mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
audioconvert: use cpu detection interface
This commit is contained in:
parent
e984c19f6c
commit
4dfe1011a6
6 changed files with 65 additions and 20 deletions
|
|
@ -25,6 +25,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <spa/support/cpu.h>
|
||||||
#include <spa/utils/defs.h>
|
#include <spa/utils/defs.h>
|
||||||
|
|
||||||
#define VOLUME_MIN 0.0f
|
#define VOLUME_MIN 0.0f
|
||||||
|
|
@ -423,8 +424,7 @@ static const struct channelmix_info {
|
||||||
uint64_t dst_mask;
|
uint64_t dst_mask;
|
||||||
|
|
||||||
channelmix_func_t func;
|
channelmix_func_t func;
|
||||||
#define FEATURE_SSE (1<<0)
|
#define FEATURE_SSE SPA_CPU_FLAG_SSE
|
||||||
#define FEATURE_DEFAULT FEATURE_SSE
|
|
||||||
uint32_t features;
|
uint32_t features;
|
||||||
} channelmix_table[] =
|
} channelmix_table[] =
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@ struct impl {
|
||||||
struct spa_node node;
|
struct spa_node node;
|
||||||
|
|
||||||
struct spa_log *log;
|
struct spa_log *log;
|
||||||
|
struct spa_cpu *cpu;
|
||||||
|
|
||||||
struct props props;
|
struct props props;
|
||||||
|
|
||||||
|
|
@ -105,6 +106,7 @@ struct impl {
|
||||||
|
|
||||||
bool started;
|
bool started;
|
||||||
|
|
||||||
|
uint32_t cpu_flags;
|
||||||
channelmix_func_t convert;
|
channelmix_func_t convert;
|
||||||
uint32_t n_matrix;
|
uint32_t n_matrix;
|
||||||
float matrix[4096];
|
float matrix[4096];
|
||||||
|
|
@ -430,10 +432,12 @@ static int setup_convert(struct impl *this,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* find convert function */
|
/* find convert function */
|
||||||
if ((chanmix_info = find_channelmix_info(src_chan, src_mask, dst_chan, dst_mask, FEATURE_DEFAULT)) == NULL)
|
if ((chanmix_info = find_channelmix_info(src_chan, src_mask,
|
||||||
|
dst_chan, dst_mask, this->cpu_flags)) == NULL)
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
|
|
||||||
spa_log_info(this->log, NAME " %p: got channelmix features %08x", this, chanmix_info->features);
|
spa_log_info(this->log, NAME " %p: got channelmix features %08x:%08x",
|
||||||
|
this, this->cpu_flags, chanmix_info->features);
|
||||||
|
|
||||||
this->convert = chanmix_info->func;
|
this->convert = chanmix_info->func;
|
||||||
|
|
||||||
|
|
@ -1255,9 +1259,18 @@ impl_init(const struct spa_handle_factory *factory,
|
||||||
this = (struct impl *) handle;
|
this = (struct impl *) handle;
|
||||||
|
|
||||||
for (i = 0; i < n_support; i++) {
|
for (i = 0; i < n_support; i++) {
|
||||||
if (support[i].type == SPA_TYPE_INTERFACE_Log)
|
switch (support[i].type) {
|
||||||
|
case SPA_TYPE_INTERFACE_Log:
|
||||||
this->log = support[i].data;
|
this->log = support[i].data;
|
||||||
|
break;
|
||||||
|
case SPA_TYPE_INTERFACE_CPU:
|
||||||
|
this->cpu = support[i].data;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->cpu)
|
||||||
|
this->cpu_flags = spa_cpu_get_flags(this->cpu);
|
||||||
|
|
||||||
this->node = impl_node;
|
this->node = impl_node;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <spa/support/cpu.h>
|
||||||
#include <spa/utils/defs.h>
|
#include <spa/utils/defs.h>
|
||||||
|
|
||||||
#define U8_MIN 0
|
#define U8_MIN 0
|
||||||
|
|
@ -677,9 +678,7 @@ typedef void (*convert_func_t) (void *data, int n_dst, void *dst[n_dst],
|
||||||
static const struct conv_info {
|
static const struct conv_info {
|
||||||
uint32_t src_fmt;
|
uint32_t src_fmt;
|
||||||
uint32_t dst_fmt;
|
uint32_t dst_fmt;
|
||||||
#define FEATURE_SSE (1<<0)
|
#define FEATURE_SSE SPA_CPU_FLAG_SSE
|
||||||
#define FEATURE_SSE2 (1<<1)
|
|
||||||
#define FEATURE_DEFAULT FEATURE_SSE
|
|
||||||
uint32_t features;
|
uint32_t features;
|
||||||
|
|
||||||
convert_func_t func;
|
convert_func_t func;
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include <spa/support/log.h>
|
#include <spa/support/log.h>
|
||||||
|
#include <spa/support/cpu.h>
|
||||||
#include <spa/utils/list.h>
|
#include <spa/utils/list.h>
|
||||||
#include <spa/node/node.h>
|
#include <spa/node/node.h>
|
||||||
#include <spa/node/io.h>
|
#include <spa/node/io.h>
|
||||||
|
|
@ -98,6 +99,7 @@ struct impl {
|
||||||
struct spa_node node;
|
struct spa_node node;
|
||||||
|
|
||||||
struct spa_log *log;
|
struct spa_log *log;
|
||||||
|
struct spa_cpu *cpu;
|
||||||
|
|
||||||
struct props props;
|
struct props props;
|
||||||
|
|
||||||
|
|
@ -110,6 +112,7 @@ struct impl {
|
||||||
|
|
||||||
bool started;
|
bool started;
|
||||||
|
|
||||||
|
uint32_t cpu_flags;
|
||||||
convert_func_t convert;
|
convert_func_t convert;
|
||||||
|
|
||||||
float empty[4096];
|
float empty[4096];
|
||||||
|
|
@ -173,12 +176,12 @@ static int setup_convert(struct impl *this)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* find fast path */
|
/* find fast path */
|
||||||
conv = find_conv_info(src_fmt, dst_fmt, FEATURE_DEFAULT);
|
conv = find_conv_info(src_fmt, dst_fmt, this->cpu_flags);
|
||||||
if (conv == NULL)
|
if (conv == NULL)
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
|
|
||||||
spa_log_info(this->log, NAME " %p: got converter features %08x", this,
|
spa_log_info(this->log, NAME " %p: got converter features %08x:%08x", this,
|
||||||
conv->features);
|
this->cpu_flags, conv->features);
|
||||||
|
|
||||||
this->convert = conv->func;
|
this->convert = conv->func;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -973,11 +976,20 @@ impl_init(const struct spa_handle_factory *factory,
|
||||||
this = (struct impl *) handle;
|
this = (struct impl *) handle;
|
||||||
|
|
||||||
for (i = 0; i < n_support; i++) {
|
for (i = 0; i < n_support; i++) {
|
||||||
if (support[i].type == SPA_TYPE_INTERFACE_Log)
|
switch (support[i].type) {
|
||||||
|
case SPA_TYPE_INTERFACE_Log:
|
||||||
this->log = support[i].data;
|
this->log = support[i].data;
|
||||||
|
break;
|
||||||
|
case SPA_TYPE_INTERFACE_CPU:
|
||||||
|
this->cpu = support[i].data;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this->node = impl_node;
|
this->node = impl_node;
|
||||||
|
|
||||||
|
if (this->cpu)
|
||||||
|
this->cpu_flags = spa_cpu_get_flags(this->cpu);
|
||||||
|
|
||||||
init_port(this, SPA_DIRECTION_OUTPUT, 0, SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS);
|
init_port(this, SPA_DIRECTION_OUTPUT, 0, SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS);
|
||||||
init_port(this, SPA_DIRECTION_INPUT, 0, SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS);
|
init_port(this, SPA_DIRECTION_INPUT, 0, SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ struct impl {
|
||||||
struct spa_node node;
|
struct spa_node node;
|
||||||
|
|
||||||
struct spa_log *log;
|
struct spa_log *log;
|
||||||
|
struct spa_cpu *cpu;
|
||||||
|
|
||||||
const struct spa_node_callbacks *callbacks;
|
const struct spa_node_callbacks *callbacks;
|
||||||
void *user_data;
|
void *user_data;
|
||||||
|
|
@ -92,6 +93,7 @@ struct impl {
|
||||||
int monitor_count;
|
int monitor_count;
|
||||||
|
|
||||||
bool started;
|
bool started;
|
||||||
|
uint32_t cpu_flags;
|
||||||
convert_func_t convert;
|
convert_func_t convert;
|
||||||
|
|
||||||
bool monitor;
|
bool monitor;
|
||||||
|
|
@ -576,10 +578,10 @@ static int setup_convert(struct impl *this)
|
||||||
outport->format.info.raw.channels,
|
outport->format.info.raw.channels,
|
||||||
outport->format.info.raw.rate);
|
outport->format.info.raw.rate);
|
||||||
|
|
||||||
conv = find_conv_info(src_fmt, dst_fmt, FEATURE_DEFAULT);
|
conv = find_conv_info(src_fmt, dst_fmt, this->cpu_flags);
|
||||||
if (conv != NULL) {
|
if (conv != NULL) {
|
||||||
spa_log_info(this->log, NAME " %p: got converter features %08x", this,
|
spa_log_info(this->log, NAME " %p: got converter features %08x:%08x", this,
|
||||||
conv->features);
|
this->cpu_flags, conv->features);
|
||||||
|
|
||||||
this->convert = conv->func;
|
this->convert = conv->func;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -1063,9 +1065,18 @@ impl_init(const struct spa_handle_factory *factory,
|
||||||
this = (struct impl *) handle;
|
this = (struct impl *) handle;
|
||||||
|
|
||||||
for (i = 0; i < n_support; i++) {
|
for (i = 0; i < n_support; i++) {
|
||||||
if (support[i].type == SPA_TYPE_INTERFACE_Log)
|
switch (support[i].type) {
|
||||||
|
case SPA_TYPE_INTERFACE_Log:
|
||||||
this->log = support[i].data;
|
this->log = support[i].data;
|
||||||
|
break;
|
||||||
|
case SPA_TYPE_INTERFACE_CPU:
|
||||||
|
this->cpu = support[i].data;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->cpu)
|
||||||
|
this->cpu_flags = spa_cpu_get_flags(this->cpu);
|
||||||
|
|
||||||
if (info != NULL && (str = spa_dict_lookup(info, "merger.monitor")) != NULL)
|
if (info != NULL && (str = spa_dict_lookup(info, "merger.monitor")) != NULL)
|
||||||
this->monitor = atoi(str);
|
this->monitor = atoi(str);
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,7 @@ struct impl {
|
||||||
struct spa_node node;
|
struct spa_node node;
|
||||||
|
|
||||||
struct spa_log *log;
|
struct spa_log *log;
|
||||||
|
struct spa_cpu *cpu;
|
||||||
|
|
||||||
const struct spa_node_callbacks *callbacks;
|
const struct spa_node_callbacks *callbacks;
|
||||||
void *user_data;
|
void *user_data;
|
||||||
|
|
@ -92,6 +93,7 @@ struct impl {
|
||||||
int port_count;
|
int port_count;
|
||||||
|
|
||||||
bool started;
|
bool started;
|
||||||
|
uint32_t cpu_flags;
|
||||||
convert_func_t convert;
|
convert_func_t convert;
|
||||||
|
|
||||||
bool have_profile;
|
bool have_profile;
|
||||||
|
|
@ -569,10 +571,10 @@ static int setup_convert(struct impl *this)
|
||||||
inport->format.info.raw.rate,
|
inport->format.info.raw.rate,
|
||||||
this->port_count);
|
this->port_count);
|
||||||
|
|
||||||
conv = find_conv_info(src_fmt, dst_fmt, FEATURE_DEFAULT);
|
conv = find_conv_info(src_fmt, dst_fmt, this->cpu_flags);
|
||||||
if (conv != NULL) {
|
if (conv != NULL) {
|
||||||
spa_log_info(this->log, NAME " %p: got converter features %08x", this,
|
spa_log_info(this->log, NAME " %p: got converter features %08x:%08x", this,
|
||||||
conv->features);
|
this->cpu_flags, conv->features);
|
||||||
|
|
||||||
this->convert = conv->func;
|
this->convert = conv->func;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -1006,9 +1008,17 @@ impl_init(const struct spa_handle_factory *factory,
|
||||||
this = (struct impl *) handle;
|
this = (struct impl *) handle;
|
||||||
|
|
||||||
for (i = 0; i < n_support; i++) {
|
for (i = 0; i < n_support; i++) {
|
||||||
if (support[i].type == SPA_TYPE_INTERFACE_Log)
|
switch (support[i].type) {
|
||||||
|
case SPA_TYPE_INTERFACE_Log:
|
||||||
this->log = support[i].data;
|
this->log = support[i].data;
|
||||||
|
break;
|
||||||
|
case SPA_TYPE_INTERFACE_CPU:
|
||||||
|
this->cpu = support[i].data;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (this->cpu)
|
||||||
|
this->cpu_flags = spa_cpu_get_flags(this->cpu);
|
||||||
|
|
||||||
this->node = impl_node;
|
this->node = impl_node;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue