From a84bf672e845777b0a6d89c4d7140f31f0d51b1a Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 28 Jun 2022 11:31:40 +0200 Subject: [PATCH] audioconvert: add dither passthrough flag --- spa/plugins/audioconvert/audioconvert.c | 7 ++++--- spa/plugins/audioconvert/dither-ops.c | 3 +++ spa/plugins/audioconvert/dither-ops.h | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/spa/plugins/audioconvert/audioconvert.c b/spa/plugins/audioconvert/audioconvert.c index a936f3a4a..4b43f003e 100644 --- a/spa/plugins/audioconvert/audioconvert.c +++ b/spa/plugins/audioconvert/audioconvert.c @@ -1409,9 +1409,10 @@ static int setup_dither(struct impl *this) if ((res = dither_init(&this->dither)) < 0) return res; - spa_log_info(this->log, "%p:got dither %08x:%08x noise:%d quantize:%d", this, + spa_log_info(this->log, "%p: got dither %08x:%08x quantize:%d:%d passthrough:%d", this, this->cpu_flags, this->dither.cpu_flags, - this->dither.noise, this->dither.quantize); + this->dither.quantize, this->dither.noise, + this->dither.is_passthrough); return 0; } @@ -2485,7 +2486,7 @@ static int impl_node_process(void *object) } this->out_offset += n_samples; - if (this->dither.process != NULL) { + if (!this->dither.is_passthrough) { in_datas = (const void**)out_datas; if (out_passthrough) out_datas = dst_datas; diff --git a/spa/plugins/audioconvert/dither-ops.c b/spa/plugins/audioconvert/dither-ops.c index 70ea32e75..1ff6428e0 100644 --- a/spa/plugins/audioconvert/dither-ops.c +++ b/spa/plugins/audioconvert/dither-ops.c @@ -98,5 +98,8 @@ int dither_init(struct dither *d) d->free = impl_dither_free; d->process = info->process; + + d->is_passthrough = d->noise == 0 && d->method == DITHER_METHOD_NONE; + return 0; } diff --git a/spa/plugins/audioconvert/dither-ops.h b/spa/plugins/audioconvert/dither-ops.h index 46feb4d69..780d191f0 100644 --- a/spa/plugins/audioconvert/dither-ops.h +++ b/spa/plugins/audioconvert/dither-ops.h @@ -42,6 +42,7 @@ struct dither { uint32_t method; uint32_t n_channels; uint32_t cpu_flags; + unsigned int is_passthrough:1; struct spa_log *log;