diff options
author | Sean Bartell <wingedtachikoma@gmail.com> | 2011-06-24 01:25:21 -0400 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2012-03-18 12:00:39 +0100 |
commit | b5716df4cb2837bbbc42195cf1aefcf03e21d6a6 (patch) | |
tree | 130cd712e2e00893b6df9959a375a8d9523a1aca /lib/rbcodec/metadata/sid.c | |
parent | 24bd9d5393dbe39a5c6194877bc00ede669b1d5d (diff) | |
download | rockbox-b5716df4cb2837bbbc42195cf1aefcf03e21d6a6.tar.gz rockbox-b5716df4cb2837bbbc42195cf1aefcf03e21d6a6.zip |
Build librbcodec with DSP and metadata.
All associated files are moved to /lib/rbcodec.
Change-Id: I572ddd2b8a996aae1e98c081d06b1ed356dce222
Diffstat (limited to 'lib/rbcodec/metadata/sid.c')
-rw-r--r-- | lib/rbcodec/metadata/sid.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/lib/rbcodec/metadata/sid.c b/lib/rbcodec/metadata/sid.c new file mode 100644 index 0000000000..50b879b56d --- /dev/null +++ b/lib/rbcodec/metadata/sid.c | |||
@@ -0,0 +1,89 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2005 Dave Chapman | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include <stdio.h> | ||
22 | #include <string.h> | ||
23 | #include <stdlib.h> | ||
24 | #include <ctype.h> | ||
25 | #include <inttypes.h> | ||
26 | |||
27 | #include "system.h" | ||
28 | #include "metadata.h" | ||
29 | #include "metadata_common.h" | ||
30 | #include "metadata_parsers.h" | ||
31 | #include "rbunicode.h" | ||
32 | |||
33 | /* PSID metadata info is available here: | ||
34 | http://www.unusedino.de/ec64/technical/formats/sidplay.html */ | ||
35 | bool get_sid_metadata(int fd, struct mp3entry* id3) | ||
36 | { | ||
37 | /* Use the trackname part of the id3 structure as a temporary buffer */ | ||
38 | unsigned char* buf = (unsigned char *)id3->path; | ||
39 | char *p; | ||
40 | |||
41 | |||
42 | if ((lseek(fd, 0, SEEK_SET) < 0) | ||
43 | || (read(fd, buf, 0x80) < 0x80)) | ||
44 | { | ||
45 | return false; | ||
46 | } | ||
47 | |||
48 | if ((memcmp(buf, "PSID", 4) != 0)) | ||
49 | { | ||
50 | return false; | ||
51 | } | ||
52 | |||
53 | p = id3->id3v2buf; | ||
54 | |||
55 | /* Copy Title (assumed max 0x1f letters + 1 zero byte) */ | ||
56 | id3->title = p; | ||
57 | buf[0x16+0x1f] = 0; | ||
58 | p = iso_decode(&buf[0x16], p, 0, strlen(&buf[0x16])+1); | ||
59 | |||
60 | /* Copy Artist (assumed max 0x1f letters + 1 zero byte) */ | ||
61 | id3->artist = p; | ||
62 | buf[0x36+0x1f] = 0; | ||
63 | p = iso_decode(&buf[0x36], p, 0, strlen(&buf[0x36])+1); | ||
64 | |||
65 | /* Copy Year (assumed max 4 letters + 1 zero byte) */ | ||
66 | buf[0x56+0x4] = 0; | ||
67 | id3->year = atoi(&buf[0x56]); | ||
68 | |||
69 | /* Copy Album (assumed max 0x1f-0x05 letters + 1 zero byte) */ | ||
70 | id3->album = p; | ||
71 | buf[0x56+0x1f] = 0; | ||
72 | iso_decode(&buf[0x5b], p, 0, strlen(&buf[0x5b])+1); | ||
73 | |||
74 | id3->bitrate = 706; | ||
75 | id3->frequency = 44100; | ||
76 | /* New idea as posted by Marco Alanen (ravon): | ||
77 | * Set the songlength in seconds to the number of subsongs | ||
78 | * so every second represents a subsong. | ||
79 | * Users can then skip the current subsong by seeking | ||
80 | * | ||
81 | * Note: the number of songs is a 16bit value at 0xE, so this code only | ||
82 | * uses the lower 8 bits of the counter. | ||
83 | */ | ||
84 | id3->length = (buf[0xf]-1)*1000; | ||
85 | id3->vbr = false; | ||
86 | id3->filesize = filesize(fd); | ||
87 | |||
88 | return true; | ||
89 | } | ||