mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
fmt: use faster s24 to f32 conversion
This commit is contained in:
parent
25c81e8c34
commit
13010d5d2e
2 changed files with 22 additions and 23 deletions
|
|
@ -46,27 +46,21 @@
|
|||
#define S32_MAX 2147483647
|
||||
#define S32_SCALE 2147483647
|
||||
|
||||
union s24_data {
|
||||
struct {
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
uint16_t lo;
|
||||
int16_t hi;
|
||||
#else
|
||||
int16_t hi;
|
||||
uint16_t lo;
|
||||
#endif
|
||||
} s24;
|
||||
int32_t value;
|
||||
};
|
||||
|
||||
static inline int32_t read_s24(const void *src)
|
||||
{
|
||||
union s24_data d;
|
||||
const uint8_t *s = src;
|
||||
d.s24.hi = ((int8_t*)s)[2];
|
||||
d.s24.lo = *((uint16_t*)s);
|
||||
return d.value;
|
||||
union {
|
||||
int8_t v[4];
|
||||
int32_t value;
|
||||
} d;
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
memcpy(&d.v[1], src, 3);
|
||||
#else
|
||||
memcpy(&d.v[0], src, 3);
|
||||
#endif
|
||||
return d.value >> 8;
|
||||
}
|
||||
|
||||
#define READ24(s) read_s24(s)
|
||||
|
||||
#if defined (__SSE__)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue