audioconvert: pass state to functions

Pass some state to convert and channelmix functions. This makes it
possible to select per channel optimized convert functions but
also makes it possible to implement noise shaping later.
Pass the channelmix matrix and volume in the state.
Handle specialized 2 channel s16 -> f32 conversion
This commit is contained in:
Wim Taymans 2019-03-29 17:39:59 +01:00
parent d47353c0e6
commit d8e399dee9
17 changed files with 952 additions and 685 deletions

View file

@ -25,13 +25,13 @@
#include "channelmix-ops.h"
void
channelmix_copy_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
int n_src, const void * SPA_RESTRICT src[n_src],
const void *matrix, float v, int n_samples)
channelmix_copy_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples)
{
int i, n;
uint32_t i, n;
float **d = (float **)dst;
const float **s = (const float **)src;
float v = mix->volume;
if (v <= VOLUME_MIN) {
for (i = 0; i < n_dst; i++)
@ -51,14 +51,14 @@ channelmix_copy_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
#define _M(ch) (1UL << SPA_AUDIO_CHANNEL_ ## ch)
void
channelmix_f32_n_m_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
int n_src, const void * SPA_RESTRICT src[n_src],
const void *matrix, float v, int n_samples)
channelmix_f32_n_m_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples)
{
int i, j, n;
uint32_t i, j, n;
float **d = (float **) dst;
const float **s = (const float **) src;
const float *m = matrix;
const float *m = mix->matrix;
float v = mix->volume;
for (n = 0; n < n_samples; n++) {
for (i = 0; i < n_dst; i++) {
@ -74,13 +74,13 @@ channelmix_f32_n_m_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
#define MASK_STEREO _M(FL)|_M(FR)|_M(UNKNOWN)
void
channelmix_f32_1_2_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
int n_src, const void * SPA_RESTRICT src[n_src],
const void *matrix, float v, int n_samples)
channelmix_f32_1_2_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples)
{
int n;
uint32_t n;
float **d = (float **)dst;
const float **s = (const float **)src;
float v = mix->volume;
if (v <= VOLUME_MIN) {
memset(d[0], 0, n_samples * sizeof(float));
@ -97,13 +97,13 @@ channelmix_f32_1_2_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
}
void
channelmix_f32_2_1_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
int n_src, const void * SPA_RESTRICT src[n_src],
const void *matrix, float v, int n_samples)
channelmix_f32_2_1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples)
{
int n;
uint32_t n;
float **d = (float **)dst;
const float **s = (const float **)src;
float v = mix->volume;
if (v <= VOLUME_MIN) {
memset(d[0], 0, n_samples * sizeof(float));
@ -116,13 +116,13 @@ channelmix_f32_2_1_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
}
void
channelmix_f32_4_1_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
int n_src, const void * SPA_RESTRICT src[n_src],
const void *matrix, float v, int n_samples)
channelmix_f32_4_1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples)
{
int n;
uint32_t n;
float **d = (float **)dst;
const float **s = (const float **)src;
float v = mix->volume;
if (v <= VOLUME_MIN) {
memset(d[0], 0, n_samples * sizeof(float));
@ -135,13 +135,13 @@ channelmix_f32_4_1_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
}
void
channelmix_f32_3p1_1_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
int n_src, const void * SPA_RESTRICT src[n_src],
const void *matrix, float v, int n_samples)
channelmix_f32_3p1_1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples)
{
int n;
uint32_t n;
float **d = (float **)dst;
const float **s = (const float **)src;
float v = mix->volume;
if (v <= VOLUME_MIN) {
memset(d[0], 0, n_samples * sizeof(float));
@ -157,13 +157,13 @@ channelmix_f32_3p1_1_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
#define MASK_QUAD _M(FL)|_M(FR)|_M(RL)|_M(RR)|_M(UNKNOWN)
void
channelmix_f32_2_4_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
int n_src, const void * SPA_RESTRICT src[n_src],
const void *matrix, float v, int n_samples)
channelmix_f32_2_4_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples)
{
int i, n;
uint32_t i, n;
float **d = (float **)dst;
const float **s = (const float **)src;
float v = mix->volume;
if (v <= VOLUME_MIN) {
for (i = 0; i < n_dst; i++)
@ -185,13 +185,13 @@ channelmix_f32_2_4_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
#define MASK_3_1 _M(FL)|_M(FR)|_M(FC)|_M(LFE)
void
channelmix_f32_2_3p1_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
int n_src, const void * SPA_RESTRICT src[n_src],
const void *matrix, float v, int n_samples)
channelmix_f32_2_3p1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples)
{
int i, n;
uint32_t i, n;
float **d = (float **)dst;
const float **s = (const float **)src;
float v = mix->volume;
if (v <= VOLUME_MIN) {
for (i = 0; i < n_dst; i++)
@ -218,13 +218,13 @@ channelmix_f32_2_3p1_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
#define MASK_5_1 _M(FL)|_M(FR)|_M(FC)|_M(LFE)|_M(SL)|_M(SR)|_M(RL)|_M(RR)
void
channelmix_f32_2_5p1_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
int n_src, const void * SPA_RESTRICT src[n_src],
const void *matrix, float v, int n_samples)
channelmix_f32_2_5p1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples)
{
int i, n;
uint32_t i, n;
float **d = (float **)dst;
const float **s = (const float **)src;
float v = mix->volume;
if (v <= VOLUME_MIN) {
for (i = 0; i < n_dst; i++)
@ -251,17 +251,17 @@ channelmix_f32_2_5p1_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
/* FL+FR+FC+LFE+SL+SR -> FL+FR */
void
channelmix_f32_5p1_2_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
int n_src, const void * SPA_RESTRICT src[n_src],
const void *matrix, float v, int n_samples)
channelmix_f32_5p1_2_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples)
{
int n;
uint32_t n;
float **d = (float **) dst;
const float **s = (const float **) src;
const float *m = matrix;
const float *m = mix->matrix;
const float clev = m[2];
const float llev = m[3];
const float slev = m[4];
float v = mix->volume;
if (v <= VOLUME_MIN) {
memset(d[0], 0, n_samples * sizeof(float));
@ -285,13 +285,13 @@ channelmix_f32_5p1_2_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
/* FL+FR+FC+LFE+SL+SR -> FL+FR+FC+LFE*/
void
channelmix_f32_5p1_3p1_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
int n_src, const void * SPA_RESTRICT src[n_src],
const void *matrix, float v, int n_samples)
channelmix_f32_5p1_3p1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples)
{
int i, n;
uint32_t i, n;
float **d = (float **) dst;
const float **s = (const float **) src;
float v = mix->volume;
if (v <= VOLUME_MIN) {
for (i = 0; i < n_dst; i++)
@ -310,16 +310,16 @@ channelmix_f32_5p1_3p1_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
/* FL+FR+FC+LFE+SL+SR -> FL+FR+RL+RR*/
void
channelmix_f32_5p1_4_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
int n_src, const void * SPA_RESTRICT src[n_src],
const void *matrix, float v, int n_samples)
channelmix_f32_5p1_4_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples)
{
int i, n;
uint32_t i, n;
float **d = (float **) dst;
const float **s = (const float **) src;
const float *m = matrix;
const float *m = mix->matrix;
const float clev = m[2];
const float llev = m[3];
float v = mix->volume;
if (v <= VOLUME_MIN) {
for (i = 0; i < n_dst; i++)
@ -349,17 +349,17 @@ channelmix_f32_5p1_4_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
/* FL+FR+FC+LFE+SL+SR+RL+RR -> FL+FR */
void
channelmix_f32_7p1_2_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
int n_src, const void * SPA_RESTRICT src[n_src],
const void *matrix, float v, int n_samples)
channelmix_f32_7p1_2_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples)
{
int n;
uint32_t n;
float **d = (float **) dst;
const float **s = (const float **) src;
const float *m = matrix;
const float *m = mix->matrix;
const float clev = m[2];
const float llev = m[3];
const float slev = m[4];
float v = mix->volume;
if (v <= VOLUME_MIN) {
memset(d[0], 0, n_samples * sizeof(float));
@ -383,13 +383,13 @@ channelmix_f32_7p1_2_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
/* FL+FR+FC+LFE+SL+SR+RL+RR -> FL+FR+FC+LFE*/
void
channelmix_f32_7p1_3p1_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
int n_src, const void * SPA_RESTRICT src[n_src],
const void *matrix, float v, int n_samples)
channelmix_f32_7p1_3p1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples)
{
int i, n;
uint32_t i, n;
float **d = (float **) dst;
const float **s = (const float **) src;
float v = mix->volume;
if (v <= VOLUME_MIN) {
for (i = 0; i < n_dst; i++)
@ -408,17 +408,17 @@ channelmix_f32_7p1_3p1_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
/* FL+FR+FC+LFE+SL+SR+RL+RR -> FL+FR+RL+RR*/
void
channelmix_f32_7p1_4_c(void *data, int n_dst, void * SPA_RESTRICT dst[n_dst],
int n_src, const void * SPA_RESTRICT src[n_src],
const void *matrix, float v, int n_samples)
channelmix_f32_7p1_4_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples)
{
int i, n;
uint32_t i, n;
float **d = (float **) dst;
const float **s = (const float **) src;
const float *m = matrix;
const float *m = mix->matrix;
const float clev = m[2];
const float llev = m[3];
const float slev = m[4];
float v = mix->volume;
if (v <= VOLUME_MIN) {
for (i = 0; i < n_dst; i++)