2023-02-08 18:12:00 +01:00
|
|
|
/* Spa */
|
|
|
|
|
/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
|
|
|
|
|
/* SPDX-License-Identifier: MIT */
|
2018-12-05 15:58:55 +01:00
|
|
|
|
2019-03-27 17:58:48 +01:00
|
|
|
#ifndef RESAMPLE_H
|
|
|
|
|
#define RESAMPLE_H
|
|
|
|
|
|
2018-12-19 16:47:20 +01:00
|
|
|
#include <spa/support/cpu.h>
|
2019-04-02 23:06:46 +02:00
|
|
|
#include <spa/support/log.h>
|
2018-12-19 16:47:20 +01:00
|
|
|
|
2020-02-12 13:31:03 +01:00
|
|
|
#define RESAMPLE_DEFAULT_QUALITY 4
|
|
|
|
|
|
2018-12-05 15:58:55 +01:00
|
|
|
struct resample {
|
2022-06-28 16:45:07 +02:00
|
|
|
struct spa_log *log;
|
2022-09-19 12:35:49 +02:00
|
|
|
#define RESAMPLE_OPTION_PREFILL (1<<0)
|
|
|
|
|
uint32_t options;
|
2018-12-19 16:47:20 +01:00
|
|
|
uint32_t cpu_flags;
|
2022-06-28 16:45:07 +02:00
|
|
|
const char *func_name;
|
|
|
|
|
|
2018-12-05 15:58:55 +01:00
|
|
|
uint32_t channels;
|
|
|
|
|
uint32_t i_rate;
|
|
|
|
|
uint32_t o_rate;
|
2019-04-23 17:34:27 +02:00
|
|
|
double rate;
|
2020-02-12 13:31:03 +01:00
|
|
|
int quality;
|
2018-12-05 15:58:55 +01:00
|
|
|
|
2019-03-26 12:58:26 +01:00
|
|
|
void (*free) (struct resample *r);
|
|
|
|
|
void (*update_rate) (struct resample *r, double rate);
|
2019-07-08 18:26:08 +02:00
|
|
|
uint32_t (*in_len) (struct resample *r, uint32_t out_len);
|
|
|
|
|
uint32_t (*out_len) (struct resample *r, uint32_t in_len);
|
2019-03-26 12:58:26 +01:00
|
|
|
void (*process) (struct resample *r,
|
|
|
|
|
const void * SPA_RESTRICT src[], uint32_t *in_len,
|
|
|
|
|
void * SPA_RESTRICT dst[], uint32_t *out_len);
|
|
|
|
|
void (*reset) (struct resample *r);
|
|
|
|
|
uint32_t (*delay) (struct resample *r);
|
2025-01-14 21:54:45 +02:00
|
|
|
int32_t (*phase_ns) (struct resample *r);
|
2018-12-05 15:58:55 +01:00
|
|
|
void *data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define resample_free(r) (r)->free(r)
|
|
|
|
|
#define resample_update_rate(r,...) (r)->update_rate(r,__VA_ARGS__)
|
2019-07-08 18:26:08 +02:00
|
|
|
#define resample_in_len(r,...) (r)->in_len(r,__VA_ARGS__)
|
|
|
|
|
#define resample_out_len(r,...) (r)->out_len(r,__VA_ARGS__)
|
2018-12-05 15:58:55 +01:00
|
|
|
#define resample_process(r,...) (r)->process(r,__VA_ARGS__)
|
|
|
|
|
#define resample_reset(r) (r)->reset(r)
|
2019-03-26 12:58:26 +01:00
|
|
|
#define resample_delay(r) (r)->delay(r)
|
2025-01-14 21:54:45 +02:00
|
|
|
#define resample_phase_ns(r) (r)->phase_ns(r)
|
2019-03-27 17:58:48 +01:00
|
|
|
|
2020-04-03 17:46:04 +02:00
|
|
|
int resample_native_init(struct resample *r);
|
|
|
|
|
int resample_peaks_init(struct resample *r);
|
|
|
|
|
|
2019-03-27 17:58:48 +01:00
|
|
|
#endif /* RESAMPLE_H */
|