Fix cast-align.

This commit is contained in:
HiFiPhile 2023-09-19 16:32:49 +02:00
parent 9d0251f7a6
commit 6be7f354c2

View File

@ -631,64 +631,55 @@ static bool audiod_rx_done_cb(uint8_t rhport, audiod_function_t* audio, uint16_t
// Decoding according to 2.3.1.5 Audio Streams // Decoding according to 2.3.1.5 Audio Streams
// Helper function // Helper function
static inline uint8_t * audiod_interleaved_copy_bytes_fast_decode(uint16_t const nBytesToCopy, uint8_t * dst, uint8_t * dst_end, uint8_t * src, uint8_t const n_ff_used) static inline void * audiod_interleaved_copy_bytes_fast_decode(uint16_t const nBytesToCopy, void * dst, const void * dst_end, void * src, uint8_t const n_ff_used)
{ {
// Due to one FIFO contains 2 channels, data always aligned to (nBytesToCopy * 2) // Due to one FIFO contains 2 channels, data always aligned to (nBytesToCopy * 2)
uint16_t * dst16 = dst;
uint16_t * src16 = src;
const uint16_t * dst_end16 = dst_end;
uint32_t * dst32 = dst;
uint32_t * src32 = src;
const uint32_t * dst_end32 = dst_end;
switch (nBytesToCopy) if (nBytesToCopy == 1)
{ {
case 1: while(dst16 < dst_end16)
while((uint8_t *)dst < dst_end) {
{ *dst16++ = *src16++;
*(uint16_t*)dst = *(uint16_t*)src; src16 += n_ff_used - 1;
src += 2; }
dst += 2; return src16;
src += 2 * (n_ff_used - 1); }
} else if (nBytesToCopy == 2)
break; {
while(dst32 < dst_end32)
case 2: {
while((uint8_t *)dst < dst_end) *dst32++ = *src32++;
{ src32 += n_ff_used - 1;
*(uint32_t*)dst = *(uint32_t*)src; }
src += 4; return src32;
dst += 4; }
src += 4 * (n_ff_used - 1); else if (nBytesToCopy == 3)
} {
break; while(dst16 < dst_end16)
{
case 3: *dst16++ = *src16++;
while((uint8_t *)dst < dst_end) *dst16++ = *src16++;
{ *dst16++ = *src16++;
*(uint16_t*)dst = *(uint16_t*)src; src16 += 3 * (n_ff_used - 1);
src += 2; }
dst += 2; return src16;
*(uint16_t*)dst = *(uint16_t*)src; }
src += 2; else // nBytesToCopy == 4
dst += 2; {
*(uint16_t*)dst = *(uint16_t*)src; while(dst32 < dst_end32)
src += 2; {
dst += 2; *dst32++ = *src32++;
src += 6 * (n_ff_used - 1); *dst32++ = *src32++;
} src32 += 2 * (n_ff_used - 1);
break; }
return src32;
case 4:
while((uint8_t *)dst < dst_end)
{
*(uint32_t*)dst++ = *(uint32_t*)src++;
src += 4;
dst += 4;
*(uint32_t*)dst++ = *(uint32_t*)src++;
src += 4;
dst += 4;
src += 8 * (n_ff_used - 1);
}
break;
} }
return src;
} }
static bool audiod_decode_type_I_pcm(uint8_t rhport, audiod_function_t* audio, uint16_t n_bytes_received) static bool audiod_decode_type_I_pcm(uint8_t rhport, audiod_function_t* audio, uint16_t n_bytes_received)
@ -935,62 +926,55 @@ range [-1, +1)
* */ * */
// Helper function // Helper function
static inline uint8_t * audiod_interleaved_copy_bytes_fast_encode(uint16_t const nBytesToCopy, uint8_t * src, uint8_t * src_end, uint8_t * dst, uint8_t const n_ff_used) static inline void * audiod_interleaved_copy_bytes_fast_encode(uint16_t const nBytesToCopy, void * src, const void * src_end, void * dst, uint8_t const n_ff_used)
{ {
// Due to one FIFO contains 2 channels, data always aligned to (nBytesToCopy * 2) // Due to one FIFO contains 2 channels, data always aligned to (nBytesToCopy * 2)
switch (nBytesToCopy) uint16_t * dst16 = dst;
uint16_t * src16 = src;
const uint16_t * src_end16 = src_end;
uint32_t * dst32 = dst;
uint32_t * src32 = src;
const uint32_t * src_end32 = src_end;
if (nBytesToCopy == 1)
{ {
case 1: while(src16 < src_end16)
while(src < src_end) {
{ *dst16++ = *src16++;
*(uint16_t*)dst = *(uint16_t*)src; dst16 += n_ff_used - 1;
src += 2; }
dst += 2; return dst16;
dst += 2 * (n_ff_used - 1); }
} else if (nBytesToCopy == 2)
break; {
while(src32 < src_end32)
case 2: {
while(src < src_end) *dst32++ = *src32++;
{ dst32 += n_ff_used - 1;
*(uint32_t*)dst = *(uint32_t*)src; }
src += 4; return dst32;
dst += 4; }
dst += 4 * (n_ff_used - 1); else if (nBytesToCopy == 3)
} {
break; while(src16 < src_end16)
{
case 3: *dst16++ = *src16++;
while(src < src_end) *dst16++ = *src16++;
{ *dst16++ = *src16++;
*(uint16_t*)dst = *(uint16_t*)src; dst16 += 3 * (n_ff_used - 1);
src += 2; }
dst += 2; return dst16;
*(uint16_t*)dst = *(uint16_t*)src; }
src += 2; else // nBytesToCopy == 4
dst += 2; {
*(uint16_t*)dst = *(uint16_t*)src; while(src32 < src_end32)
src += 2; {
dst += 2; *dst32++ = *src32++;
dst += 6 * (n_ff_used - 1); *dst32++ = *src32++;
} dst32 += 2 * (n_ff_used - 1);
break; }
return dst32;
case 4:
while(src < src_end)
{
*(uint32_t*)dst++ = *(uint32_t*)src++;
src += 4;
dst += 4;
*(uint32_t*)dst++ = *(uint32_t*)src++;
src += 4;
dst += 4;
dst += 8 * (n_ff_used - 1);
}
break;
} }
return dst;
} }
static uint16_t audiod_encode_type_I_pcm(uint8_t rhport, audiod_function_t* audio) static uint16_t audiod_encode_type_I_pcm(uint8_t rhport, audiod_function_t* audio)