diff options
author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-04-04 15:21:44 +0000 |
---|---|---|
committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-04-04 15:21:44 +0000 |
commit | d1766a1510b6092fa8ea0e644fdd1c1e508d9c4d (patch) | |
tree | 644a546ce4baf2b4618837d7bc9f774d0c9545ed | |
parent | f0132528fdc3a966e3d5efba0fb720faabca241b (diff) | |
download | rockbox-d1766a1510b6092fa8ea0e644fdd1c1e508d9c4d.tar.gz rockbox-d1766a1510b6092fa8ea0e644fdd1c1e508d9c4d.zip |
Rework parts of the replaygain code to be able to differentiate between 0.00 dB set intentionally and having no replaygain information at all. Bump codec api.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29679 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/codecs.h | 4 | ||||
-rw-r--r-- | apps/dsp.c | 4 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_tokens.c | 4 | ||||
-rw-r--r-- | apps/metadata.h | 2 | ||||
-rw-r--r-- | apps/replaygain.c | 18 | ||||
-rw-r--r-- | apps/replaygain.h | 1 | ||||
-rw-r--r-- | apps/screens.c | 8 |
7 files changed, 23 insertions, 18 deletions
diff --git a/apps/codecs.h b/apps/codecs.h index daf2c8694e..d96b2a7c9a 100644 --- a/apps/codecs.h +++ b/apps/codecs.h | |||
@@ -75,12 +75,12 @@ | |||
75 | #define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ | 75 | #define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ |
76 | 76 | ||
77 | /* increase this every time the api struct changes */ | 77 | /* increase this every time the api struct changes */ |
78 | #define CODEC_API_VERSION 40 | 78 | #define CODEC_API_VERSION 41 |
79 | 79 | ||
80 | /* update this to latest version if a change to the api struct breaks | 80 | /* update this to latest version if a change to the api struct breaks |
81 | backwards compatibility (and please take the opportunity to sort in any | 81 | backwards compatibility (and please take the opportunity to sort in any |
82 | new function which are "waiting" at the end of the function table) */ | 82 | new function which are "waiting" at the end of the function table) */ |
83 | #define CODEC_MIN_API_VERSION 40 | 83 | #define CODEC_MIN_API_VERSION 41 |
84 | 84 | ||
85 | /* codec return codes */ | 85 | /* codec return codes */ |
86 | enum codec_status { | 86 | enum codec_status { |
diff --git a/apps/dsp.c b/apps/dsp.c index 3aab2f2df5..3cff1918d7 100644 --- a/apps/dsp.c +++ b/apps/dsp.c | |||
@@ -1475,12 +1475,12 @@ intptr_t dsp_configure(struct dsp_config *dsp, int setting, intptr_t value) | |||
1475 | 1475 | ||
1476 | case DSP_SET_TRACK_GAIN: | 1476 | case DSP_SET_TRACK_GAIN: |
1477 | if (dsp == &AUDIO_DSP) | 1477 | if (dsp == &AUDIO_DSP) |
1478 | dsp_set_gain_var(&track_gain, value ? convert_gain(value) : 0); | 1478 | dsp_set_gain_var(&track_gain, value); |
1479 | break; | 1479 | break; |
1480 | 1480 | ||
1481 | case DSP_SET_ALBUM_GAIN: | 1481 | case DSP_SET_ALBUM_GAIN: |
1482 | if (dsp == &AUDIO_DSP) | 1482 | if (dsp == &AUDIO_DSP) |
1483 | dsp_set_gain_var(&album_gain, value ? convert_gain(value) : 0); | 1483 | dsp_set_gain_var(&album_gain, value); |
1484 | break; | 1484 | break; |
1485 | 1485 | ||
1486 | case DSP_SET_TRACK_PEAK: | 1486 | case DSP_SET_TRACK_PEAK: |
diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c index a315bae609..3aa7947edc 100644 --- a/apps/gui/skin_engine/skin_tokens.c +++ b/apps/gui/skin_engine/skin_tokens.c | |||
@@ -1332,11 +1332,11 @@ const char *get_token_value(struct gui_wps *gwps, | |||
1332 | /* due to above, coming here with !id3 shouldn't be possible */ | 1332 | /* due to above, coming here with !id3 shouldn't be possible */ |
1333 | case 2: | 1333 | case 2: |
1334 | case 4: | 1334 | case 4: |
1335 | replaygain_itoa(buf, buf_size, id3->track_gain); | 1335 | replaygain_itoa(buf, buf_size, id3->track_level); |
1336 | break; | 1336 | break; |
1337 | case 3: | 1337 | case 3: |
1338 | case 5: | 1338 | case 5: |
1339 | replaygain_itoa(buf, buf_size, id3->album_gain); | 1339 | replaygain_itoa(buf, buf_size, id3->album_level); |
1340 | break; | 1340 | break; |
1341 | } | 1341 | } |
1342 | return buf; | 1342 | return buf; |
diff --git a/apps/metadata.h b/apps/metadata.h index 4c7e94f394..a520f40989 100644 --- a/apps/metadata.h +++ b/apps/metadata.h | |||
@@ -282,6 +282,8 @@ struct mp3entry { | |||
282 | 282 | ||
283 | /* replaygain support */ | 283 | /* replaygain support */ |
284 | #if CONFIG_CODEC == SWCODEC | 284 | #if CONFIG_CODEC == SWCODEC |
285 | long track_level; /* holds the level in dB * (1<<FP_BITS) */ | ||
286 | long album_level; | ||
285 | long track_gain; /* s19.12 signed fixed point. 0 for no gain. */ | 287 | long track_gain; /* s19.12 signed fixed point. 0 for no gain. */ |
286 | long album_gain; | 288 | long album_gain; |
287 | long track_peak; /* s19.12 signed fixed point. 0 for no peak. */ | 289 | long track_peak; /* s19.12 signed fixed point. 0 for no peak. */ |
diff --git a/apps/replaygain.c b/apps/replaygain.c index 7875e06e72..5eb745a5f1 100644 --- a/apps/replaygain.c +++ b/apps/replaygain.c | |||
@@ -118,7 +118,7 @@ static long fp_atof(const char* s, int precision) | |||
118 | + (((int64_t) frac_part * int_one) / frac_max_int)); | 118 | + (((int64_t) frac_part * int_one) / frac_max_int)); |
119 | } | 119 | } |
120 | 120 | ||
121 | long convert_gain(long gain) | 121 | static long convert_gain(long gain) |
122 | { | 122 | { |
123 | /* Don't allow unreasonably low or high gain changes. | 123 | /* Don't allow unreasonably low or high gain changes. |
124 | * Our math code can't handle it properly anyway. :) */ | 124 | * Our math code can't handle it properly anyway. :) */ |
@@ -171,13 +171,15 @@ void parse_replaygain(const char* key, const char* value, | |||
171 | (strcasecmp(key, "rg_radio") == 0)) && | 171 | (strcasecmp(key, "rg_radio") == 0)) && |
172 | !entry->track_gain) | 172 | !entry->track_gain) |
173 | { | 173 | { |
174 | entry->track_gain = get_replaygain(value); | 174 | entry->track_level = get_replaygain(value); |
175 | entry->track_gain = convert_gain(entry->track_level); | ||
175 | } | 176 | } |
176 | else if (((strcasecmp(key, "replaygain_album_gain") == 0) || | 177 | else if (((strcasecmp(key, "replaygain_album_gain") == 0) || |
177 | (strcasecmp(key, "rg_audiophile") == 0)) && | 178 | (strcasecmp(key, "rg_audiophile") == 0)) && |
178 | !entry->album_gain) | 179 | !entry->album_gain) |
179 | { | 180 | { |
180 | entry->album_gain = get_replaygain(value); | 181 | entry->album_level = get_replaygain(value); |
182 | entry->album_gain = convert_gain(entry->album_level); | ||
181 | } | 183 | } |
182 | else if (((strcasecmp(key, "replaygain_track_peak") == 0) || | 184 | else if (((strcasecmp(key, "replaygain_track_peak") == 0) || |
183 | (strcasecmp(key, "rg_peak") == 0)) && | 185 | (strcasecmp(key, "rg_peak") == 0)) && |
@@ -207,12 +209,14 @@ void parse_replaygain_int(bool album, long gain, long peak, | |||
207 | 209 | ||
208 | if (album) | 210 | if (album) |
209 | { | 211 | { |
210 | entry->album_gain = gain; | 212 | entry->album_level = gain; |
211 | entry->album_peak = peak; | 213 | entry->album_gain = convert_gain(gain); |
214 | entry->album_peak = peak; | ||
212 | } | 215 | } |
213 | else | 216 | else |
214 | { | 217 | { |
215 | entry->track_gain = gain; | 218 | entry->track_level = gain; |
216 | entry->track_peak = peak; | 219 | entry->track_gain = convert_gain(gain); |
220 | entry->track_peak = peak; | ||
217 | } | 221 | } |
218 | } | 222 | } |
diff --git a/apps/replaygain.h b/apps/replaygain.h index 4fb5476e23..215464dfdf 100644 --- a/apps/replaygain.h +++ b/apps/replaygain.h | |||
@@ -30,6 +30,5 @@ void parse_replaygain(const char* key, const char* value, | |||
30 | void parse_replaygain_int(bool album, long gain, long peak, | 30 | void parse_replaygain_int(bool album, long gain, long peak, |
31 | struct mp3entry* entry); | 31 | struct mp3entry* entry); |
32 | void replaygain_itoa(char* buffer, int length, long int_gain); | 32 | void replaygain_itoa(char* buffer, int length, long int_gain); |
33 | long convert_gain(long gain); | ||
34 | 33 | ||
35 | #endif | 34 | #endif |
diff --git a/apps/screens.c b/apps/screens.c index b1a48c5bd6..6c70477fbd 100644 --- a/apps/screens.c +++ b/apps/screens.c | |||
@@ -729,12 +729,12 @@ static const char* id3_get_info(int selected_item, void* data, | |||
729 | break; | 729 | break; |
730 | #if CONFIG_CODEC == SWCODEC | 730 | #if CONFIG_CODEC == SWCODEC |
731 | case LANG_ID3_TRACK_GAIN: | 731 | case LANG_ID3_TRACK_GAIN: |
732 | replaygain_itoa(buffer, buffer_len, id3->track_gain); | 732 | replaygain_itoa(buffer, buffer_len, id3->track_level); |
733 | val=(id3->track_gain) ? buffer : NULL; /* only show gains!=0 */ | 733 | val=(id3->track_level) ? buffer : NULL; /* only show level!=0 */ |
734 | break; | 734 | break; |
735 | case LANG_ID3_ALBUM_GAIN: | 735 | case LANG_ID3_ALBUM_GAIN: |
736 | replaygain_itoa(buffer, buffer_len, id3->album_gain); | 736 | replaygain_itoa(buffer, buffer_len, id3->album_level); |
737 | val=(id3->album_gain) ? buffer : NULL; /* only show gains!=0 */ | 737 | val=(id3->album_level) ? buffer : NULL; /* only show level!=0 */ |
738 | break; | 738 | break; |
739 | #endif | 739 | #endif |
740 | case LANG_ID3_PATH: | 740 | case LANG_ID3_PATH: |