summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2014-03-03 14:45:14 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2014-03-03 14:45:14 +0100
commitf7ab9fb52a0d50db3e5de67e74f1654ad374ae59 (patch)
tree42bcf6ed34290dc490d64a7e2414bef1f76cf9fe
parent7fc78023587e6cb238d5fa16f5acafb4078c6798 (diff)
downloadplan9front-f7ab9fb52a0d50db3e5de67e74f1654ad374ae59.tar.xz
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().
-rw-r--r--sys/src/cmd/audio/pcmconv/pcmconv.c5
1 files changed, 3 insertions, 2 deletions
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++;
}
}