diff --git a/spa/plugins/audioconvert/audioconvert.c b/spa/plugins/audioconvert/audioconvert.c index 2f05ab4df..6673a8b46 100644 --- a/spa/plugins/audioconvert/audioconvert.c +++ b/spa/plugins/audioconvert/audioconvert.c @@ -1396,16 +1396,16 @@ static int setup_out_convert(struct impl *this) this->cpu_flags, out->conv.cpu_flags, out->conv.is_passthrough); if (this->props.dither_noise > 0) { - this->dither.intensity = (calc_width(&dst_info) * 8) - 1; - this->dither.intensity -= SPA_MIN(this->dither.intensity, this->props.dither_noise); + this->dither.quantize = 32 - (calc_width(&dst_info) * 8); + this->dither.quantize += this->props.dither_noise; this->dither.n_channels = dst_info.info.raw.channels; this->dither.cpu_flags = this->cpu_flags; if ((res = dither_init(&this->dither)) < 0) return res; - spa_log_debug(this->log, "%p: dither noise:%d intensity:%d", this, - this->props.dither_noise, this->dither.intensity); + spa_log_info(this->log, "%p: dither noise:%d quantize:%d", this, + this->props.dither_noise, this->dither.quantize); } return 0; } diff --git a/spa/plugins/audioconvert/dither-ops.c b/spa/plugins/audioconvert/dither-ops.c index 5d84f8eb5..ffb79989c 100644 --- a/spa/plugins/audioconvert/dither-ops.c +++ b/spa/plugins/audioconvert/dither-ops.c @@ -79,10 +79,10 @@ int dither_init(struct dither *d) if (info == NULL) return -ENOTSUP; - if (d->intensity >= 32) + if (d->quantize >= 32) return -EINVAL; - d->scale = 1.0f / (1ULL << (31 + d->intensity)); + d->scale = 1.0f / (1ULL << (63 - d->quantize)); d->dither_size = DITHER_SIZE; d->dither = calloc(d->dither_size + DITHER_OPS_MAX_OVERREAD + diff --git a/spa/plugins/audioconvert/dither-ops.h b/spa/plugins/audioconvert/dither-ops.h index 867b469f8..afa96db5f 100644 --- a/spa/plugins/audioconvert/dither-ops.h +++ b/spa/plugins/audioconvert/dither-ops.h @@ -33,7 +33,7 @@ #define DITHER_OPS_MAX_OVERREAD 16 struct dither { - uint32_t intensity; + uint32_t quantize; #define DITHER_METHOD_NONE 0 #define DITHER_METHOD_RECTANGULAR 2 #define DITHER_METHOD_TRIANGULAR 3