mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
fmt-ops: add support for s24 with endian conversion
This commit is contained in:
parent
c047bab910
commit
f4387e0568
3 changed files with 43 additions and 0 deletions
|
|
@ -316,6 +316,22 @@ conv_s24_to_f32d_c(struct convert *conv, void * SPA_RESTRICT dst[], const void *
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
conv_s24s_to_f32d_c(struct convert *conv, void * SPA_RESTRICT dst[], const void * SPA_RESTRICT src[],
|
||||
uint32_t n_samples)
|
||||
{
|
||||
const uint8_t *s = src[0];
|
||||
float **d = (float **) dst;
|
||||
uint32_t i, j, n_channels = conv->n_channels;
|
||||
|
||||
for (j = 0; j < n_samples; j++) {
|
||||
for (i = 0; i < n_channels; i++) {
|
||||
d[i][j] = S24_TO_F32(read_s24s(s));
|
||||
s += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
conv_s24d_to_f32_c(struct convert *conv, void * SPA_RESTRICT dst[], const void * SPA_RESTRICT src[],
|
||||
uint32_t n_samples)
|
||||
|
|
|
|||
|
|
@ -89,6 +89,8 @@ static struct conv_info conv_table[] =
|
|||
{ SPA_AUDIO_FORMAT_S24, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_s24_to_f32d_c },
|
||||
{ SPA_AUDIO_FORMAT_S24P, SPA_AUDIO_FORMAT_F32, 0, 0, conv_s24d_to_f32_c },
|
||||
|
||||
{ SPA_AUDIO_FORMAT_S24_OE, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_s24s_to_f32d_c },
|
||||
|
||||
{ SPA_AUDIO_FORMAT_S24_32, SPA_AUDIO_FORMAT_F32, 0, 0, conv_s24_32_to_f32_c },
|
||||
{ SPA_AUDIO_FORMAT_S24_32P, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_s24_32d_to_f32d_c },
|
||||
{ SPA_AUDIO_FORMAT_S24_32, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_s24_32_to_f32d_c },
|
||||
|
|
|
|||
|
|
@ -63,6 +63,16 @@ static inline int32_t read_s24(const void *src)
|
|||
#endif
|
||||
}
|
||||
|
||||
static inline int32_t read_s24s(const void *src)
|
||||
{
|
||||
const int8_t *s = src;
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
return (((int32_t)s[0] << 16) | ((uint32_t)(uint8_t)s[1] << 8) | (uint32_t)(uint8_t)s[2]);
|
||||
#else
|
||||
return (((int32_t)s[2] << 16) | ((uint32_t)(uint8_t)s[1] << 8) | (uint32_t)(uint8_t)s[0]);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void write_s24(void *dst, int32_t val)
|
||||
{
|
||||
uint8_t *d = dst;
|
||||
|
|
@ -77,6 +87,20 @@ static inline void write_s24(void *dst, int32_t val)
|
|||
#endif
|
||||
}
|
||||
|
||||
static inline void write_s24s(void *dst, int32_t val)
|
||||
{
|
||||
uint8_t *d = dst;
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
d[0] = (uint8_t) (val >> 16);
|
||||
d[1] = (uint8_t) (val >> 8);
|
||||
d[2] = (uint8_t) (val);
|
||||
#else
|
||||
d[0] = (uint8_t) (val);
|
||||
d[1] = (uint8_t) (val >> 8);
|
||||
d[2] = (uint8_t) (val >> 16);
|
||||
#endif
|
||||
}
|
||||
|
||||
#define MAX_NS 64
|
||||
|
||||
struct convert {
|
||||
|
|
@ -127,6 +151,7 @@ DEFINE_FUNCTION(s32d_to_f32, c);
|
|||
DEFINE_FUNCTION(s24d_to_f32d, c);
|
||||
DEFINE_FUNCTION(s24_to_f32, c);
|
||||
DEFINE_FUNCTION(s24_to_f32d, c);
|
||||
DEFINE_FUNCTION(s24s_to_f32d, c);
|
||||
DEFINE_FUNCTION(s24d_to_f32, c);
|
||||
DEFINE_FUNCTION(s24_32d_to_f32d, c);
|
||||
DEFINE_FUNCTION(s24_32_to_f32, c);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue