summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom Johansen <thomj@rockbox.org>2007-02-23 12:22:17 +0000
committerThom Johansen <thomj@rockbox.org>2007-02-23 12:22:17 +0000
commitaf743c2bd6b0752538d2995acb89c0012bfe5753 (patch)
treeb5f51c86575ac82c9a6c8f3bfb9c5e1766c1ec4b
parentc5df4f844e552b6373d320b7d5d3f5901297de6e (diff)
downloadrockbox-af743c2bd6b0752538d2995acb89c0012bfe5753.tar.gz
rockbox-af743c2bd6b0752538d2995acb89c0012bfe5753.zip
Remove unneeded zero checks from convert_gain() and get_replaygain_int(). These functions return correct results without them.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12459 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/replaygain.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/firmware/replaygain.c b/firmware/replaygain.c
index b7cde7f005..c934586f4b 100644
--- a/firmware/replaygain.c
+++ b/firmware/replaygain.c
@@ -288,37 +288,27 @@ static long fp_atof(const char* s, int precision)
288 288
289static long convert_gain(long gain) 289static long convert_gain(long gain)
290{ 290{
291 if (gain != 0) 291 /* Don't allow unreasonably low or high gain changes.
292 * Our math code can't handle it properly anyway. :)
293 */
294 if (gain < (-48 * FP_ONE))
292 { 295 {
293 /* Don't allow unreasonably low or high gain changes. 296 gain = -48 * FP_ONE;
294 * Our math code can't handle it properly anyway. :) 297 }
295 */
296 if (gain < (-48 * FP_ONE))
297 {
298 gain = -48 * FP_ONE;
299 }
300
301 if (gain > (17 * FP_ONE))
302 {
303 gain = 17 * FP_ONE;
304 }
305 298
306 gain = fp_exp10(gain / 20) << (24 - FP_BITS); 299 if (gain > (17 * FP_ONE))
300 {
301 gain = 17 * FP_ONE;
307 } 302 }
308 303
304 gain = fp_exp10(gain / 20) << (24 - FP_BITS);
305
309 return gain; 306 return gain;
310} 307}
311 308
312long get_replaygain_int(long int_gain) 309long get_replaygain_int(long int_gain)
313{ 310{
314 long gain = 0; 311 return convert_gain(int_gain * FP_ONE / 100);
315
316 if (int_gain)
317 {
318 gain = convert_gain(int_gain * FP_ONE / 100);
319 }
320
321 return gain;
322} 312}
323 313
324long get_replaygain(const char* str) 314long get_replaygain(const char* str)