mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
audioconvert: add converstion to and from alaw/ulaw
This commit is contained in:
parent
d0d7f2f20b
commit
df9f79d869
4 changed files with 2235 additions and 0 deletions
|
|
@ -31,6 +31,7 @@
|
|||
#include <spa/param/audio/format-utils.h>
|
||||
|
||||
#include "fmt-ops.h"
|
||||
#include "law.h"
|
||||
|
||||
void
|
||||
conv_copy8d_c(struct convert *conv, void * SPA_RESTRICT dst[], const void * SPA_RESTRICT src[],
|
||||
|
|
@ -210,6 +211,34 @@ conv_s8d_to_f32_c(struct convert *conv, void * SPA_RESTRICT dst[], const void *
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
conv_alaw_to_f32d_c(struct convert *conv, void * SPA_RESTRICT dst[], const void * SPA_RESTRICT src[],
|
||||
uint32_t n_samples)
|
||||
{
|
||||
const int8_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] = alaw_to_f32(*s++);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
conv_ulaw_to_f32d_c(struct convert *conv, void * SPA_RESTRICT dst[], const void * SPA_RESTRICT src[],
|
||||
uint32_t n_samples)
|
||||
{
|
||||
const int8_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] = ulaw_to_f32(*s++);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
conv_s16d_to_f32d_c(struct convert *conv, void * SPA_RESTRICT dst[], const void * SPA_RESTRICT src[],
|
||||
uint32_t n_samples)
|
||||
|
|
@ -617,6 +646,34 @@ conv_f32d_to_s8_c(struct convert *conv, void * SPA_RESTRICT dst[], const void *
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
conv_f32d_to_alaw_c(struct convert *conv, void * SPA_RESTRICT dst[], const void * SPA_RESTRICT src[],
|
||||
uint32_t n_samples)
|
||||
{
|
||||
const float **s = (const float **) src;
|
||||
int8_t *d = dst[0];
|
||||
uint32_t i, j, n_channels = conv->n_channels;
|
||||
|
||||
for (j = 0; j < n_samples; j++) {
|
||||
for (i = 0; i < n_channels; i++)
|
||||
*d++ = f32_to_alaw(s[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
conv_f32d_to_ulaw_c(struct convert *conv, void * SPA_RESTRICT dst[], const void * SPA_RESTRICT src[],
|
||||
uint32_t n_samples)
|
||||
{
|
||||
const float **s = (const float **) src;
|
||||
int8_t *d = dst[0];
|
||||
uint32_t i, j, n_channels = conv->n_channels;
|
||||
|
||||
for (j = 0; j < n_samples; j++) {
|
||||
for (i = 0; i < n_channels; i++)
|
||||
*d++ = f32_to_ulaw(s[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
conv_f32d_to_s16d_c(struct convert *conv, void * SPA_RESTRICT dst[], const void * SPA_RESTRICT src[],
|
||||
uint32_t n_samples)
|
||||
|
|
|
|||
|
|
@ -57,6 +57,9 @@ static struct conv_info conv_table[] =
|
|||
{ SPA_AUDIO_FORMAT_S8, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_s8_to_f32d_c },
|
||||
{ SPA_AUDIO_FORMAT_S8P, SPA_AUDIO_FORMAT_F32, 0, 0, conv_s8d_to_f32_c },
|
||||
|
||||
{ SPA_AUDIO_FORMAT_ALAW, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_alaw_to_f32d_c },
|
||||
{ SPA_AUDIO_FORMAT_ULAW, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_ulaw_to_f32d_c },
|
||||
|
||||
{ SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_F32, 0, 0, conv_s16_to_f32_c },
|
||||
{ SPA_AUDIO_FORMAT_S16P, SPA_AUDIO_FORMAT_F32P, 0, 0, conv_s16d_to_f32d_c },
|
||||
#if defined (HAVE_NEON)
|
||||
|
|
@ -133,6 +136,9 @@ static struct conv_info conv_table[] =
|
|||
{ SPA_AUDIO_FORMAT_F32, SPA_AUDIO_FORMAT_S8P, 0, 0, conv_f32_to_s8d_c },
|
||||
{ SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_S8, 0, 0, conv_f32d_to_s8_c },
|
||||
|
||||
{ SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_ALAW, 0, 0, conv_f32d_to_alaw_c },
|
||||
{ SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_ULAW, 0, 0, conv_f32d_to_ulaw_c },
|
||||
|
||||
#if defined (HAVE_SSE2)
|
||||
{ SPA_AUDIO_FORMAT_F32, SPA_AUDIO_FORMAT_S16, 0, SPA_CPU_FLAG_SSE2, conv_f32_to_s16_sse2 },
|
||||
#endif
|
||||
|
|
@ -200,6 +206,11 @@ static struct conv_info conv_table[] =
|
|||
{ SPA_AUDIO_FORMAT_S8, SPA_AUDIO_FORMAT_S8P, 0, 0, conv_deinterleave_8_c },
|
||||
{ SPA_AUDIO_FORMAT_S8P, SPA_AUDIO_FORMAT_S8, 0, 0, conv_interleave_8_c },
|
||||
|
||||
/* alaw */
|
||||
{ SPA_AUDIO_FORMAT_ALAW, SPA_AUDIO_FORMAT_ALAW, 0, 0, conv_copy8_c },
|
||||
/* ulaw */
|
||||
{ SPA_AUDIO_FORMAT_ULAW, SPA_AUDIO_FORMAT_ULAW, 0, 0, conv_copy8_c },
|
||||
|
||||
/* s16 */
|
||||
{ SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_S16, 0, 0, conv_copy16_c },
|
||||
{ SPA_AUDIO_FORMAT_S16P, SPA_AUDIO_FORMAT_S16P, 0, 0, conv_copy16d_c },
|
||||
|
|
|
|||
|
|
@ -161,6 +161,8 @@ DEFINE_FUNCTION(s8d_to_f32d, c);
|
|||
DEFINE_FUNCTION(s8_to_f32, c);
|
||||
DEFINE_FUNCTION(s8_to_f32d, c);
|
||||
DEFINE_FUNCTION(s8d_to_f32, c);
|
||||
DEFINE_FUNCTION(ulaw_to_f32d, c);
|
||||
DEFINE_FUNCTION(alaw_to_f32d, c);
|
||||
DEFINE_FUNCTION(s16d_to_f32d, c);
|
||||
DEFINE_FUNCTION(s16_to_f32, c);
|
||||
DEFINE_FUNCTION(s16_to_f32d, c);
|
||||
|
|
@ -189,6 +191,8 @@ DEFINE_FUNCTION(f32d_to_s8d, c);
|
|||
DEFINE_FUNCTION(f32_to_s8, c);
|
||||
DEFINE_FUNCTION(f32_to_s8d, c);
|
||||
DEFINE_FUNCTION(f32d_to_s8, c);
|
||||
DEFINE_FUNCTION(f32d_to_alaw, c);
|
||||
DEFINE_FUNCTION(f32d_to_ulaw, c);
|
||||
DEFINE_FUNCTION(f32d_to_s16d, c);
|
||||
DEFINE_FUNCTION(f32_to_s16, c);
|
||||
DEFINE_FUNCTION(f32_to_s16d, c);
|
||||
|
|
|
|||
2163
spa/plugins/audioconvert/law.h
Normal file
2163
spa/plugins/audioconvert/law.h
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue