audioconvert: round instead of truncate, to reduce distortion

See #2543
This commit is contained in:
Wim Taymans 2022-07-13 20:56:13 +02:00
parent d18428f8bb
commit 0ba3e7c5db
4 changed files with 58 additions and 58 deletions

View file

@ -35,12 +35,12 @@
#include <spa/utils/defs.h>
#include <spa/utils/string.h>
#define ROUND(v) (v)
#define f32_round(a) lrintf(a)
#define ITOF(type,v,scale,offs) \
(((type)(v)) * (1.0f / (scale)) - (offs))
#define FTOI(type,v,scale,offs,dither,min,max) \
(type)ROUND(SPA_CLAMP((v) * (scale) + (offs) + (dither), min, max))
(type)f32_round(SPA_CLAMP((v) * (scale) + (offs) + (dither), min, max))
#define FMT_OPS_MAX_ALIGN 32