diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-09-26 17:19:07 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-10-09 11:39:25 -0400 |
commit | 4231c2c83f2b5331e3e38b10a308ee3752315f9c (patch) | |
tree | 1e14867e9c9f0d7b778e7c4c18103a7cbd491794 /lib/rbcodec/metadata/metadata.c | |
parent | 278522f8118bd2cfce065ec95f0a93ca53e3ca44 (diff) | |
download | rockbox-4231c2c83f2b5331e3e38b10a308ee3752315f9c.tar.gz rockbox-4231c2c83f2b5331e3e38b10a308ee3752315f9c.zip |
codecs: Add support for the 'VTX' ZX Spectrum chiptunes format.
This codec requires floating point.
Original author: Peter Sovietov
Ported to Rockbox: Roman Skylarov
Further integration and bugfixes: Solomon Peachy
Change-Id: I781ecd3592dfcdbbc694063334350342534f1d6c
Diffstat (limited to 'lib/rbcodec/metadata/metadata.c')
-rw-r--r-- | lib/rbcodec/metadata/metadata.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/lib/rbcodec/metadata/metadata.c b/lib/rbcodec/metadata/metadata.c index 9c41347975..aec72db97f 100644 --- a/lib/rbcodec/metadata/metadata.c +++ b/lib/rbcodec/metadata/metadata.c | |||
@@ -43,7 +43,7 @@ static bool get_shn_metadata(int fd, struct mp3entry *id3) | |||
43 | } | 43 | } |
44 | 44 | ||
45 | static bool get_other_asap_metadata(int fd, struct mp3entry *id3) | 45 | static bool get_other_asap_metadata(int fd, struct mp3entry *id3) |
46 | { | 46 | { |
47 | id3->bitrate = 706; | 47 | id3->bitrate = 706; |
48 | id3->frequency = 44100; | 48 | id3->frequency = 44100; |
49 | id3->vbr = false; | 49 | id3->vbr = false; |
@@ -85,7 +85,7 @@ const struct afmt_entry audio_formats[AFMT_NUM_CODECS] = | |||
85 | /* Musepack SV7 */ | 85 | /* Musepack SV7 */ |
86 | [AFMT_MPC_SV7] = | 86 | [AFMT_MPC_SV7] = |
87 | AFMT_ENTRY("MPCv7", "mpc", NULL, get_musepack_metadata,"mpc\0"), | 87 | AFMT_ENTRY("MPCv7", "mpc", NULL, get_musepack_metadata,"mpc\0"), |
88 | /* A/52 (aka AC3) audio */ | 88 | /* A/52 (aka AC3) audio */ |
89 | [AFMT_A52] = | 89 | [AFMT_A52] = |
90 | AFMT_ENTRY("AC3", "a52", NULL, get_a52_metadata, "a52\0ac3\0"), | 90 | AFMT_ENTRY("AC3", "a52", NULL, get_a52_metadata, "a52\0ac3\0"), |
91 | /* WavPack */ | 91 | /* WavPack */ |
@@ -109,7 +109,7 @@ const struct afmt_entry audio_formats[AFMT_NUM_CODECS] = | |||
109 | /* NESM (NES Sound Format) */ | 109 | /* NESM (NES Sound Format) */ |
110 | [AFMT_NSF] = | 110 | [AFMT_NSF] = |
111 | AFMT_ENTRY("NSF", "nsf", NULL, get_nsf_metadata, "nsf\0nsfe\0"), | 111 | AFMT_ENTRY("NSF", "nsf", NULL, get_nsf_metadata, "nsf\0nsfe\0"), |
112 | /* Speex File Format */ | 112 | /* Speex File Format */ |
113 | [AFMT_SPEEX] = | 113 | [AFMT_SPEEX] = |
114 | AFMT_ENTRY("Speex", "speex",NULL, get_ogg_metadata, "spx\0"), | 114 | AFMT_ENTRY("Speex", "speex",NULL, get_ogg_metadata, "spx\0"), |
115 | /* SPC700 Save State */ | 115 | /* SPC700 Save State */ |
@@ -162,12 +162,12 @@ const struct afmt_entry audio_formats[AFMT_NUM_CODECS] = | |||
162 | AFMT_ENTRY("DLT", "asap", NULL, get_other_asap_metadata,"dlt\0"), | 162 | AFMT_ENTRY("DLT", "asap", NULL, get_other_asap_metadata,"dlt\0"), |
163 | /* Atari MPT File */ | 163 | /* Atari MPT File */ |
164 | [AFMT_MPT] = | 164 | [AFMT_MPT] = |
165 | AFMT_ENTRY("MPT", "asap", NULL, get_other_asap_metadata,"mpt\0"), | 165 | AFMT_ENTRY("MPT", "asap", NULL, get_other_asap_metadata,"mpt\0"), |
166 | /* Atari MPD File */ | 166 | /* Atari MPD File */ |
167 | [AFMT_MPD] = | 167 | [AFMT_MPD] = |
168 | AFMT_ENTRY("MPD", "asap", NULL, get_other_asap_metadata,"mpd\0"), | 168 | AFMT_ENTRY("MPD", "asap", NULL, get_other_asap_metadata,"mpd\0"), |
169 | /* Atari RMT File */ | 169 | /* Atari RMT File */ |
170 | [AFMT_RMT] = | 170 | [AFMT_RMT] = |
171 | AFMT_ENTRY("RMT", "asap", NULL, get_other_asap_metadata,"rmt\0"), | 171 | AFMT_ENTRY("RMT", "asap", NULL, get_other_asap_metadata,"rmt\0"), |
172 | /* Atari TMC File */ | 172 | /* Atari TMC File */ |
173 | [AFMT_TMC] = | 173 | [AFMT_TMC] = |
@@ -177,10 +177,10 @@ const struct afmt_entry audio_formats[AFMT_NUM_CODECS] = | |||
177 | AFMT_ENTRY("TM8", "asap", NULL, get_other_asap_metadata,"tm8\0"), | 177 | AFMT_ENTRY("TM8", "asap", NULL, get_other_asap_metadata,"tm8\0"), |
178 | /* Atari TM2 File */ | 178 | /* Atari TM2 File */ |
179 | [AFMT_TM2] = | 179 | [AFMT_TM2] = |
180 | AFMT_ENTRY("TM2", "asap", NULL, get_other_asap_metadata,"tm2\0"), | 180 | AFMT_ENTRY("TM2", "asap", NULL, get_other_asap_metadata,"tm2\0"), |
181 | /* Atrac3 in Sony OMA Container */ | 181 | /* Atrac3 in Sony OMA Container */ |
182 | [AFMT_OMA_ATRAC3] = | 182 | [AFMT_OMA_ATRAC3] = |
183 | AFMT_ENTRY("ATRAC3","atrac3_oma",NULL, get_oma_metadata, "oma\0aa3\0"), | 183 | AFMT_ENTRY("ATRAC3","atrac3_oma",NULL, get_oma_metadata, "oma\0aa3\0"), |
184 | /* SMAF (Synthetic music Mobile Application Format) */ | 184 | /* SMAF (Synthetic music Mobile Application Format) */ |
185 | [AFMT_SMAF] = | 185 | [AFMT_SMAF] = |
186 | AFMT_ENTRY("SMAF", "smaf", NULL, get_smaf_metadata, "mmf\0"), | 186 | AFMT_ENTRY("SMAF", "smaf", NULL, get_smaf_metadata, "mmf\0"), |
@@ -194,7 +194,7 @@ const struct afmt_entry audio_formats[AFMT_NUM_CODECS] = | |||
194 | [AFMT_WAVE64] = | 194 | [AFMT_WAVE64] = |
195 | AFMT_ENTRY("WAVE64","wav64",NULL, get_wave64_metadata,"w64\0"), | 195 | AFMT_ENTRY("WAVE64","wav64",NULL, get_wave64_metadata,"w64\0"), |
196 | /* True Audio */ | 196 | /* True Audio */ |
197 | [AFMT_TTA] = | 197 | [AFMT_TTA] = |
198 | AFMT_ENTRY("TTA", "tta", NULL, get_tta_metadata, "tta\0"), | 198 | AFMT_ENTRY("TTA", "tta", NULL, get_tta_metadata, "tta\0"), |
199 | /* WMA Voice in ASF */ | 199 | /* WMA Voice in ASF */ |
200 | [AFMT_WMAVOICE] = | 200 | [AFMT_WMAVOICE] = |
@@ -206,8 +206,13 @@ const struct afmt_entry audio_formats[AFMT_NUM_CODECS] = | |||
206 | [AFMT_MP4_AAC_HE] = | 206 | [AFMT_MP4_AAC_HE] = |
207 | AFMT_ENTRY("AAC-HE","aac", NULL, get_mp4_metadata, "mp4\0"), | 207 | AFMT_ENTRY("AAC-HE","aac", NULL, get_mp4_metadata, "mp4\0"), |
208 | /* AY (ZX Spectrum, Amstrad CPC Sound Format) */ | 208 | /* AY (ZX Spectrum, Amstrad CPC Sound Format) */ |
209 | [AFMT_AY] = | 209 | [AFMT_AY] = |
210 | AFMT_ENTRY("AY", "ay", NULL, get_ay_metadata, "ay\0"), | 210 | AFMT_ENTRY("AY", "ay", NULL, get_ay_metadata, "ay\0"), |
211 | /* AY (ZX Spectrum Sound Format) */ | ||
212 | #ifdef HAVE_FPU | ||
213 | [AFMT_VTX] = | ||
214 | AFMT_ENTRY("VTX", "vtx", NULL, get_vtx_metadata, "vtx\0"), | ||
215 | #endif | ||
211 | /* GBS (Game Boy Sound Format) */ | 216 | /* GBS (Game Boy Sound Format) */ |
212 | [AFMT_GBS] = | 217 | [AFMT_GBS] = |
213 | AFMT_ENTRY("GBS", "gbs", NULL, get_gbs_metadata, "gbs\0"), | 218 | AFMT_ENTRY("GBS", "gbs", NULL, get_gbs_metadata, "gbs\0"), |
@@ -313,6 +318,9 @@ bool rbcodec_format_is_atomic(int afmt) | |||
313 | case AFMT_MOD: | 318 | case AFMT_MOD: |
314 | case AFMT_SAP: | 319 | case AFMT_SAP: |
315 | case AFMT_AY: | 320 | case AFMT_AY: |
321 | #ifdef HAVE_FPU | ||
322 | case AFMT_VTX: | ||
323 | #endif | ||
316 | case AFMT_GBS: | 324 | case AFMT_GBS: |
317 | case AFMT_HES: | 325 | case AFMT_HES: |
318 | case AFMT_SGC: | 326 | case AFMT_SGC: |
@@ -352,17 +360,17 @@ unsigned int probe_file_format(const char *filename) | |||
352 | { | 360 | { |
353 | char *suffix; | 361 | char *suffix; |
354 | unsigned int i; | 362 | unsigned int i; |
355 | 363 | ||
356 | suffix = strrchr(filename, '.'); | 364 | suffix = strrchr(filename, '.'); |
357 | 365 | ||
358 | if (suffix == NULL) | 366 | if (suffix == NULL) |
359 | { | 367 | { |
360 | return AFMT_UNKNOWN; | 368 | return AFMT_UNKNOWN; |
361 | } | 369 | } |
362 | 370 | ||
363 | /* skip '.' */ | 371 | /* skip '.' */ |
364 | suffix++; | 372 | suffix++; |
365 | 373 | ||
366 | for (i = 1; i < AFMT_NUM_CODECS; i++) | 374 | for (i = 1; i < AFMT_NUM_CODECS; i++) |
367 | { | 375 | { |
368 | /* search extension list for type */ | 376 | /* search extension list for type */ |
@@ -379,7 +387,7 @@ unsigned int probe_file_format(const char *filename) | |||
379 | } | 387 | } |
380 | while (*ext != '\0'); | 388 | while (*ext != '\0'); |
381 | } | 389 | } |
382 | 390 | ||
383 | return AFMT_UNKNOWN; | 391 | return AFMT_UNKNOWN; |
384 | } | 392 | } |
385 | 393 | ||
@@ -418,7 +426,7 @@ bool get_metadata(struct mp3entry* id3, int fd, const char* trackname) | |||
418 | close(logfd); | 426 | close(logfd); |
419 | } | 427 | } |
420 | } | 428 | } |
421 | 429 | ||
422 | /* Clear the mp3entry to avoid having bogus pointers appear */ | 430 | /* Clear the mp3entry to avoid having bogus pointers appear */ |
423 | wipe_mp3entry(id3); | 431 | wipe_mp3entry(id3); |
424 | 432 | ||
@@ -454,7 +462,7 @@ bool get_metadata(struct mp3entry* id3, int fd, const char* trackname) | |||
454 | void strip_tags(int handle_id) | 462 | void strip_tags(int handle_id) |
455 | { | 463 | { |
456 | static const unsigned char tag[] = "TAG"; | 464 | static const unsigned char tag[] = "TAG"; |
457 | static const unsigned char apetag[] = "APETAGEX"; | 465 | static const unsigned char apetag[] = "APETAGEX"; |
458 | size_t len, version; | 466 | size_t len, version; |
459 | void *tail; | 467 | void *tail; |
460 | 468 | ||
@@ -502,7 +510,7 @@ void adjust_mp3entry(struct mp3entry *entry, void *dest, const void *orig) | |||
502 | MOVE_ENTRY(entry->artist) | 510 | MOVE_ENTRY(entry->artist) |
503 | MOVE_ENTRY(entry->album) | 511 | MOVE_ENTRY(entry->album) |
504 | 512 | ||
505 | if (entry->genre_string > (char*)orig && | 513 | if (entry->genre_string > (char*)orig && |
506 | entry->genre_string < (char*)orig + sizeof(struct mp3entry)) | 514 | entry->genre_string < (char*)orig + sizeof(struct mp3entry)) |
507 | /* Don't adjust that if it points to an entry of the "genres" array */ | 515 | /* Don't adjust that if it points to an entry of the "genres" array */ |
508 | entry->genre_string += offset; | 516 | entry->genre_string += offset; |