channelmix: don't pass channels around

We have this info in the channelmix structure.
This commit is contained in:
Wim Taymans 2022-02-24 09:13:57 +01:00
parent 76aaae2034
commit b1ca470d99
5 changed files with 69 additions and 71 deletions

View file

@ -25,10 +25,10 @@
#include "channelmix-ops.h" #include "channelmix-ops.h"
void void
channelmix_copy_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], channelmix_copy_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples) const void * SPA_RESTRICT src[], uint32_t n_samples)
{ {
uint32_t i, n; uint32_t i, n, n_dst = mix->dst_chan;
float **d = (float **)dst; float **d = (float **)dst;
const float **s = (const float **)src; const float **s = (const float **)src;
@ -51,10 +51,10 @@ channelmix_copy_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT ds
#define _M(ch) (1UL << SPA_AUDIO_CHANNEL_ ## ch) #define _M(ch) (1UL << SPA_AUDIO_CHANNEL_ ## ch)
void void
channelmix_f32_n_m_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], channelmix_f32_n_m_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples) const void * SPA_RESTRICT src[], uint32_t n_samples)
{ {
uint32_t i, j, n; uint32_t i, j, n, n_dst = mix->dst_chan, n_src = mix->src_chan;
float **d = (float **) dst; float **d = (float **) dst;
const float **s = (const float **) src; const float **s = (const float **) src;
@ -89,8 +89,8 @@ channelmix_f32_n_m_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT
#define MASK_STEREO _M(FL)|_M(FR)|_M(UNKNOWN) #define MASK_STEREO _M(FL)|_M(FR)|_M(UNKNOWN)
void void
channelmix_f32_1_2_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], channelmix_f32_1_2_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples) const void * SPA_RESTRICT src[], uint32_t n_samples)
{ {
uint32_t n; uint32_t n;
float **d = (float **)dst; float **d = (float **)dst;
@ -118,8 +118,8 @@ channelmix_f32_1_2_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT
} }
void void
channelmix_f32_2_1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], channelmix_f32_2_1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples) const void * SPA_RESTRICT src[], uint32_t n_samples)
{ {
uint32_t n; uint32_t n;
float **d = (float **)dst; float **d = (float **)dst;
@ -140,8 +140,8 @@ channelmix_f32_2_1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT
} }
void void
channelmix_f32_4_1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], channelmix_f32_4_1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples) const void * SPA_RESTRICT src[], uint32_t n_samples)
{ {
uint32_t n; uint32_t n;
float **d = (float **)dst; float **d = (float **)dst;
@ -166,8 +166,8 @@ channelmix_f32_4_1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT
} }
void void
channelmix_f32_3p1_1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], channelmix_f32_3p1_1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples) const void * SPA_RESTRICT src[], uint32_t n_samples)
{ {
uint32_t n; uint32_t n;
float **d = (float **)dst; float **d = (float **)dst;
@ -193,10 +193,10 @@ channelmix_f32_3p1_1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRI
#define MASK_QUAD _M(FL)|_M(FR)|_M(RL)|_M(RR)|_M(UNKNOWN) #define MASK_QUAD _M(FL)|_M(FR)|_M(RL)|_M(RR)|_M(UNKNOWN)
void void
channelmix_f32_2_4_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], channelmix_f32_2_4_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples) const void * SPA_RESTRICT src[], uint32_t n_samples)
{ {
uint32_t i, n; uint32_t i, n, n_dst = mix->dst_chan;
float **d = (float **)dst; float **d = (float **)dst;
const float **s = (const float **)src; const float **s = (const float **)src;
const float v0 = mix->matrix[0][0]; const float v0 = mix->matrix[0][0];
@ -233,10 +233,10 @@ channelmix_f32_2_4_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT
#define MASK_3_1 _M(FL)|_M(FR)|_M(FC)|_M(LFE) #define MASK_3_1 _M(FL)|_M(FR)|_M(FC)|_M(LFE)
void void
channelmix_f32_2_3p1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], channelmix_f32_2_3p1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples) const void * SPA_RESTRICT src[], uint32_t n_samples)
{ {
uint32_t i, n; uint32_t i, n, n_dst = mix->dst_chan;
float **d = (float **)dst; float **d = (float **)dst;
const float **s = (const float **)src; const float **s = (const float **)src;
const float v0 = mix->matrix[0][0]; const float v0 = mix->matrix[0][0];
@ -274,10 +274,10 @@ channelmix_f32_2_3p1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRI
#define MASK_5_1 _M(FL)|_M(FR)|_M(FC)|_M(LFE)|_M(SL)|_M(SR)|_M(RL)|_M(RR) #define MASK_5_1 _M(FL)|_M(FR)|_M(FC)|_M(LFE)|_M(SL)|_M(SR)|_M(RL)|_M(RR)
void void
channelmix_f32_2_5p1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], channelmix_f32_2_5p1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples) const void * SPA_RESTRICT src[], uint32_t n_samples)
{ {
uint32_t i, n; uint32_t i, n, n_dst = mix->dst_chan;
float **d = (float **)dst; float **d = (float **)dst;
const float **s = (const float **)src; const float **s = (const float **)src;
const float v0 = mix->matrix[0][0]; const float v0 = mix->matrix[0][0];
@ -319,8 +319,8 @@ channelmix_f32_2_5p1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRI
/* FL+FR+FC+LFE+SL+SR -> FL+FR */ /* FL+FR+FC+LFE+SL+SR -> FL+FR */
void void
channelmix_f32_5p1_2_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], channelmix_f32_5p1_2_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples) const void * SPA_RESTRICT src[], uint32_t n_samples)
{ {
uint32_t n; uint32_t n;
float **d = (float **) dst; float **d = (float **) dst;
@ -347,10 +347,10 @@ channelmix_f32_5p1_2_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRI
/* FL+FR+FC+LFE+SL+SR -> FL+FR+FC+LFE*/ /* FL+FR+FC+LFE+SL+SR -> FL+FR+FC+LFE*/
void void
channelmix_f32_5p1_3p1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], channelmix_f32_5p1_3p1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples) const void * SPA_RESTRICT src[], uint32_t n_samples)
{ {
uint32_t i, n; uint32_t i, n, n_dst = mix->dst_chan;
float **d = (float **) dst; float **d = (float **) dst;
const float **s = (const float **) src; const float **s = (const float **) src;
const float v0 = mix->matrix[0][0]; const float v0 = mix->matrix[0][0];
@ -376,10 +376,10 @@ channelmix_f32_5p1_3p1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_REST
/* FL+FR+FC+LFE+SL+SR -> FL+FR+RL+RR*/ /* FL+FR+FC+LFE+SL+SR -> FL+FR+RL+RR*/
void void
channelmix_f32_5p1_4_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], channelmix_f32_5p1_4_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples) const void * SPA_RESTRICT src[], uint32_t n_samples)
{ {
uint32_t i, n; uint32_t i, n, n_dst = mix->dst_chan;
float **d = (float **) dst; float **d = (float **) dst;
const float **s = (const float **) src; const float **s = (const float **) src;
const float clev = mix->matrix[0][2]; const float clev = mix->matrix[0][2];
@ -408,8 +408,8 @@ channelmix_f32_5p1_4_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRI
/* FL+FR+FC+LFE+SL+SR+RL+RR -> FL+FR */ /* FL+FR+FC+LFE+SL+SR+RL+RR -> FL+FR */
void void
channelmix_f32_7p1_2_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], channelmix_f32_7p1_2_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples) const void * SPA_RESTRICT src[], uint32_t n_samples)
{ {
uint32_t n; uint32_t n;
float **d = (float **) dst; float **d = (float **) dst;
@ -438,10 +438,10 @@ channelmix_f32_7p1_2_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRI
/* FL+FR+FC+LFE+SL+SR+RL+RR -> FL+FR+FC+LFE*/ /* FL+FR+FC+LFE+SL+SR+RL+RR -> FL+FR+FC+LFE*/
void void
channelmix_f32_7p1_3p1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], channelmix_f32_7p1_3p1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples) const void * SPA_RESTRICT src[], uint32_t n_samples)
{ {
uint32_t i, n; uint32_t i, n, n_dst = mix->dst_chan;
float **d = (float **) dst; float **d = (float **) dst;
const float **s = (const float **) src; const float **s = (const float **) src;
const float v0 = mix->matrix[0][0]; const float v0 = mix->matrix[0][0];
@ -467,10 +467,10 @@ channelmix_f32_7p1_3p1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_REST
/* FL+FR+FC+LFE+SL+SR+RL+RR -> FL+FR+RL+RR*/ /* FL+FR+FC+LFE+SL+SR+RL+RR -> FL+FR+RL+RR*/
void void
channelmix_f32_7p1_4_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], channelmix_f32_7p1_4_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples) const void * SPA_RESTRICT src[], uint32_t n_samples)
{ {
uint32_t i, n; uint32_t i, n, n_dst = mix->dst_chan;
float **d = (float **) dst; float **d = (float **) dst;
const float **s = (const float **) src; const float **s = (const float **) src;
const float v0 = mix->matrix[0][0]; const float v0 = mix->matrix[0][0];

View file

@ -26,10 +26,10 @@
#include <xmmintrin.h> #include <xmmintrin.h>
void channelmix_copy_sse(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], void channelmix_copy_sse(struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples) const void * SPA_RESTRICT src[], uint32_t n_samples)
{ {
uint32_t i, n, unrolled; uint32_t i, n, unrolled, n_dst = mix->dst_chan;
float **d = (float **)dst; float **d = (float **)dst;
const float **s = (const float **)src; const float **s = (const float **)src;
@ -71,10 +71,10 @@ void channelmix_copy_sse(struct channelmix *mix, uint32_t n_dst, void * SPA_REST
} }
void void
channelmix_f32_2_4_sse(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], channelmix_f32_2_4_sse(struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples) const void * SPA_RESTRICT src[], uint32_t n_samples)
{ {
uint32_t i, n, unrolled; uint32_t i, n, unrolled, n_dst = mix->dst_chan;
float **d = (float **)dst; float **d = (float **)dst;
const float **s = (const float **)src; const float **s = (const float **)src;
const float m00 = mix->matrix[0][0]; const float m00 = mix->matrix[0][0];
@ -139,8 +139,8 @@ channelmix_f32_2_4_sse(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRI
/* FL+FR+FC+LFE+SL+SR -> FL+FR */ /* FL+FR+FC+LFE+SL+SR -> FL+FR */
void void
channelmix_f32_5p1_2_sse(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], channelmix_f32_5p1_2_sse(struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples) const void * SPA_RESTRICT src[], uint32_t n_samples)
{ {
uint32_t n, unrolled; uint32_t n, unrolled;
float **d = (float **) dst; float **d = (float **) dst;
@ -229,10 +229,10 @@ channelmix_f32_5p1_2_sse(struct channelmix *mix, uint32_t n_dst, void * SPA_REST
/* FL+FR+FC+LFE+SL+SR -> FL+FR+FC+LFE*/ /* FL+FR+FC+LFE+SL+SR -> FL+FR+FC+LFE*/
void void
channelmix_f32_5p1_3p1_sse(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], channelmix_f32_5p1_3p1_sse(struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples) const void * SPA_RESTRICT src[], uint32_t n_samples)
{ {
uint32_t i, n, unrolled; uint32_t i, n, unrolled, n_dst = mix->dst_chan;
float **d = (float **) dst; float **d = (float **) dst;
const float **s = (const float **) src; const float **s = (const float **) src;
const __m128 v0 = _mm_set1_ps(mix->matrix[0][0]); const __m128 v0 = _mm_set1_ps(mix->matrix[0][0]);
@ -307,10 +307,10 @@ channelmix_f32_5p1_3p1_sse(struct channelmix *mix, uint32_t n_dst, void * SPA_RE
/* FL+FR+FC+LFE+SL+SR -> FL+FR+RL+RR*/ /* FL+FR+FC+LFE+SL+SR -> FL+FR+RL+RR*/
void void
channelmix_f32_5p1_4_sse(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], channelmix_f32_5p1_4_sse(struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples) const void * SPA_RESTRICT src[], uint32_t n_samples)
{ {
uint32_t i, n, unrolled; uint32_t i, n, unrolled, n_dst = mix->dst_chan;
float **d = (float **) dst; float **d = (float **) dst;
const float **s = (const float **) src; const float **s = (const float **) src;
const __m128 clev = _mm_set1_ps(mix->matrix[0][2]); const __m128 clev = _mm_set1_ps(mix->matrix[0][2]);

View file

@ -51,8 +51,8 @@ struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.channelmix");
#define ANY ((uint32_t)-1) #define ANY ((uint32_t)-1)
#define EQ ((uint32_t)-2) #define EQ ((uint32_t)-2)
typedef void (*channelmix_func_t) (struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], typedef void (*channelmix_func_t) (struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples); const void * SPA_RESTRICT src[], uint32_t n_samples);
static const struct channelmix_info { static const struct channelmix_info {
uint32_t src_chan; uint32_t src_chan;

View file

@ -72,8 +72,8 @@ struct channelmix {
uint32_t lr4_info[SPA_AUDIO_MAX_CHANNELS]; uint32_t lr4_info[SPA_AUDIO_MAX_CHANNELS];
struct lr4 lr4[SPA_AUDIO_MAX_CHANNELS]; struct lr4 lr4[SPA_AUDIO_MAX_CHANNELS];
void (*process) (struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], void (*process) (struct channelmix *mix, void * SPA_RESTRICT dst[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src], uint32_t n_samples); const void * SPA_RESTRICT src[], uint32_t n_samples);
void (*set_volume) (struct channelmix *mix, float volume, bool mute, void (*set_volume) (struct channelmix *mix, float volume, bool mute,
uint32_t n_channel_volumes, float *channel_volumes); uint32_t n_channel_volumes, float *channel_volumes);
void (*free) (struct channelmix *mix); void (*free) (struct channelmix *mix);
@ -87,10 +87,9 @@ int channelmix_init(struct channelmix *mix);
#define channelmix_set_volume(mix,...) (mix)->set_volume(mix, __VA_ARGS__) #define channelmix_set_volume(mix,...) (mix)->set_volume(mix, __VA_ARGS__)
#define channelmix_free(mix) (mix)->free(mix) #define channelmix_free(mix) (mix)->free(mix)
#define DEFINE_FUNCTION(name,arch) \ #define DEFINE_FUNCTION(name,arch) \
void channelmix_##name##_##arch(struct channelmix *mix, \ void channelmix_##name##_##arch(struct channelmix *mix, \
uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], \ void * SPA_RESTRICT dst[], const void * SPA_RESTRICT src[], \
uint32_t n_src, const void * SPA_RESTRICT src[n_src], \
uint32_t n_samples); uint32_t n_samples);
#define CHANNELMIX_OPS_MAX_ALIGN 16 #define CHANNELMIX_OPS_MAX_ALIGN 16

View file

@ -1293,8 +1293,7 @@ static int impl_node_port_reuse_buffer(void *object, uint32_t port_id, uint32_t
} }
static int channelmix_process_control(struct impl *this, struct port *ctrlport, static int channelmix_process_control(struct impl *this, struct port *ctrlport,
uint32_t n_dst, void * SPA_RESTRICT dst[n_dst], void * SPA_RESTRICT dst[], const void * SPA_RESTRICT src[],
uint32_t n_src, const void * SPA_RESTRICT src[n_src],
uint32_t n_samples) uint32_t n_samples)
{ {
struct spa_pod_control *c, *prev = NULL; struct spa_pod_control *c, *prev = NULL;
@ -1337,10 +1336,10 @@ static int channelmix_process_control(struct impl *this, struct port *ctrlport,
spa_log_trace_fp(this->log, "%p: process %d %d", this, spa_log_trace_fp(this->log, "%p: process %d %d", this,
c->offset, chunk); c->offset, chunk);
channelmix_process(&this->mix, n_dst, dst, n_src, src, chunk); channelmix_process(&this->mix, dst, src, chunk);
for (i = 0; i < n_src; i++) for (i = 0; i < this->mix.src_chan; i++)
s[i] += chunk; s[i] += chunk;
for (i = 0; i < n_dst; i++) for (i = 0; i < this->mix.dst_chan; i++)
d[i] += chunk; d[i] += chunk;
avail_samples -= chunk; avail_samples -= chunk;
@ -1353,7 +1352,7 @@ static int channelmix_process_control(struct impl *this, struct port *ctrlport,
* remaining samples */ * remaining samples */
spa_log_trace_fp(this->log, "%p: remain %d", this, avail_samples); spa_log_trace_fp(this->log, "%p: remain %d", this, avail_samples);
if (avail_samples > 0) if (avail_samples > 0)
channelmix_process(&this->mix, n_dst, dst, n_src, src, avail_samples); channelmix_process(&this->mix, dst, src, avail_samples);
return 1; return 1;
} }
@ -1445,14 +1444,14 @@ static int impl_node_process(void *object)
if (!is_passthrough) { if (!is_passthrough) {
if (ctrlport->ctrl != NULL) { if (ctrlport->ctrl != NULL) {
/* if return value is 1, the sequence has been processed */ /* if return value is 1, the sequence has been processed */
if (channelmix_process_control(this, ctrlport, n_dst_datas, dst_datas, if (channelmix_process_control(this, ctrlport, dst_datas,
n_src_datas, src_datas, n_samples) == 1) { src_datas, n_samples) == 1) {
ctrlio->status = SPA_STATUS_OK; ctrlio->status = SPA_STATUS_OK;
ctrlport->ctrl = NULL; ctrlport->ctrl = NULL;
} }
} else { } else {
channelmix_process(&this->mix, n_dst_datas, dst_datas, channelmix_process(&this->mix, dst_datas,
n_src_datas, src_datas, n_samples); src_datas, n_samples);
} }
} }
} }