summaryrefslogtreecommitdiff
path: root/apps/replaygain.c
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2011-03-31 21:46:09 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2011-03-31 21:46:09 +0000
commit29164ccbccc83a7e5ec335acf5c37fde21649386 (patch)
treedd90c9fc01e40fba1d29b3e22a95a75ec3a75254 /apps/replaygain.c
parent4f7930b883d32cbb8af69a293c96e8bff3ccd916 (diff)
downloadrockbox-29164ccbccc83a7e5ec335acf5c37fde21649386.tar.gz
rockbox-29164ccbccc83a7e5ec335acf5c37fde21649386.zip
Changing convert_gain() also implicitly changed get_replaygain_int() which could lead to div by zero. This patch finds another way to fix the replaygain fallback.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29665 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/replaygain.c')
-rw-r--r--apps/replaygain.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/apps/replaygain.c b/apps/replaygain.c
index 3b47974d58..02be033657 100644
--- a/apps/replaygain.c
+++ b/apps/replaygain.c
@@ -35,6 +35,8 @@
35 35
36#define FP_BITS (12) 36#define FP_BITS (12)
37#define FP_ONE (1 << FP_BITS) 37#define FP_ONE (1 << FP_BITS)
38#define FP_MIN (-48 * FP_ONE)
39#define FP_MAX ( 17 * FP_ONE)
38 40
39void replaygain_itoa(char* buffer, int length, long int_gain) 41void replaygain_itoa(char* buffer, int length, long int_gain)
40{ 42{
@@ -121,10 +123,10 @@ long convert_gain(long gain)
121 /* Don't allow unreasonably low or high gain changes. 123 /* Don't allow unreasonably low or high gain changes.
122 * Our math code can't handle it properly anyway. :) 124 * Our math code can't handle it properly anyway. :)
123 */ 125 */
124 gain = MAX(gain,-48 * FP_ONE); 126 gain = MAX(gain, FP_MIN);
125 gain = MIN(gain, 17 * FP_ONE); 127 gain = MIN(gain, FP_MAX);
126 128
127 return (gain) ? fp_factor(gain, FP_BITS) << (24 - FP_BITS) : 0; 129 return fp_factor(gain, FP_BITS) << (24 - FP_BITS);
128} 130}
129 131
130/* Get the sample scale factor in Q19.12 format from a gain value. Returns 0 132/* Get the sample scale factor in Q19.12 format from a gain value. Returns 0