forked from len0rd/rockbox
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
This commit is contained in:
parent
8f5f690760
commit
c668de3085
3 changed files with 42 additions and 19 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue