comparison src/madplug_x/replaygain.c @ 2362:2b561aa49580

removed unneeded exponential transformation + little out-of-buffer fix
author Eugene Zagidullin <e.asphyx@gmail.com>
date Tue, 05 Feb 2008 09:13:41 +0300
parents c5fa65cb26ca
children 5298b10777b3
comparison
equal deleted inserted replaced
2360:ead24454f4b7 2362:2b561aa49580
51 } 51 }
52 52
53 static gdouble 53 static gdouble
54 strgain2double(gchar * s, int len) 54 strgain2double(gchar * s, int len)
55 { 55 {
56 gchar *strval = g_strndup(s, len);
56 gdouble res = g_strtod(s, NULL); // gain, in dB. 57 gdouble res = g_strtod(s, NULL); // gain, in dB.
57 if (res == 0) 58 g_free(strval);
58 return 1; 59 return res;
59 return pow(10, res / 20);
60 } 60 }
61 61
62 // Reads APE v2.0 tag ending at current pos in fp 62 // Reads APE v2.0 tag ending at current pos in fp
63 63
64 static int 64 static int
134 if (uncase_strcmp(p, "REPLAYGAIN_ALBUM_PEAK") == 0) { 134 if (uncase_strcmp(p, "REPLAYGAIN_ALBUM_PEAK") == 0) {
135 scale = &file_info->replaygain_album_peak; 135 scale = &file_info->replaygain_album_peak;
136 str = &file_info->replaygain_album_peak_str; 136 str = &file_info->replaygain_album_peak_str;
137 } 137 }
138 if (str != NULL) { 138 if (str != NULL) {
139 *scale = g_strtod(p + isize + 1, NULL); 139 *scale = strgain2double(p + isize + 1, vsize);
140 *str = g_strndup(p + isize + 1, vsize); 140 *str = g_strndup(p + isize + 1, vsize);
141 } 141 }
142 142
143 /* mp3gain additional tags : 143 /* mp3gain additional tags :
144 the gain tag translates to scale = 2^(gain/4), 144 the gain tag translates to scale = 2^(gain/4),