pcm/Volume: improved dithering

Instead of just adding a rectangular random value before shifting back
to the normal scale, use the existing PcmDither library.
This commit is contained in:
Max Kellermann
2013-12-22 17:39:26 +01:00
parent 394e2815db
commit afcf0795c4
6 changed files with 59 additions and 22 deletions

View File

@@ -60,8 +60,9 @@ TestVolume(G g=G())
const auto _dest = ConstBuffer<value_type>::FromVoid(dest);
for (unsigned i = 0; i < N; ++i) {
CPPUNIT_ASSERT(_dest.data[i] >= (_src[i] - 1) / 2);
CPPUNIT_ASSERT(_dest.data[i] <= _src[i] / 2 + 1);
const auto expected = (_src[i] + 1) / 2;
CPPUNIT_ASSERT(_dest.data[i] >= expected - 4);
CPPUNIT_ASSERT(_dest.data[i] <= expected + 4);
}
pv.Close();