diff options
author | Jens Arnold <amiconn@rockbox.org> | 2006-03-26 17:41:36 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2006-03-26 17:41:36 +0000 |
commit | 8083e8c0de4d03985afe72f83bd9c76ce715ce41 (patch) | |
tree | 5ba6353ce6476919b0e1ab9434be8622d865d3c7 /apps | |
parent | d9ef5980df35fa4c7dc60fddf781cd71463c9746 (diff) | |
download | rockbox-8083e8c0de4d03985afe72f83bd9c76ce715ce41.tar.gz rockbox-8083e8c0de4d03985afe72f83bd9c76ce715ce41.zip |
Fixed potential sample overflow in variable stereo width > 100% and karaoke mode, both hwcodec and swcodec.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9263 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dsp.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/apps/dsp.c b/apps/dsp.c index 1f477d3f70..e5696bc7cd 100644 --- a/apps/dsp.c +++ b/apps/dsp.c | |||
@@ -706,13 +706,14 @@ void stereo_width_set(int value) | |||
706 | { | 706 | { |
707 | long width, straight, cross; | 707 | long width, straight, cross; |
708 | 708 | ||
709 | width = value*0x7fffff/100; | 709 | width = value * 0x7fffff / 100; |
710 | if (value <= 100) { | 710 | if (value <= 100) { |
711 | straight = (0x7fffff + width)/2; | 711 | straight = (0x7fffff + width) / 2; |
712 | cross = straight - width; | 712 | cross = straight - width; |
713 | } else { | 713 | } else { |
714 | straight = 0x7fffff; | 714 | /* straight = (1 + width) / (2 * width) */ |
715 | cross = 0x7fffff - ((int64_t)(2*width) << 23)/(0x7fffff + width); | 715 | straight = ((int64_t)(0x7fffff + width) << 22) / width; |
716 | cross = straight - 0x7fffff; | ||
716 | } | 717 | } |
717 | sw_gain = straight << 8; | 718 | sw_gain = straight << 8; |
718 | sw_cross = cross << 8; | 719 | sw_cross = cross << 8; |
@@ -752,10 +753,10 @@ static void channels_process(int32_t **src, int num) | |||
752 | break; | 753 | break; |
753 | case SOUND_CHAN_KARAOKE: | 754 | case SOUND_CHAN_KARAOKE: |
754 | for (i = 0; i < num; i++) { | 755 | for (i = 0; i < num; i++) { |
755 | int32_t left_sample = sl[i]; | 756 | int32_t left_sample = sl[i]/2; |
756 | 757 | ||
757 | sl[i] -= sr[i]; | 758 | sl[i] = left_sample - sr[i]/2; |
758 | sr[i] -= left_sample; | 759 | sr[i] = sr[i]/2 - left_sample; |
759 | } | 760 | } |
760 | break; | 761 | break; |
761 | } | 762 | } |