2018-04-02 11:21:29 +02:00
|
|
|
/* Spa
|
|
|
|
|
*
|
2018-11-05 17:48:52 +01:00
|
|
|
* Copyright © 2018 Wim Taymans
|
2018-04-02 11:21:29 +02:00
|
|
|
*
|
2018-11-05 17:48:52 +01:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
2018-04-02 11:21:29 +02:00
|
|
|
*
|
2018-11-05 17:48:52 +01:00
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
* Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
2018-04-02 11:21:29 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdio.h>
|
2019-01-23 15:59:54 +01:00
|
|
|
#include <math.h>
|
2018-04-02 11:21:29 +02:00
|
|
|
|
2018-12-17 13:26:54 +01:00
|
|
|
#include <spa/support/cpu.h>
|
2018-04-02 11:21:29 +02:00
|
|
|
#include <spa/utils/defs.h>
|
2019-01-23 15:59:54 +01:00
|
|
|
#include <spa/param/audio/format-utils.h>
|
2018-04-02 11:21:29 +02:00
|
|
|
|
2018-04-05 15:38:10 +02:00
|
|
|
#define U8_MIN 0
|
2018-05-08 10:42:17 +02:00
|
|
|
#define U8_MAX 255
|
2019-01-23 15:59:54 +01:00
|
|
|
#define U8_SCALE 127.5f
|
2018-05-08 10:42:17 +02:00
|
|
|
#define U8_OFFS 128
|
2019-01-23 15:59:54 +01:00
|
|
|
#define U8_TO_F32(v) ((((uint8_t)(v)) * (1.0f / U8_OFFS)) - 1.0)
|
|
|
|
|
#define F32_TO_U8(v) (uint8_t)((SPA_CLAMP(v, -1.0f, 1.0f) * U8_SCALE) + U8_OFFS)
|
2018-04-02 20:05:11 +02:00
|
|
|
|
2018-05-08 10:42:17 +02:00
|
|
|
#define S16_MIN -32767
|
|
|
|
|
#define S16_MAX 32767
|
2018-10-30 08:37:07 +00:00
|
|
|
#define S16_MAX_F 32767.0f
|
2019-01-23 15:59:54 +01:00
|
|
|
#define S16_SCALE 32767.0f
|
|
|
|
|
#define S16_TO_F32(v) (((int16_t)(v)) * (1.0f / S16_SCALE))
|
|
|
|
|
#define F32_TO_S16(v) (int16_t)(SPA_CLAMP(v, -1.0f, 1.0f) * S16_SCALE)
|
2018-04-02 20:05:11 +02:00
|
|
|
|
2018-05-08 10:42:17 +02:00
|
|
|
#define S24_MIN -8388607
|
|
|
|
|
#define S24_MAX 8388607
|
2018-07-31 12:23:35 +02:00
|
|
|
#define S24_MAX_F 8388607.0f
|
2019-01-23 15:59:54 +01:00
|
|
|
#define S24_SCALE 8388607.0f
|
|
|
|
|
#define S24_TO_F32(v) (((int32_t)(v)) * (1.0f / S24_SCALE))
|
|
|
|
|
#define F32_TO_S24(v) (int32_t)(SPA_CLAMP(v, -1.0f, 1.0f) * S24_SCALE)
|
|
|
|
|
|
2018-04-02 11:21:29 +02:00
|
|
|
|
2019-01-23 15:59:54 +01:00
|
|
|
#define S32_TO_F32(v) S24_TO_F32((v) >> 8)
|
|
|
|
|
#define F32_TO_S32(v) (F32_TO_S24(v) << 8)
|
2018-04-05 15:38:10 +02:00
|
|
|
|
2018-11-08 09:56:58 +01:00
|
|
|
|
|
|
|
|
static inline int32_t read_s24(const void *src)
|
|
|
|
|
{
|
2019-01-07 13:49:52 +01:00
|
|
|
const int8_t *s = src;
|
2018-11-21 15:51:03 +01:00
|
|
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
2019-01-07 13:49:52 +01:00
|
|
|
return (((int32_t)s[2] << 16) | ((uint32_t)(uint8_t)s[1] << 8) | (uint32_t)(uint8_t)s[0]);
|
2018-11-21 15:51:03 +01:00
|
|
|
#else
|
2019-01-07 13:49:52 +01:00
|
|
|
return (((int32_t)s[0] << 16) | ((uint32_t)(uint8_t)s[1] << 8) | (uint32_t)(uint8_t)s[2]);
|
2018-11-21 15:51:03 +01:00
|
|
|
#endif
|
2018-11-08 09:56:58 +01:00
|
|
|
}
|
2018-11-21 15:51:03 +01:00
|
|
|
|
2019-01-23 15:59:54 +01:00
|
|
|
static inline void write_s24(void *dst, int32_t val)
|
|
|
|
|
{
|
|
|
|
|
uint8_t *d = dst;
|
|
|
|
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
|
|
|
|
d[0] = (uint8_t) (val);
|
|
|
|
|
d[1] = (uint8_t) (val >> 8);
|
|
|
|
|
d[2] = (uint8_t) (val >> 16);
|
|
|
|
|
#else
|
|
|
|
|
d[0] = (uint8_t) (val >> 16);
|
|
|
|
|
d[1] = (uint8_t) (val >> 8);
|
|
|
|
|
d[2] = (uint8_t) (val);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2018-11-08 09:56:58 +01:00
|
|
|
|
2018-12-20 16:11:25 +01:00
|
|
|
#if defined (__SSE2__)
|
|
|
|
|
#include "fmt-ops-sse2.c"
|
2018-07-31 12:23:35 +02:00
|
|
|
#endif
|
|
|
|
|
|
2018-04-05 15:38:10 +02:00
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_copy8d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
int i;
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-12-13 12:02:47 +01:00
|
|
|
memcpy(dst[i], src[i], n_samples);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_copy8(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
|
|
|
|
{
|
|
|
|
|
memcpy(dst[0], src[0], n_samples * n_channels);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
conv_copy16d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-12-13 12:02:47 +01:00
|
|
|
{
|
|
|
|
|
int i;
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-12-13 12:02:47 +01:00
|
|
|
memcpy(dst[i], src[i], n_samples * sizeof(int16_t));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_copy16(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
|
|
|
|
{
|
|
|
|
|
memcpy(dst[0], src[0], n_samples * sizeof(int16_t) * n_channels);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
conv_copy24d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-12-13 12:02:47 +01:00
|
|
|
{
|
|
|
|
|
int i;
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-12-13 12:02:47 +01:00
|
|
|
memcpy(dst[i], src[i], n_samples * 3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_copy24(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
|
|
|
|
{
|
|
|
|
|
memcpy(dst[0], src[0], n_samples * 3 * n_channels);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
conv_copy32d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-12-13 12:02:47 +01:00
|
|
|
{
|
|
|
|
|
int i;
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-12-13 12:02:47 +01:00
|
|
|
memcpy(dst[i], src[i], n_samples * sizeof(int32_t));
|
2018-04-05 15:38:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_copy32(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
|
|
|
|
{
|
|
|
|
|
memcpy(dst[0], src[0], n_samples * sizeof(int32_t) * n_channels);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
conv_u8d_to_f32d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
int i, j;
|
|
|
|
|
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++) {
|
2018-04-09 09:30:56 +02:00
|
|
|
const uint8_t *s = src[i];
|
2018-04-05 15:38:10 +02:00
|
|
|
float *d = dst[i];
|
|
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++)
|
2018-04-05 15:38:10 +02:00
|
|
|
d[j] = U8_TO_F32(s[j]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_u8_to_f32(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
|
|
|
|
{
|
|
|
|
|
conv_u8d_to_f32d(data, dst, src, 1, n_samples * n_channels);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
conv_u8_to_f32d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
2018-04-09 09:30:56 +02:00
|
|
|
const uint8_t *s = src[0];
|
2018-04-05 15:38:10 +02:00
|
|
|
float **d = (float **) dst;
|
|
|
|
|
int i, j;
|
|
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-04-05 15:38:10 +02:00
|
|
|
d[i][j] = U8_TO_F32(*s++);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-02 11:21:29 +02:00
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_u8d_to_f32(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-02 11:21:29 +02:00
|
|
|
{
|
2018-04-09 09:30:56 +02:00
|
|
|
const uint8_t **s = (const uint8_t **) src;
|
2018-04-05 15:38:10 +02:00
|
|
|
float *d = dst[0];
|
|
|
|
|
int i, j;
|
|
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-04-05 15:38:10 +02:00
|
|
|
*d++ = U8_TO_F32(s[i][j]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_s16d_to_f32d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
int i, j;
|
2018-04-02 11:21:29 +02:00
|
|
|
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++) {
|
2018-04-05 15:38:10 +02:00
|
|
|
const int16_t *s = src[i];
|
|
|
|
|
float *d = dst[i];
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++)
|
2018-04-05 15:38:10 +02:00
|
|
|
d[j] = S16_TO_F32(s[j]);
|
|
|
|
|
}
|
2018-04-02 11:21:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_s16_to_f32(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
|
|
|
|
{
|
|
|
|
|
conv_s16d_to_f32d(data, dst, src, 1, n_samples * n_channels);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
conv_s16_to_f32d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-02 11:21:29 +02:00
|
|
|
{
|
2018-04-05 15:38:10 +02:00
|
|
|
const int16_t *s = src[0];
|
2018-04-02 11:21:29 +02:00
|
|
|
float **d = (float **) dst;
|
2018-04-05 15:38:10 +02:00
|
|
|
int i, j;
|
2018-04-02 11:21:29 +02:00
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-04-05 15:38:10 +02:00
|
|
|
d[i][j] = S16_TO_F32(*s++);
|
|
|
|
|
}
|
2018-04-02 11:21:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_s16d_to_f32(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-02 11:21:29 +02:00
|
|
|
{
|
2018-04-02 20:05:11 +02:00
|
|
|
const int16_t **s = (const int16_t **) src;
|
2018-04-05 15:38:10 +02:00
|
|
|
float *d = dst[0];
|
2018-12-13 12:02:47 +01:00
|
|
|
int i, j;
|
2018-04-02 11:21:29 +02:00
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-12-13 12:02:47 +01:00
|
|
|
*d++ = S16_TO_F32(s[i][j]);
|
2018-04-05 15:38:10 +02:00
|
|
|
}
|
2018-04-02 11:21:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_s32d_to_f32d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-02 11:21:29 +02:00
|
|
|
{
|
2018-04-05 15:38:10 +02:00
|
|
|
int i, j;
|
2018-04-02 11:21:29 +02:00
|
|
|
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++) {
|
2018-04-05 15:38:10 +02:00
|
|
|
const int32_t *s = src[i];
|
|
|
|
|
float *d = dst[i];
|
|
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++)
|
2018-04-05 15:38:10 +02:00
|
|
|
d[j] = S32_TO_F32(s[j]);
|
|
|
|
|
}
|
2018-04-02 20:05:11 +02:00
|
|
|
}
|
|
|
|
|
|
2018-04-05 15:38:10 +02:00
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_s32_to_f32(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
|
|
|
|
{
|
|
|
|
|
conv_s32d_to_f32d(data, dst, src, 1, n_samples * n_channels);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
conv_s32_to_f32d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
const int32_t *s = src[0];
|
|
|
|
|
float **d = (float **) dst;
|
|
|
|
|
int i, j;
|
|
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-04-05 15:38:10 +02:00
|
|
|
d[i][j] = S32_TO_F32(*s++);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-02 20:05:11 +02:00
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_s32d_to_f32(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-02 20:05:11 +02:00
|
|
|
{
|
2018-04-05 15:38:10 +02:00
|
|
|
const int32_t **s = (const int32_t **) src;
|
|
|
|
|
float *d = dst[0];
|
2018-12-13 12:02:47 +01:00
|
|
|
int i, j;
|
2018-04-02 20:05:11 +02:00
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-12-13 12:02:47 +01:00
|
|
|
*d++ = S32_TO_F32(s[i][j]);
|
2018-04-05 15:38:10 +02:00
|
|
|
}
|
2018-04-02 20:05:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_s24d_to_f32d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-02 20:05:11 +02:00
|
|
|
{
|
2018-04-05 15:38:10 +02:00
|
|
|
int i, j;
|
|
|
|
|
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++) {
|
2018-04-05 15:38:10 +02:00
|
|
|
const int8_t *s = src[i];
|
|
|
|
|
float *d = dst[i];
|
|
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-23 15:59:54 +01:00
|
|
|
d[j] = S24_TO_F32(read_s24(s));
|
2018-04-05 15:38:10 +02:00
|
|
|
s += 3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_s24_to_f32(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
|
|
|
|
{
|
|
|
|
|
conv_s24d_to_f32d(data, dst, src, 1, n_samples * n_channels);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
conv_s24_to_f32d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
2018-06-25 14:34:36 +02:00
|
|
|
const uint8_t *s = src[0];
|
2018-04-02 20:05:11 +02:00
|
|
|
float **d = (float **) dst;
|
2018-04-05 15:38:10 +02:00
|
|
|
int i, j;
|
2018-04-02 20:05:11 +02:00
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++) {
|
2019-01-23 15:59:54 +01:00
|
|
|
d[i][j] = S24_TO_F32(read_s24(s));
|
2018-04-05 15:38:10 +02:00
|
|
|
s += 3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_s24d_to_f32(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
2018-06-25 14:34:36 +02:00
|
|
|
const uint8_t **s = (const uint8_t **) src;
|
2018-04-05 15:38:10 +02:00
|
|
|
float *d = dst[0];
|
2018-12-13 12:02:47 +01:00
|
|
|
int i, j;
|
2018-04-05 15:38:10 +02:00
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++) {
|
2019-01-23 15:59:54 +01:00
|
|
|
*d++ = S24_TO_F32(read_s24(&s[i][j*3]));
|
2018-04-05 15:38:10 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_s24_32d_to_f32d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
int i, j;
|
|
|
|
|
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++) {
|
2018-04-05 15:38:10 +02:00
|
|
|
const int32_t *s = src[i];
|
|
|
|
|
float *d = dst[i];
|
|
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++)
|
2018-04-05 15:38:10 +02:00
|
|
|
d[j] = S24_TO_F32(s[j]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_s24_32_to_f32(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
|
|
|
|
{
|
|
|
|
|
conv_s24_32d_to_f32d(data, dst, src, 1, n_samples * n_channels);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
conv_s24_32_to_f32d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
const int32_t *s = src[0];
|
|
|
|
|
float **d = (float **) dst;
|
|
|
|
|
int i, j;
|
|
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-04-05 15:38:10 +02:00
|
|
|
d[i][j] = S24_TO_F32(*s++);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_s24_32d_to_f32(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
const int32_t **s = (const int32_t **) src;
|
|
|
|
|
float *d = dst[0];
|
2018-12-13 12:02:47 +01:00
|
|
|
int i, j;
|
2018-04-05 15:38:10 +02:00
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-12-13 12:02:47 +01:00
|
|
|
*d++ = S24_TO_F32(s[i][j]);
|
2018-04-05 15:38:10 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_f32d_to_u8d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
int i, j;
|
|
|
|
|
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++) {
|
2018-04-05 15:38:10 +02:00
|
|
|
const float *s = src[i];
|
2019-01-07 13:49:52 +01:00
|
|
|
uint8_t *d = dst[i];
|
2018-04-05 15:38:10 +02:00
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++)
|
2018-04-05 15:38:10 +02:00
|
|
|
d[j] = F32_TO_U8(s[j]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_f32_to_u8(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
|
|
|
|
{
|
|
|
|
|
conv_f32d_to_u8d(data, dst, src, 1, n_samples * n_channels);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
conv_f32_to_u8d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
const float *s = src[0];
|
2019-01-07 13:49:52 +01:00
|
|
|
uint8_t **d = (uint8_t **) dst;
|
2018-04-05 15:38:10 +02:00
|
|
|
int i, j;
|
|
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-04-05 15:38:10 +02:00
|
|
|
d[i][j] = F32_TO_U8(*s++);
|
|
|
|
|
}
|
2018-04-02 11:21:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_f32d_to_u8(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-02 20:05:11 +02:00
|
|
|
{
|
2018-06-25 17:08:34 +02:00
|
|
|
const float **s = (const float **) src;
|
2019-01-07 13:49:52 +01:00
|
|
|
uint8_t *d = dst[0];
|
2018-12-13 12:02:47 +01:00
|
|
|
int i, j;
|
2018-04-05 15:38:10 +02:00
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-12-13 12:02:47 +01:00
|
|
|
*d++ = F32_TO_U8(s[i][j]);
|
2018-04-05 15:38:10 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_f32d_to_s16d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
2018-12-13 12:02:47 +01:00
|
|
|
int i, j;
|
2018-04-05 15:38:10 +02:00
|
|
|
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++) {
|
2018-04-05 15:38:10 +02:00
|
|
|
const float *s = src[i];
|
|
|
|
|
int16_t *d = dst[i];
|
|
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++)
|
|
|
|
|
d[j] = F32_TO_S16(s[j]);
|
2018-04-05 15:38:10 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_f32_to_s16(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
|
|
|
|
{
|
|
|
|
|
conv_f32d_to_s16d(data, dst, src, 1, n_samples * n_channels);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
conv_f32_to_s16d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
const float *s = src[0];
|
|
|
|
|
int16_t **d = (int16_t **) dst;
|
2018-12-13 12:02:47 +01:00
|
|
|
int i, j;
|
2018-04-05 15:38:10 +02:00
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-12-13 12:02:47 +01:00
|
|
|
d[i][j] = F32_TO_S16(*s++);
|
2018-04-05 15:38:10 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_f32d_to_s16(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
const float **s = (const float **) src;
|
|
|
|
|
int16_t *d = dst[0];
|
2018-12-13 12:02:47 +01:00
|
|
|
int i, j;
|
2018-04-02 20:05:11 +02:00
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-12-13 12:02:47 +01:00
|
|
|
*d++ = F32_TO_S16(s[i][j]);
|
2018-04-05 15:38:10 +02:00
|
|
|
}
|
2018-04-02 20:05:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_f32d_to_s32d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-02 20:05:11 +02:00
|
|
|
{
|
2018-04-05 15:38:10 +02:00
|
|
|
int i, j;
|
2018-04-02 20:05:11 +02:00
|
|
|
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++) {
|
2018-04-05 15:38:10 +02:00
|
|
|
const float *s = src[i];
|
|
|
|
|
int32_t *d = dst[i];
|
|
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++)
|
2018-04-05 15:38:10 +02:00
|
|
|
d[j] = F32_TO_S32(s[j]);
|
|
|
|
|
}
|
2018-04-02 20:05:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_f32_to_s32(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
|
|
|
|
{
|
|
|
|
|
conv_f32d_to_s32d(data, dst, src, 1, n_samples * n_channels);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
conv_f32_to_s32d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-02 11:21:29 +02:00
|
|
|
{
|
2018-04-05 15:38:10 +02:00
|
|
|
const float *s = src[0];
|
|
|
|
|
int32_t **d = (int32_t **) dst;
|
|
|
|
|
int i, j;
|
|
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-04-05 15:38:10 +02:00
|
|
|
d[i][j] = F32_TO_S32(*s++);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_f32d_to_s32(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
const float **s = (const float **) src;
|
|
|
|
|
int32_t *d = dst[0];
|
2018-12-13 12:02:47 +01:00
|
|
|
int i, j;
|
2018-04-05 15:38:10 +02:00
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-12-13 12:02:47 +01:00
|
|
|
*d++ = F32_TO_S32(s[i][j]);
|
2018-04-05 15:38:10 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-31 12:23:35 +02:00
|
|
|
|
2018-04-05 15:38:10 +02:00
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_f32d_to_s24d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
int i, j;
|
|
|
|
|
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++) {
|
2018-04-05 15:38:10 +02:00
|
|
|
const float *s = src[i];
|
2019-01-07 13:49:52 +01:00
|
|
|
uint8_t *d = dst[i];
|
2018-04-05 15:38:10 +02:00
|
|
|
|
2019-01-23 15:59:54 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
|
|
|
|
write_s24(d, F32_TO_S24(s[j]));
|
2018-04-05 15:38:10 +02:00
|
|
|
d += 3;
|
2019-01-23 15:59:54 +01:00
|
|
|
}
|
2018-04-05 15:38:10 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_f32_to_s24(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
|
|
|
|
{
|
|
|
|
|
conv_f32d_to_s24d(data, dst, src, 1, n_samples * n_channels);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
conv_f32_to_s24d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
const float *s = src[0];
|
2019-01-07 13:49:52 +01:00
|
|
|
uint8_t **d = (uint8_t **) dst;
|
2018-04-05 15:38:10 +02:00
|
|
|
int i, j;
|
|
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++) {
|
2019-01-23 15:59:54 +01:00
|
|
|
write_s24(&d[i][j*3], F32_TO_S24(*s++));
|
2018-04-05 15:38:10 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_f32d_to_s24(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
const float **s = (const float **) src;
|
2019-01-07 13:49:52 +01:00
|
|
|
uint8_t *d = dst[0];
|
2018-12-13 12:02:47 +01:00
|
|
|
int i, j;
|
2018-04-05 15:38:10 +02:00
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++) {
|
2019-01-23 15:59:54 +01:00
|
|
|
write_s24(d, F32_TO_S24(s[i][j]));
|
2018-04-05 15:38:10 +02:00
|
|
|
d += 3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_f32d_to_s24_32d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
int i, j;
|
|
|
|
|
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++) {
|
2018-04-05 15:38:10 +02:00
|
|
|
const float *s = src[i];
|
|
|
|
|
int32_t *d = dst[i];
|
|
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++)
|
2018-04-05 15:38:10 +02:00
|
|
|
d[j] = F32_TO_S24(s[j]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_f32_to_s24_32(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
|
|
|
|
{
|
|
|
|
|
conv_f32d_to_s24_32d(data, dst, src, 1, n_samples * n_channels);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
conv_f32_to_s24_32d(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
const float *s = src[0];
|
|
|
|
|
int32_t **d = (int32_t **) dst;
|
|
|
|
|
int i, j;
|
|
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-04-05 15:38:10 +02:00
|
|
|
d[i][j] = F32_TO_S24(*s++);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
conv_f32d_to_s24_32(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
const float **s = (const float **) src;
|
|
|
|
|
int32_t *d = dst[0];
|
2018-12-13 12:02:47 +01:00
|
|
|
int i, j;
|
2018-04-05 15:38:10 +02:00
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-12-13 12:02:47 +01:00
|
|
|
*d++ = F32_TO_S24(s[i][j]);
|
2018-04-05 15:38:10 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
deinterleave_8(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
const uint8_t *s = src[0];
|
2018-04-02 11:21:29 +02:00
|
|
|
uint8_t **d = (uint8_t **) dst;
|
2018-04-05 15:38:10 +02:00
|
|
|
int i, j;
|
2018-04-02 11:21:29 +02:00
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-04-05 15:38:10 +02:00
|
|
|
d[i][j] = *s++;
|
2018-04-02 11:21:29 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
deinterleave_16(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-02 11:21:29 +02:00
|
|
|
{
|
2018-04-05 15:38:10 +02:00
|
|
|
const uint16_t *s = src[0];
|
2018-04-02 11:21:29 +02:00
|
|
|
uint16_t **d = (uint16_t **) dst;
|
2018-04-05 15:38:10 +02:00
|
|
|
int i, j;
|
2018-04-02 11:21:29 +02:00
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-04-05 15:38:10 +02:00
|
|
|
d[i][j] = *s++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
deinterleave_24(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
const uint8_t *s = src[0];
|
|
|
|
|
uint8_t **d = (uint8_t **) dst;
|
|
|
|
|
int i, j;
|
|
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++) {
|
2019-01-23 15:59:54 +01:00
|
|
|
write_s24(&d[i][j*3], read_s24(s));
|
2018-04-05 15:38:10 +02:00
|
|
|
s += 3;
|
|
|
|
|
}
|
2018-04-02 11:21:29 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
deinterleave_32(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-02 11:21:29 +02:00
|
|
|
{
|
2018-04-05 15:38:10 +02:00
|
|
|
const uint32_t *s = src[0];
|
2018-04-02 11:21:29 +02:00
|
|
|
uint32_t **d = (uint32_t **) dst;
|
2018-04-05 15:38:10 +02:00
|
|
|
int i, j;
|
2018-04-02 11:21:29 +02:00
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-04-05 15:38:10 +02:00
|
|
|
d[i][j] = *s++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
interleave_8(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
const int8_t **s = (const int8_t **) src;
|
|
|
|
|
uint8_t *d = dst[0];
|
|
|
|
|
int i, j;
|
|
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-04-05 15:38:10 +02:00
|
|
|
*d++ = s[i][j];
|
2018-04-02 11:21:29 +02:00
|
|
|
}
|
|
|
|
|
}
|
2018-04-02 20:05:11 +02:00
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
interleave_16(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
const int16_t **s = (const int16_t **) src;
|
|
|
|
|
uint16_t *d = dst[0];
|
|
|
|
|
int i, j;
|
|
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-04-05 15:38:10 +02:00
|
|
|
*d++ = s[i][j];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
interleave_24(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-05 15:38:10 +02:00
|
|
|
{
|
|
|
|
|
const int8_t **s = (const int8_t **) src;
|
|
|
|
|
uint8_t *d = dst[0];
|
|
|
|
|
int i, j;
|
|
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++) {
|
2019-01-23 15:59:54 +01:00
|
|
|
write_s24(d, read_s24(&s[i][j*3]));
|
2018-04-05 15:38:10 +02:00
|
|
|
d += 3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-24 18:28:52 +01:00
|
|
|
interleave_32(void *data, void *dst[], const void *src[], int n_channels, int n_samples)
|
2018-04-02 20:05:11 +02:00
|
|
|
{
|
|
|
|
|
const int32_t **s = (const int32_t **) src;
|
2018-04-05 15:38:10 +02:00
|
|
|
uint32_t *d = dst[0];
|
|
|
|
|
int i, j;
|
2018-04-02 20:05:11 +02:00
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
for (j = 0; j < n_samples; j++) {
|
2019-01-24 18:28:52 +01:00
|
|
|
for (i = 0; i < n_channels; i++)
|
2018-04-05 15:38:10 +02:00
|
|
|
*d++ = s[i][j];
|
2018-04-02 20:05:11 +02:00
|
|
|
}
|
|
|
|
|
}
|
2018-04-06 18:39:07 +02:00
|
|
|
|
2018-12-17 10:20:18 +01:00
|
|
|
|
2019-01-24 18:28:52 +01:00
|
|
|
typedef void (*convert_func_t) (void *data, void *dst[], const void *src[],
|
|
|
|
|
int n_channels, int n_samples);
|
2018-04-06 18:39:07 +02:00
|
|
|
|
|
|
|
|
static const struct conv_info {
|
2018-08-23 17:47:57 +02:00
|
|
|
uint32_t src_fmt;
|
|
|
|
|
uint32_t dst_fmt;
|
2018-12-20 16:11:25 +01:00
|
|
|
#define FEATURE_SSE2 SPA_CPU_FLAG_SSE2
|
2018-07-31 12:23:35 +02:00
|
|
|
uint32_t features;
|
2018-04-06 18:39:07 +02:00
|
|
|
|
2018-09-13 17:03:56 +02:00
|
|
|
convert_func_t func;
|
2018-04-06 18:39:07 +02:00
|
|
|
} conv_table[] =
|
|
|
|
|
{
|
|
|
|
|
/* to f32 */
|
2018-09-13 17:03:56 +02:00
|
|
|
{ SPA_AUDIO_FORMAT_U8, SPA_AUDIO_FORMAT_F32, 0, conv_u8_to_f32 },
|
2019-01-24 18:28:52 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_U8P, SPA_AUDIO_FORMAT_F32P, 0, conv_u8d_to_f32d },
|
2018-09-13 17:03:56 +02:00
|
|
|
{ SPA_AUDIO_FORMAT_U8, SPA_AUDIO_FORMAT_F32P, 0, conv_u8_to_f32d },
|
|
|
|
|
{ SPA_AUDIO_FORMAT_U8P, SPA_AUDIO_FORMAT_F32, 0, conv_u8d_to_f32 },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_F32, 0, conv_s16_to_f32 },
|
2019-01-24 18:28:52 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_S16P, SPA_AUDIO_FORMAT_F32P, 0, conv_s16d_to_f32d },
|
2018-12-20 16:11:25 +01:00
|
|
|
#if defined (__SSE2__)
|
|
|
|
|
{ SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_F32P, FEATURE_SSE2, conv_s16_to_f32d_sse2 },
|
2018-07-31 12:23:35 +02:00
|
|
|
#endif
|
2018-09-13 17:03:56 +02:00
|
|
|
{ SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_F32P, 0, conv_s16_to_f32d },
|
|
|
|
|
{ SPA_AUDIO_FORMAT_S16P, SPA_AUDIO_FORMAT_F32, 0, conv_s16d_to_f32 },
|
|
|
|
|
|
2018-12-13 12:02:47 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_F32, SPA_AUDIO_FORMAT_F32, 0, conv_copy32 },
|
2019-01-24 18:28:52 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_F32P, 0, conv_copy32d },
|
2018-09-13 17:03:56 +02:00
|
|
|
{ SPA_AUDIO_FORMAT_F32, SPA_AUDIO_FORMAT_F32P, 0, deinterleave_32 },
|
|
|
|
|
{ SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_F32, 0, interleave_32 },
|
|
|
|
|
|
|
|
|
|
{ SPA_AUDIO_FORMAT_S32, SPA_AUDIO_FORMAT_F32, 0, conv_s32_to_f32 },
|
2019-01-24 18:28:52 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_S32P, SPA_AUDIO_FORMAT_F32P, 0, conv_s32d_to_f32d },
|
2018-09-13 17:03:56 +02:00
|
|
|
{ SPA_AUDIO_FORMAT_S32, SPA_AUDIO_FORMAT_F32P, 0, conv_s32_to_f32d },
|
|
|
|
|
{ SPA_AUDIO_FORMAT_S32P, SPA_AUDIO_FORMAT_F32, 0, conv_s32d_to_f32 },
|
|
|
|
|
|
|
|
|
|
{ SPA_AUDIO_FORMAT_S24, SPA_AUDIO_FORMAT_F32, 0, conv_s24_to_f32 },
|
2019-01-24 18:28:52 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_S24P, SPA_AUDIO_FORMAT_F32P, 0, conv_s24d_to_f32d },
|
2018-12-20 16:11:25 +01:00
|
|
|
#if defined (__SSE2__)
|
|
|
|
|
{ SPA_AUDIO_FORMAT_S24, SPA_AUDIO_FORMAT_F32P, FEATURE_SSE2, conv_s24_to_f32d_sse2 },
|
2018-11-08 09:56:58 +01:00
|
|
|
#endif
|
2018-09-13 17:03:56 +02:00
|
|
|
{ SPA_AUDIO_FORMAT_S24, SPA_AUDIO_FORMAT_F32P, 0, conv_s24_to_f32d },
|
|
|
|
|
{ SPA_AUDIO_FORMAT_S24P, SPA_AUDIO_FORMAT_F32, 0, conv_s24d_to_f32 },
|
|
|
|
|
|
|
|
|
|
{ SPA_AUDIO_FORMAT_S24_32, SPA_AUDIO_FORMAT_F32, 0, conv_s24_32_to_f32 },
|
2019-01-24 18:28:52 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_S24_32P, SPA_AUDIO_FORMAT_F32P, 0, conv_s24_32d_to_f32d },
|
2018-09-13 17:03:56 +02:00
|
|
|
{ SPA_AUDIO_FORMAT_S24_32, SPA_AUDIO_FORMAT_F32P, 0, conv_s24_32_to_f32d },
|
|
|
|
|
{ SPA_AUDIO_FORMAT_S24_32P, SPA_AUDIO_FORMAT_F32, 0, conv_s24_32d_to_f32 },
|
2018-04-06 18:39:07 +02:00
|
|
|
|
|
|
|
|
/* from f32 */
|
2018-09-13 17:03:56 +02:00
|
|
|
{ SPA_AUDIO_FORMAT_F32, SPA_AUDIO_FORMAT_U8, 0, conv_f32_to_u8 },
|
2019-01-24 18:28:52 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_U8P, 0, conv_f32d_to_u8d },
|
2018-09-13 17:03:56 +02:00
|
|
|
{ SPA_AUDIO_FORMAT_F32, SPA_AUDIO_FORMAT_U8P, 0, conv_f32_to_u8d },
|
|
|
|
|
{ SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_U8, 0, conv_f32d_to_u8 },
|
|
|
|
|
|
|
|
|
|
{ SPA_AUDIO_FORMAT_F32, SPA_AUDIO_FORMAT_S16, 0, conv_f32_to_s16 },
|
2019-01-24 18:28:52 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_S16P, 0, conv_f32d_to_s16d },
|
2018-09-13 17:03:56 +02:00
|
|
|
{ SPA_AUDIO_FORMAT_F32, SPA_AUDIO_FORMAT_S16P, 0, conv_f32_to_s16d },
|
2018-12-20 16:11:25 +01:00
|
|
|
#if defined (__SSE2__)
|
|
|
|
|
{ SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_S16, FEATURE_SSE2, conv_f32d_to_s16_sse2 },
|
2018-10-29 09:21:33 +00:00
|
|
|
#endif
|
2018-09-13 17:03:56 +02:00
|
|
|
{ SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_S16, 0, conv_f32d_to_s16 },
|
|
|
|
|
|
|
|
|
|
{ SPA_AUDIO_FORMAT_F32, SPA_AUDIO_FORMAT_S32, 0, conv_f32_to_s32 },
|
2019-01-24 18:28:52 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_S32P, 0, conv_f32d_to_s32d },
|
2018-09-13 17:03:56 +02:00
|
|
|
{ SPA_AUDIO_FORMAT_F32, SPA_AUDIO_FORMAT_S32P, 0, conv_f32_to_s32d },
|
2018-12-20 16:11:25 +01:00
|
|
|
#if defined (__SSE2__)
|
|
|
|
|
{ SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_S32, FEATURE_SSE2, conv_f32d_to_s32_sse2 },
|
2018-07-31 12:23:35 +02:00
|
|
|
#endif
|
2018-09-13 17:03:56 +02:00
|
|
|
{ SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_S32, 0, conv_f32d_to_s32 },
|
|
|
|
|
|
|
|
|
|
{ SPA_AUDIO_FORMAT_F32, SPA_AUDIO_FORMAT_S24, 0, conv_f32_to_s24 },
|
2019-01-24 18:28:52 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_S24P, 0, conv_f32d_to_s24d },
|
2018-09-13 17:03:56 +02:00
|
|
|
{ SPA_AUDIO_FORMAT_F32, SPA_AUDIO_FORMAT_S24P, 0, conv_f32_to_s24d },
|
|
|
|
|
{ SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_S24, 0, conv_f32d_to_s24 },
|
|
|
|
|
|
|
|
|
|
{ SPA_AUDIO_FORMAT_F32, SPA_AUDIO_FORMAT_S24_32, 0, conv_f32_to_s24_32 },
|
2019-01-24 18:28:52 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_S24_32P, 0, conv_f32d_to_s24_32d },
|
2018-09-13 17:03:56 +02:00
|
|
|
{ SPA_AUDIO_FORMAT_F32, SPA_AUDIO_FORMAT_S24_32P, 0, conv_f32_to_s24_32d },
|
|
|
|
|
{ SPA_AUDIO_FORMAT_F32P, SPA_AUDIO_FORMAT_S24_32, 0, conv_f32d_to_s24_32 },
|
2018-04-06 18:39:07 +02:00
|
|
|
|
|
|
|
|
/* u8 */
|
2018-12-13 12:02:47 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_U8, SPA_AUDIO_FORMAT_U8, 0, conv_copy8 },
|
2019-01-24 18:28:52 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_U8P, SPA_AUDIO_FORMAT_U8P, 0, conv_copy8d },
|
2018-09-13 17:03:56 +02:00
|
|
|
{ SPA_AUDIO_FORMAT_U8, SPA_AUDIO_FORMAT_U8P, 0, deinterleave_8 },
|
|
|
|
|
{ SPA_AUDIO_FORMAT_U8P, SPA_AUDIO_FORMAT_U8, 0, interleave_8 },
|
2018-04-06 18:39:07 +02:00
|
|
|
|
|
|
|
|
/* s16 */
|
2018-12-13 12:02:47 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_S16, 0, conv_copy16 },
|
2019-01-24 18:28:52 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_S16P, SPA_AUDIO_FORMAT_S16P, 0, conv_copy16d },
|
2018-09-13 17:03:56 +02:00
|
|
|
{ SPA_AUDIO_FORMAT_S16, SPA_AUDIO_FORMAT_S16P, 0, deinterleave_16 },
|
|
|
|
|
{ SPA_AUDIO_FORMAT_S16P, SPA_AUDIO_FORMAT_S16, 0, interleave_16 },
|
2018-04-06 18:39:07 +02:00
|
|
|
|
|
|
|
|
/* s32 */
|
2018-12-13 12:02:47 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_S32, SPA_AUDIO_FORMAT_S32, 0, conv_copy32 },
|
2019-01-24 18:28:52 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_S32P, SPA_AUDIO_FORMAT_S32P, 0, conv_copy32d },
|
2018-09-13 17:03:56 +02:00
|
|
|
{ SPA_AUDIO_FORMAT_S32, SPA_AUDIO_FORMAT_S32P, 0, deinterleave_32 },
|
|
|
|
|
{ SPA_AUDIO_FORMAT_S32P, SPA_AUDIO_FORMAT_S32, 0, interleave_32 },
|
2018-04-06 18:39:07 +02:00
|
|
|
|
|
|
|
|
/* s24 */
|
2018-12-13 12:02:47 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_S24, SPA_AUDIO_FORMAT_S24, 0, conv_copy24 },
|
2019-01-24 18:28:52 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_S24P, SPA_AUDIO_FORMAT_S24P, 0, conv_copy24d },
|
2018-09-13 17:03:56 +02:00
|
|
|
{ SPA_AUDIO_FORMAT_S24, SPA_AUDIO_FORMAT_S24P, 0, deinterleave_24 },
|
|
|
|
|
{ SPA_AUDIO_FORMAT_S24P, SPA_AUDIO_FORMAT_S24, 0, interleave_24 },
|
2018-04-06 18:39:07 +02:00
|
|
|
|
|
|
|
|
/* s24_32 */
|
2018-12-13 12:02:47 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_S24_32, SPA_AUDIO_FORMAT_S24_32, 0, conv_copy32 },
|
2019-01-24 18:28:52 +01:00
|
|
|
{ SPA_AUDIO_FORMAT_S24_32P, SPA_AUDIO_FORMAT_S24_32P, 0, conv_copy32d },
|
2018-09-13 17:03:56 +02:00
|
|
|
{ SPA_AUDIO_FORMAT_S24_32, SPA_AUDIO_FORMAT_S24_32P, 0, deinterleave_32 },
|
|
|
|
|
{ SPA_AUDIO_FORMAT_S24_32P, SPA_AUDIO_FORMAT_S24_32, 0, interleave_32 },
|
2018-04-06 18:39:07 +02:00
|
|
|
};
|
|
|
|
|
|
2018-08-23 17:47:57 +02:00
|
|
|
static const struct conv_info *find_conv_info(uint32_t src_fmt, uint32_t dst_fmt, uint32_t features)
|
2018-04-06 18:39:07 +02:00
|
|
|
{
|
2019-01-07 15:52:42 +01:00
|
|
|
size_t i;
|
2018-04-06 18:39:07 +02:00
|
|
|
|
|
|
|
|
for (i = 0; i < SPA_N_ELEMENTS(conv_table); i++) {
|
2018-08-23 17:47:57 +02:00
|
|
|
if (conv_table[i].src_fmt == src_fmt &&
|
|
|
|
|
conv_table[i].dst_fmt == dst_fmt &&
|
2018-07-31 12:23:35 +02:00
|
|
|
(conv_table[i].features == 0 || (conv_table[i].features & features) != 0))
|
2018-04-06 18:39:07 +02:00
|
|
|
return &conv_table[i];
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|