fix issue with unclipped dither
This commit is contained in:
@@ -17,12 +17,9 @@ static uint64_t sSeed1{0};
|
|||||||
static uint64_t sSeed2{0};
|
static uint64_t sSeed2{0};
|
||||||
|
|
||||||
auto shiftWithDither(int64_t src, uint_fast8_t bits) -> Sample {
|
auto shiftWithDither(int64_t src, uint_fast8_t bits) -> Sample {
|
||||||
// Generate `bits` random bits
|
// FIXME: Use a better dither.
|
||||||
uint64_t mask = 0xFFFFFFFF;
|
int16_t noise = static_cast<int16_t>(komirand(&sSeed1, &sSeed2) & 1);
|
||||||
mask >>= 32 - bits;
|
return (src >> bits) ^ noise;
|
||||||
int64_t noise = static_cast<int32_t>(komirand(&sSeed1, &sSeed2) & mask);
|
|
||||||
// Apply to the sample, then shift to 16 bit.
|
|
||||||
return (src + noise) >> bits;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sample
|
} // namespace sample
|
||||||
|
|||||||
Reference in New Issue
Block a user