summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-02-27 19:14:21 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-02-27 19:14:21 +0000
commitb5b4a16b6dc2c5afb34f83b0395c5806ac20ff7c (patch)
tree22fd53c73473991e193e786ee93e7822b397cbd7
parent92e6bcbe17d56d9acb50c52edc8f55233156ae8f (diff)
downloadrockbox-b5b4a16b6dc2c5afb34f83b0395c5806ac20ff7c.tar.gz
rockbox-b5b4a16b6dc2c5afb34f83b0395c5806ac20ff7c.zip
Fix a problem when dithering mono audio. Left samples weren't being duplicated into right channel in pcm buffer.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12509 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/dsp.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/apps/dsp.c b/apps/dsp.c
index 70f1ff46c4..199e24e170 100644
--- a/apps/dsp.c
+++ b/apps/dsp.c
@@ -476,17 +476,16 @@ static void sample_output_dithered(int count, struct dsp_data *data,
476 const int32_t min = data->clip_min; 476 const int32_t min = data->clip_min;
477 const int32_t max = data->clip_max; 477 const int32_t max = data->clip_max;
478 const int32_t range = max - min; 478 const int32_t range = max - min;
479 const int dinc = dsp->data.num_channels;
480
481 int ch; 479 int ch;
482 for (ch = 0; ch < dinc; ch++) 480 int16_t *d;
481
482 for (ch = 0; ch < dsp->data.num_channels; ch++)
483 { 483 {
484 struct dither_data * const dither = &dither_data[ch]; 484 struct dither_data * const dither = &dither_data[ch];
485 int32_t *s = src[ch]; 485 int32_t *s = src[ch];
486 int16_t *d = &dst[ch];
487 int i; 486 int i;
488 487
489 for (i = 0; i < count; i++, s++, d += dinc) 488 for (i = 0, d = &dst[ch]; i < count; i++, s++, d += 2)
490 { 489 {
491 int32_t output, sample; 490 int32_t output, sample;
492 int32_t random; 491 int32_t random;
@@ -530,6 +529,20 @@ static void sample_output_dithered(int count, struct dsp_data *data,
530 *d = output >> scale; 529 *d = output >> scale;
531 } 530 }
532 } 531 }
532
533 if (dsp->data.num_channels == 2)
534 return;
535
536 /* Have to duplicate left samples into the right channel since
537 pcm buffer and hardware is interleaved stereo */
538 d = &dst[0];
539
540 do
541 {
542 int16_t s = *d++;
543 *d++ = s;
544 }
545 while (--count > 0);
533} 546}
534 547
535/** 548/**