mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-22 06:59:59 -05:00
resample: make window configurable
Add kaiser window
This commit is contained in:
parent
18ff08243b
commit
bfd26c98e3
5 changed files with 422 additions and 66 deletions
|
|
@ -10,6 +10,32 @@
|
|||
|
||||
#define RESAMPLE_DEFAULT_QUALITY 4
|
||||
|
||||
struct resample_config {
|
||||
#define RESAMPLE_WINDOW_DEFAULT 0
|
||||
#define RESAMPLE_WINDOW_EXP 1
|
||||
#define RESAMPLE_WINDOW_BLACKMAN 2
|
||||
#define RESAMPLE_WINDOW_KAISER 3
|
||||
uint32_t window;
|
||||
|
||||
uint32_t n_taps;
|
||||
double cutoff;
|
||||
|
||||
union {
|
||||
double params[32];
|
||||
struct {
|
||||
double A;
|
||||
} exp_params;
|
||||
struct {
|
||||
double alpha;
|
||||
} blackman_params;
|
||||
struct {
|
||||
double stopband_attenuation;
|
||||
double transition_bandwidth;
|
||||
double alpha;
|
||||
} kaiser_params;
|
||||
};
|
||||
};
|
||||
|
||||
struct resample {
|
||||
struct spa_log *log;
|
||||
#define RESAMPLE_OPTION_PREFILL (1<<0)
|
||||
|
|
@ -23,6 +49,8 @@ struct resample {
|
|||
double rate;
|
||||
int quality;
|
||||
|
||||
struct resample_config config;
|
||||
|
||||
void (*free) (struct resample *r);
|
||||
void (*update_rate) (struct resample *r, double rate);
|
||||
uint32_t (*in_len) (struct resample *r, uint32_t out_len);
|
||||
|
|
@ -49,6 +77,32 @@ struct resample {
|
|||
#define resample_phase(r) (r)->phase(r)
|
||||
|
||||
int resample_native_init(struct resample *r);
|
||||
int resample_native_init_config(struct resample *r, struct resample_config *conf);
|
||||
int resample_peaks_init(struct resample *r);
|
||||
|
||||
static const struct resample_window_info {
|
||||
uint32_t window;
|
||||
const char *label;
|
||||
const char *description;
|
||||
} resample_window_info[] = {
|
||||
[RESAMPLE_WINDOW_DEFAULT] = { RESAMPLE_WINDOW_DEFAULT,
|
||||
"default", "Default window", },
|
||||
[RESAMPLE_WINDOW_EXP] = { RESAMPLE_WINDOW_EXP,
|
||||
"exponential", "Exponential window", },
|
||||
[RESAMPLE_WINDOW_BLACKMAN] = { RESAMPLE_WINDOW_BLACKMAN,
|
||||
"blackman", "Blackman window", },
|
||||
[RESAMPLE_WINDOW_KAISER] = { RESAMPLE_WINDOW_KAISER,
|
||||
"kaiser", "Kaiser window", },
|
||||
};
|
||||
|
||||
static inline uint32_t resample_window_from_label(const char *label)
|
||||
{
|
||||
SPA_FOR_EACH_ELEMENT_VAR(resample_window_info, i) {
|
||||
if (spa_streq(i->label, label))
|
||||
return i->window;
|
||||
}
|
||||
return RESAMPLE_WINDOW_EXP;
|
||||
}
|
||||
|
||||
|
||||
#endif /* RESAMPLE_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue