From c668de30852552a275b809a24648aa5a887eac65 Mon Sep 17 00:00:00 2001 From: Thom Johansen Date: Wed, 29 Aug 2007 14:32:52 +0000 Subject: FS #7286. Do correct rounding of final 16 bit samples before sending to DAC, for you golden-eared people. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14514 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/test_codec.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'apps/plugins/test_codec.c') diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c index c29094b..4346a23 100644 --- a/apps/plugins/test_codec.c +++ b/apps/plugins/test_codec.c @@ -221,7 +221,8 @@ static bool pcmbuf_insert_wav(const void *ch1, const void *ch2, int count) const int32_t* data1_32; const int32_t* data2_32; unsigned char* p = wavbuffer; - int scale = wavinfo.sampledepth - 15; + const int scale = wavinfo.sampledepth - 15; + const int dc_bias = 1 << (scale - 1); /* Prevent idle poweroff */ rb->reset_poweroff_timer(); @@ -266,18 +267,18 @@ static bool pcmbuf_insert_wav(const void *ch1, const void *ch2, int count) { case STEREO_INTERLEAVED: while (count--) { - int2le16(p, clip_sample((*data1_32++) >> scale)); + int2le16(p, clip_sample((*data1_32++ + dc_bias) >> scale)); p += 2; - int2le16(p, clip_sample((*data1_32++) >> scale)); + int2le16(p, clip_sample((*data1_32++ + dc_bias) >> scale)); p += 2; } break; case STEREO_NONINTERLEAVED: while (count--) { - int2le16(p, clip_sample((*data1_32++) >> scale)); + int2le16(p, clip_sample((*data1_32++ + dc_bias) >> scale)); p += 2; - int2le16(p, clip_sample((*data2_32++) >> scale)); + int2le16(p, clip_sample((*data2_32++ + dc_bias) >> scale)); p += 2; } @@ -285,7 +286,7 @@ static bool pcmbuf_insert_wav(const void *ch1, const void *ch2, int count) case STEREO_MONO: while (count--) { - int2le16(p, clip_sample((*data1_32++) >> scale)); + int2le16(p, clip_sample((*data1_32++ + dc_bias) >> scale)); p += 2; } break; -- cgit v1.1