From f7ab9fb52a0d50db3e5de67e74f1654ad374ae59 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Mon, 3 Mar 2014 14:45:14 +0100 Subject: pcmconv: revert previous change, fix dither clipping previous change had forgot how dithering works... m( we *really* add a random signal when *reducing* the number of bits. just make sure we do not overflow like in mixin(). --- sys/src/cmd/audio/pcmconv/pcmconv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sys/src/cmd/audio') diff --git a/sys/src/cmd/audio/pcmconv/pcmconv.c b/sys/src/cmd/audio/pcmconv/pcmconv.c index 0c9cba35c..3adda141a 100644 --- a/sys/src/cmd/audio/pcmconv/pcmconv.c +++ b/sys/src/cmd/audio/pcmconv/pcmconv.c @@ -209,12 +209,13 @@ dither(int *y, int ibits, int obits, int count) { static ulong prnd; - if(ibits >= 32 || ibits >= obits) + if(ibits >= 32 || obits >= ibits) return; while(count--){ prnd = (prnd*0x19660dL + 0x3c6ef35fL) & 0xffffffffL; - *y++ += ((int)prnd) >> ibits; + *y = clip((vlong)*y + ((int)prnd >> ibits)); + y++; } } -- cgit v1.2.3