mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
resample: make quality configurable
This commit is contained in:
parent
f726a77385
commit
454e743d1a
5 changed files with 14 additions and 3 deletions
|
|
@ -134,6 +134,7 @@ int main(int argc, char *argv[])
|
||||||
r.cpu_flags = 0;
|
r.cpu_flags = 0;
|
||||||
r.i_rate = in_rates[i];
|
r.i_rate = in_rates[i];
|
||||||
r.o_rate = out_rates[i];
|
r.o_rate = out_rates[i];
|
||||||
|
r.quality = RESAMPLE_DEFAULT_QUALITY;
|
||||||
impl_native_init(&r);
|
impl_native_init(&r);
|
||||||
run_test("native", "c", &r);
|
run_test("native", "c", &r);
|
||||||
resample_free(&r);
|
resample_free(&r);
|
||||||
|
|
@ -145,6 +146,7 @@ int main(int argc, char *argv[])
|
||||||
r.cpu_flags = SPA_CPU_FLAG_SSE;
|
r.cpu_flags = SPA_CPU_FLAG_SSE;
|
||||||
r.i_rate = in_rates[i];
|
r.i_rate = in_rates[i];
|
||||||
r.o_rate = out_rates[i];
|
r.o_rate = out_rates[i];
|
||||||
|
r.quality = RESAMPLE_DEFAULT_QUALITY;
|
||||||
impl_native_init(&r);
|
impl_native_init(&r);
|
||||||
run_test("native", "sse", &r);
|
run_test("native", "sse", &r);
|
||||||
resample_free(&r);
|
resample_free(&r);
|
||||||
|
|
@ -157,6 +159,7 @@ int main(int argc, char *argv[])
|
||||||
r.cpu_flags = SPA_CPU_FLAG_SSSE3 | SPA_CPU_FLAG_SLOW_UNALIGNED;
|
r.cpu_flags = SPA_CPU_FLAG_SSSE3 | SPA_CPU_FLAG_SLOW_UNALIGNED;
|
||||||
r.i_rate = in_rates[i];
|
r.i_rate = in_rates[i];
|
||||||
r.o_rate = out_rates[i];
|
r.o_rate = out_rates[i];
|
||||||
|
r.quality = RESAMPLE_DEFAULT_QUALITY;
|
||||||
impl_native_init(&r);
|
impl_native_init(&r);
|
||||||
run_test("native", "ssse3", &r);
|
run_test("native", "ssse3", &r);
|
||||||
resample_free(&r);
|
resample_free(&r);
|
||||||
|
|
@ -169,6 +172,7 @@ int main(int argc, char *argv[])
|
||||||
r.cpu_flags = SPA_CPU_FLAG_AVX | SPA_CPU_FLAG_FMA3;
|
r.cpu_flags = SPA_CPU_FLAG_AVX | SPA_CPU_FLAG_FMA3;
|
||||||
r.i_rate = in_rates[i];
|
r.i_rate = in_rates[i];
|
||||||
r.o_rate = out_rates[i];
|
r.o_rate = out_rates[i];
|
||||||
|
r.quality = RESAMPLE_DEFAULT_QUALITY;
|
||||||
impl_native_init(&r);
|
impl_native_init(&r);
|
||||||
run_test("native", "avx", &r);
|
run_test("native", "avx", &r);
|
||||||
resample_free(&r);
|
resample_free(&r);
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,6 @@ struct quality {
|
||||||
double cutoff;
|
double cutoff;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DEFAULT_QUALITY 4
|
|
||||||
|
|
||||||
static const struct quality blackman_qualities[] = {
|
static const struct quality blackman_qualities[] = {
|
||||||
{ 8, 0.5, },
|
{ 8, 0.5, },
|
||||||
{ 16, 0.6, },
|
{ 16, 0.6, },
|
||||||
|
|
@ -256,7 +254,7 @@ static uint32_t impl_native_delay (struct resample *r)
|
||||||
static int impl_native_init(struct resample *r)
|
static int impl_native_init(struct resample *r)
|
||||||
{
|
{
|
||||||
struct native_data *d;
|
struct native_data *d;
|
||||||
const struct quality *q = &blackman_qualities[DEFAULT_QUALITY];
|
const struct quality *q = &blackman_qualities[r->quality];
|
||||||
double scale;
|
double scale;
|
||||||
uint32_t c, n_taps, n_phases, filter_size, in_rate, out_rate, gcd, filter_stride;
|
uint32_t c, n_taps, n_phases, filter_size, in_rate, out_rate, gcd, filter_stride;
|
||||||
uint32_t history_stride, history_size, oversample;
|
uint32_t history_stride, history_size, oversample;
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,7 @@ static int setup_convert(struct impl *this,
|
||||||
this->resample.i_rate = src_info->info.raw.rate;
|
this->resample.i_rate = src_info->info.raw.rate;
|
||||||
this->resample.o_rate = dst_info->info.raw.rate;
|
this->resample.o_rate = dst_info->info.raw.rate;
|
||||||
this->resample.log = this->log;
|
this->resample.log = this->log;
|
||||||
|
this->resample.quality = RESAMPLE_DEFAULT_QUALITY;
|
||||||
|
|
||||||
if (this->peaks)
|
if (this->peaks)
|
||||||
err = impl_peaks_init(&this->resample);
|
err = impl_peaks_init(&this->resample);
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@
|
||||||
#include <spa/support/cpu.h>
|
#include <spa/support/cpu.h>
|
||||||
#include <spa/support/log.h>
|
#include <spa/support/log.h>
|
||||||
|
|
||||||
|
#define RESAMPLE_DEFAULT_QUALITY 4
|
||||||
|
|
||||||
struct resample {
|
struct resample {
|
||||||
uint32_t cpu_flags;
|
uint32_t cpu_flags;
|
||||||
uint32_t channels;
|
uint32_t channels;
|
||||||
|
|
@ -35,6 +37,7 @@ struct resample {
|
||||||
uint32_t o_rate;
|
uint32_t o_rate;
|
||||||
struct spa_log *log;
|
struct spa_log *log;
|
||||||
double rate;
|
double rate;
|
||||||
|
int quality;
|
||||||
|
|
||||||
void (*free) (struct resample *r);
|
void (*free) (struct resample *r);
|
||||||
void (*update_rate) (struct resample *r, double rate);
|
void (*update_rate) (struct resample *r, double rate);
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ static void test_native(void)
|
||||||
r.channels = 1;
|
r.channels = 1;
|
||||||
r.i_rate = 44100;
|
r.i_rate = 44100;
|
||||||
r.o_rate = 44100;
|
r.o_rate = 44100;
|
||||||
|
r.quality = RESAMPLE_DEFAULT_QUALITY;
|
||||||
impl_native_init(&r);
|
impl_native_init(&r);
|
||||||
|
|
||||||
feed_1(&r);
|
feed_1(&r);
|
||||||
|
|
@ -81,6 +82,7 @@ static void test_native(void)
|
||||||
r.channels = 1;
|
r.channels = 1;
|
||||||
r.i_rate = 44100;
|
r.i_rate = 44100;
|
||||||
r.o_rate = 48000;
|
r.o_rate = 48000;
|
||||||
|
r.quality = RESAMPLE_DEFAULT_QUALITY;
|
||||||
impl_native_init(&r);
|
impl_native_init(&r);
|
||||||
|
|
||||||
feed_1(&r);
|
feed_1(&r);
|
||||||
|
|
@ -123,6 +125,7 @@ static void test_in_len(void)
|
||||||
r.channels = 1;
|
r.channels = 1;
|
||||||
r.i_rate = 32000;
|
r.i_rate = 32000;
|
||||||
r.o_rate = 48000;
|
r.o_rate = 48000;
|
||||||
|
r.quality = RESAMPLE_DEFAULT_QUALITY;
|
||||||
impl_native_init(&r);
|
impl_native_init(&r);
|
||||||
|
|
||||||
pull_blocks(&r, 1024);
|
pull_blocks(&r, 1024);
|
||||||
|
|
@ -132,6 +135,7 @@ static void test_in_len(void)
|
||||||
r.channels = 1;
|
r.channels = 1;
|
||||||
r.i_rate = 44100;
|
r.i_rate = 44100;
|
||||||
r.o_rate = 48000;
|
r.o_rate = 48000;
|
||||||
|
r.quality = RESAMPLE_DEFAULT_QUALITY;
|
||||||
impl_native_init(&r);
|
impl_native_init(&r);
|
||||||
|
|
||||||
pull_blocks(&r, 1024);
|
pull_blocks(&r, 1024);
|
||||||
|
|
@ -141,6 +145,7 @@ static void test_in_len(void)
|
||||||
r.channels = 1;
|
r.channels = 1;
|
||||||
r.i_rate = 48000;
|
r.i_rate = 48000;
|
||||||
r.o_rate = 44100;
|
r.o_rate = 44100;
|
||||||
|
r.quality = RESAMPLE_DEFAULT_QUALITY;
|
||||||
impl_native_init(&r);
|
impl_native_init(&r);
|
||||||
|
|
||||||
pull_blocks(&r, 1024);
|
pull_blocks(&r, 1024);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue