mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-05 13:30:02 -05:00
filter-chain: move functions to separate struct
So that it's easier to copy them.
This commit is contained in:
parent
fa10849139
commit
cd38d7b53b
3 changed files with 27 additions and 24 deletions
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
#include "dsp-ops.h"
|
#include "dsp-ops.h"
|
||||||
|
|
||||||
static inline void dsp_clear_c(struct dsp_ops *ops, void * SPA_RESTRICT dst, uint32_t n_samples)
|
void dsp_clear_c(struct dsp_ops *ops, void * SPA_RESTRICT dst, uint32_t n_samples)
|
||||||
{
|
{
|
||||||
memset(dst, 0, sizeof(float) * n_samples);
|
memset(dst, 0, sizeof(float) * n_samples);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,30 +35,24 @@
|
||||||
struct dsp_info {
|
struct dsp_info {
|
||||||
uint32_t cpu_flags;
|
uint32_t cpu_flags;
|
||||||
|
|
||||||
void (*copy) (struct dsp_ops *ops,
|
struct dsp_ops_funcs funcs;
|
||||||
void * SPA_RESTRICT dst,
|
|
||||||
const void * SPA_RESTRICT src, uint32_t n_samples);
|
|
||||||
void (*mix_gain) (struct dsp_ops *ops,
|
|
||||||
void * SPA_RESTRICT dst,
|
|
||||||
const void * SPA_RESTRICT src[],
|
|
||||||
float gain[], uint32_t n_src, uint32_t n_samples);
|
|
||||||
void (*biquad_run) (struct dsp_ops *ops, struct biquad *bq,
|
|
||||||
float *out, const float *in, uint32_t n_samples);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct dsp_info dsp_table[] =
|
static struct dsp_info dsp_table[] =
|
||||||
{
|
{
|
||||||
#if defined (HAVE_SSE)
|
#if defined (HAVE_SSE)
|
||||||
{ SPA_CPU_FLAG_SSE,
|
{ SPA_CPU_FLAG_SSE,
|
||||||
.copy = dsp_copy_c,
|
.funcs.clear = dsp_clear_c,
|
||||||
.mix_gain = dsp_mix_gain_sse,
|
.funcs.copy = dsp_copy_c,
|
||||||
.biquad_run = dsp_biquad_run_c,
|
.funcs.mix_gain = dsp_mix_gain_sse,
|
||||||
|
.funcs.biquad_run = dsp_biquad_run_c,
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
{ 0,
|
{ 0,
|
||||||
.copy = dsp_copy_c,
|
.funcs.clear = dsp_clear_c,
|
||||||
.mix_gain = dsp_mix_gain_c,
|
.funcs.copy = dsp_copy_c,
|
||||||
.biquad_run = dsp_biquad_run_c,
|
.funcs.mix_gain = dsp_mix_gain_c,
|
||||||
|
.funcs.biquad_run = dsp_biquad_run_c,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -88,10 +82,8 @@ int dsp_ops_init(struct dsp_ops *ops)
|
||||||
|
|
||||||
ops->priv = info;
|
ops->priv = info;
|
||||||
ops->cpu_flags = info->cpu_flags;
|
ops->cpu_flags = info->cpu_flags;
|
||||||
ops->copy = info->copy;
|
|
||||||
ops->mix_gain = info->mix_gain;
|
|
||||||
ops->biquad_run = info->biquad_run;
|
|
||||||
ops->free = impl_dsp_ops_free;
|
ops->free = impl_dsp_ops_free;
|
||||||
|
ops->funcs = info->funcs;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,9 @@
|
||||||
|
|
||||||
#include "biquad.h"
|
#include "biquad.h"
|
||||||
|
|
||||||
struct dsp_ops {
|
struct dsp_ops;
|
||||||
uint32_t cpu_flags;
|
|
||||||
|
|
||||||
|
struct dsp_ops_funcs {
|
||||||
void (*clear) (struct dsp_ops *ops, void * SPA_RESTRICT dst, uint32_t n_samples);
|
void (*clear) (struct dsp_ops *ops, void * SPA_RESTRICT dst, uint32_t n_samples);
|
||||||
void (*copy) (struct dsp_ops *ops,
|
void (*copy) (struct dsp_ops *ops,
|
||||||
void * SPA_RESTRICT dst,
|
void * SPA_RESTRICT dst,
|
||||||
|
|
@ -42,19 +42,29 @@ struct dsp_ops {
|
||||||
float gain[], uint32_t n_src, uint32_t n_samples);
|
float gain[], uint32_t n_src, uint32_t n_samples);
|
||||||
void (*biquad_run) (struct dsp_ops *ops, struct biquad *bq,
|
void (*biquad_run) (struct dsp_ops *ops, struct biquad *bq,
|
||||||
float *out, const float *in, uint32_t n_samples);
|
float *out, const float *in, uint32_t n_samples);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct dsp_ops {
|
||||||
|
uint32_t cpu_flags;
|
||||||
|
|
||||||
void (*free) (struct dsp_ops *ops);
|
void (*free) (struct dsp_ops *ops);
|
||||||
|
|
||||||
|
struct dsp_ops_funcs funcs;
|
||||||
|
|
||||||
const void *priv;
|
const void *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
int dsp_ops_init(struct dsp_ops *ops);
|
int dsp_ops_init(struct dsp_ops *ops);
|
||||||
|
|
||||||
#define dsp_ops_copy(ops,...) (ops)->copy(ops, __VA_ARGS__)
|
|
||||||
#define dsp_ops_mix_gain(ops,...) (ops)->mix_gain(ops, __VA_ARGS__)
|
|
||||||
#define dsp_ops_biquad_run(ops,...) (ops)->biquad_run(ops, __VA_ARGS__)
|
|
||||||
#define dsp_ops_free(ops) (ops)->free(ops)
|
#define dsp_ops_free(ops) (ops)->free(ops)
|
||||||
|
|
||||||
|
#define dsp_ops_clear(ops,...) (ops)->funcs.clear(ops, __VA_ARGS__)
|
||||||
|
#define dsp_ops_copy(ops,...) (ops)->funcs.copy(ops, __VA_ARGS__)
|
||||||
|
#define dsp_ops_mix_gain(ops,...) (ops)->funcs.mix_gain(ops, __VA_ARGS__)
|
||||||
|
#define dsp_ops_biquad_run(ops,...) (ops)->funcs.biquad_run(ops, __VA_ARGS__)
|
||||||
|
|
||||||
|
#define MAKE_CLEAR_FUNC(arch) \
|
||||||
|
void dsp_clear_##arch(struct dsp_ops *ops, void * SPA_RESTRICT dst, uint32_t n_samples)
|
||||||
#define MAKE_COPY_FUNC(arch) \
|
#define MAKE_COPY_FUNC(arch) \
|
||||||
void dsp_copy_##arch(struct dsp_ops *ops, void * SPA_RESTRICT dst, \
|
void dsp_copy_##arch(struct dsp_ops *ops, void * SPA_RESTRICT dst, \
|
||||||
const void * SPA_RESTRICT src, uint32_t n_samples)
|
const void * SPA_RESTRICT src, uint32_t n_samples)
|
||||||
|
|
@ -66,6 +76,7 @@ void dsp_biquad_run_##arch (struct dsp_ops *ops, struct biquad *bq, \
|
||||||
float *out, const float *in, uint32_t n_samples)
|
float *out, const float *in, uint32_t n_samples)
|
||||||
|
|
||||||
|
|
||||||
|
MAKE_CLEAR_FUNC(c);
|
||||||
MAKE_COPY_FUNC(c);
|
MAKE_COPY_FUNC(c);
|
||||||
MAKE_MIX_GAIN_FUNC(c);
|
MAKE_MIX_GAIN_FUNC(c);
|
||||||
MAKE_BIQUAD_RUN_FUNC(c);
|
MAKE_BIQUAD_RUN_FUNC(c);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue