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().
This commit is contained in:
parent
7fc7802358
commit
f7ab9fb52a
1 changed files with 3 additions and 2 deletions
|
@ -209,12 +209,13 @@ dither(int *y, int ibits, int obits, int count)
|
||||||
{
|
{
|
||||||
static ulong prnd;
|
static ulong prnd;
|
||||||
|
|
||||||
if(ibits >= 32 || ibits >= obits)
|
if(ibits >= 32 || obits >= ibits)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while(count--){
|
while(count--){
|
||||||
prnd = (prnd*0x19660dL + 0x3c6ef35fL) & 0xffffffffL;
|
prnd = (prnd*0x19660dL + 0x3c6ef35fL) & 0xffffffffL;
|
||||||
*y++ += ((int)prnd) >> ibits;
|
*y = clip((vlong)*y + ((int)prnd >> ibits));
|
||||||
|
y++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue