diff options
Diffstat (limited to 'firmware/replaygain.c')
-rw-r--r-- | firmware/replaygain.c | 34 |
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 | ||
289 | static long convert_gain(long gain) | 289 | static 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 | ||
312 | long get_replaygain_int(long int_gain) | 309 | long 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 | ||
324 | long get_replaygain(const char* str) | 314 | long get_replaygain(const char* str) |