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
This commit is contained in:
parent
d9ef5980df
commit
8083e8c0de
2 changed files with 17 additions and 16 deletions
15
apps/dsp.c
15
apps/dsp.c
|
@ -706,13 +706,14 @@ void stereo_width_set(int value)
|
|||
{
|
||||
long width, straight, cross;
|
||||
|
||||
width = value*0x7fffff/100;
|
||||
width = value * 0x7fffff / 100;
|
||||
if (value <= 100) {
|
||||
straight = (0x7fffff + width)/2;
|
||||
straight = (0x7fffff + width) / 2;
|
||||
cross = straight - width;
|
||||
} else {
|
||||
straight = 0x7fffff;
|
||||
cross = 0x7fffff - ((int64_t)(2*width) << 23)/(0x7fffff + width);
|
||||
/* straight = (1 + width) / (2 * width) */
|
||||
straight = ((int64_t)(0x7fffff + width) << 22) / width;
|
||||
cross = straight - 0x7fffff;
|
||||
}
|
||||
sw_gain = straight << 8;
|
||||
sw_cross = cross << 8;
|
||||
|
@ -752,10 +753,10 @@ static void channels_process(int32_t **src, int num)
|
|||
break;
|
||||
case SOUND_CHAN_KARAOKE:
|
||||
for (i = 0; i < num; i++) {
|
||||
int32_t left_sample = sl[i];
|
||||
int32_t left_sample = sl[i]/2;
|
||||
|
||||
sl[i] -= sr[i];
|
||||
sr[i] -= left_sample;
|
||||
sl[i] = left_sample - sr[i]/2;
|
||||
sr[i] = sr[i]/2 - left_sample;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -504,12 +504,12 @@ static void set_channel_config(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
fp_straight = - (1<<19);
|
||||
fp_cross = ((2 * fp_width / (((1<<19) + fp_width) >> 10))
|
||||
<< 9) - (1<<19);
|
||||
/* straight = - (1 + width) / (2 * width) */
|
||||
fp_straight = - ((((1<<19) + fp_width) / (fp_width >> 9)) << 9);
|
||||
fp_cross = (1<<19) + fp_straight;
|
||||
}
|
||||
val_ll = val_rr = fp_straight & 0xFFFFF;
|
||||
val_lr = val_rl = fp_cross & 0xFFFFF;
|
||||
val_ll = val_rr = fp_straight & 0xfffff;
|
||||
val_lr = val_rl = fp_cross & 0xfffff;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -528,10 +528,10 @@ static void set_channel_config(void)
|
|||
break;
|
||||
|
||||
case SOUND_CHAN_KARAOKE:
|
||||
val_ll = 0x80001;
|
||||
val_lr = 0x7ffff;
|
||||
val_rl = 0x7ffff;
|
||||
val_rr = 0x80001;
|
||||
val_ll = 0xc0000;
|
||||
val_lr = 0x40000;
|
||||
val_rl = 0x40000;
|
||||
val_rr = 0xc0000;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue