diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-12-19 12:32:34 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-12-19 12:32:34 +0000 |
commit | c21fafc7b640836719597b425a7e598524137575 (patch) | |
tree | 0a397cf1b7ca5181dd14bf07f61ef9385051a5b3 | |
parent | fe641c0d363f2bcb75cef8d7b67e44f4d972ba47 (diff) | |
download | libextractor-c21fafc7b640836719597b425a7e598524137575.tar.gz libextractor-c21fafc7b640836719597b425a7e598524137575.zip |
sid
-rw-r--r-- | src/include/extractor.h | 4 | ||||
-rw-r--r-- | src/main/extractor_metatypes.c | 14 | ||||
-rw-r--r-- | src/plugins/Makefile.am | 14 | ||||
-rw-r--r-- | src/plugins/sid_extractor.c (renamed from src/plugins/sidextractor.c) | 149 |
4 files changed, 73 insertions, 108 deletions
diff --git a/src/include/extractor.h b/src/include/extractor.h index 960c13a..e826b8d 100644 --- a/src/include/extractor.h +++ b/src/include/extractor.h | |||
@@ -283,6 +283,8 @@ enum EXTRACTOR_MetaType | |||
283 | EXTRACTOR_METATYPE_TV_NETWORK_NAME = 151, | 283 | EXTRACTOR_METATYPE_TV_NETWORK_NAME = 151, |
284 | EXTRACTOR_METATYPE_TV_SHOW_NAME = 152, | 284 | EXTRACTOR_METATYPE_TV_SHOW_NAME = 152, |
285 | EXTRACTOR_METATYPE_CHAPTER_NAME = 153, | 285 | EXTRACTOR_METATYPE_CHAPTER_NAME = 153, |
286 | EXTRACTOR_METATYPE_SONG_COUNT = 154, | ||
287 | EXTRACTOR_METATYPE_STARTING_SONG = 155, | ||
286 | 288 | ||
287 | /* fixme: used up to here! */ | 289 | /* fixme: used up to here! */ |
288 | 290 | ||
@@ -290,8 +292,6 @@ enum EXTRACTOR_MetaType | |||
290 | EXTRACTOR_METATYPE_CONDUCTOR = 64, | 292 | EXTRACTOR_METATYPE_CONDUCTOR = 64, |
291 | EXTRACTOR_METATYPE_INTERPRET = 65, | 293 | EXTRACTOR_METATYPE_INTERPRET = 65, |
292 | EXTRACTOR_METATYPE_MUSIC_CD_IDENTIFIER = 117, | 294 | EXTRACTOR_METATYPE_MUSIC_CD_IDENTIFIER = 117, |
293 | EXTRACTOR_METATYPE_SONG_COUNT = 127, | ||
294 | EXTRACTOR_METATYPE_STARTING_SONG = 128, | ||
295 | EXTRACTOR_METATYPE_MUSICIAN_CREDITS_LIST = 123, | 295 | EXTRACTOR_METATYPE_MUSICIAN_CREDITS_LIST = 123, |
296 | 296 | ||
297 | 297 | ||
diff --git a/src/main/extractor_metatypes.c b/src/main/extractor_metatypes.c index 2864488..158d3a2 100644 --- a/src/main/extractor_metatypes.c +++ b/src/main/extractor_metatypes.c | |||
@@ -217,7 +217,7 @@ static const struct MetaTypeDescription meta_type_descriptions[] = { | |||
217 | { gettext_noop ("is essential"), | 217 | { gettext_noop ("is essential"), |
218 | gettext_noop ("package is marked as essential") }, | 218 | gettext_noop ("package is marked as essential") }, |
219 | { gettext_noop ("target architecture"), | 219 | { gettext_noop ("target architecture"), |
220 | gettext_noop ("hardware architecture the package can be used for") }, | 220 | gettext_noop ("hardware architecture the contents can be used for") }, |
221 | { gettext_noop ("pre-dependency"), | 221 | { gettext_noop ("pre-dependency"), |
222 | gettext_noop ("dependency that must be satisfied before installation") }, | 222 | gettext_noop ("dependency that must be satisfied before installation") }, |
223 | /* 85 */ | 223 | /* 85 */ |
@@ -375,6 +375,17 @@ static const struct MetaTypeDescription meta_type_descriptions[] = { | |||
375 | gettext_noop ("name of the TV show") }, | 375 | gettext_noop ("name of the TV show") }, |
376 | { gettext_noop ("chapter name"), | 376 | { gettext_noop ("chapter name"), |
377 | gettext_noop ("name of the chapter") }, | 377 | gettext_noop ("name of the chapter") }, |
378 | { gettext_noop ("song count"), | ||
379 | gettext_noop ("number of songs") }, | ||
380 | /* 155 */ | ||
381 | { gettext_noop ("starting song"), | ||
382 | gettext_noop ("number of the first song to play") }, | ||
383 | { gettext_noop (""), | ||
384 | gettext_noop ("") }, | ||
385 | { gettext_noop (""), | ||
386 | gettext_noop ("") }, | ||
387 | { gettext_noop (""), | ||
388 | gettext_noop ("") }, | ||
378 | { gettext_noop (""), | 389 | { gettext_noop (""), |
379 | gettext_noop ("") }, | 390 | gettext_noop ("") }, |
380 | { gettext_noop (""), | 391 | { gettext_noop (""), |
@@ -498,7 +509,6 @@ static const struct MetaTypeDescription meta_type_descriptions[] = { | |||
498 | gettext_noop("format version"), /* 125 */ | 509 | gettext_noop("format version"), /* 125 */ |
499 | gettext_noop("television system"), | 510 | gettext_noop("television system"), |
500 | gettext_noop("song count"), | 511 | gettext_noop("song count"), |
501 | gettext_noop("starting song"), | ||
502 | gettext_noop("hardware dependency"), | 512 | gettext_noop("hardware dependency"), |
503 | gettext_noop("ripper"), /* 130 */ | 513 | gettext_noop("ripper"), /* 130 */ |
504 | gettext_noop("filesize"), | 514 | gettext_noop("filesize"), |
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index 05f77dd..9666b6c 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am | |||
@@ -93,6 +93,7 @@ plugin_LTLIBRARIES = \ | |||
93 | libextractor_real.la \ | 93 | libextractor_real.la \ |
94 | libextractor_riff.la \ | 94 | libextractor_riff.la \ |
95 | $(rpm) \ | 95 | $(rpm) \ |
96 | libextractor_sid.la \ | ||
96 | libextractor_tar.la \ | 97 | libextractor_tar.la \ |
97 | $(thumbgtk) \ | 98 | $(thumbgtk) \ |
98 | libextractor_tiff.la \ | 99 | libextractor_tiff.la \ |
@@ -280,6 +281,11 @@ libextractor_rpm_la_LDFLAGS = \ | |||
280 | libextractor_rpm_la_LIBADD = \ | 281 | libextractor_rpm_la_LIBADD = \ |
281 | -lrpm | 282 | -lrpm |
282 | 283 | ||
284 | libextractor_sid_la_SOURCES = \ | ||
285 | sid_extractor.c | ||
286 | libextractor_sid_la_LDFLAGS = \ | ||
287 | $(PLUGINFLAGS) | ||
288 | |||
283 | libextractor_tar_la_SOURCES = \ | 289 | libextractor_tar_la_SOURCES = \ |
284 | tar_extractor.c | 290 | tar_extractor.c |
285 | libextractor_tar_la_LDFLAGS = \ | 291 | libextractor_tar_la_LDFLAGS = \ |
@@ -335,7 +341,6 @@ OLD_LIBS = \ | |||
335 | libextractor_nsf.la \ | 341 | libextractor_nsf.la \ |
336 | libextractor_nsfe.la \ | 342 | libextractor_nsfe.la \ |
337 | libextractor_s3m.la \ | 343 | libextractor_s3m.la \ |
338 | libextractor_sid.la \ | ||
339 | libextractor_tar.la \ | 344 | libextractor_tar.la \ |
340 | $(thumbqt) \ | 345 | $(thumbqt) \ |
341 | libextractor_xm.la \ | 346 | libextractor_xm.la \ |
@@ -364,13 +369,6 @@ libextractor_id3v24_la_LIBADD = \ | |||
364 | $(top_builddir)/src/common/libextractor_common.la | 369 | $(top_builddir)/src/common/libextractor_common.la |
365 | 370 | ||
366 | 371 | ||
367 | libextractor_sid_la_SOURCES = \ | ||
368 | sidextractor.c | ||
369 | libextractor_sid_la_LDFLAGS = \ | ||
370 | $(PLUGINFLAGS) | ||
371 | libextractor_sid_la_LIBADD = \ | ||
372 | $(top_builddir)/src/main/libextractor.la | ||
373 | |||
374 | libextractor_nsf_la_SOURCES = \ | 372 | libextractor_nsf_la_SOURCES = \ |
375 | nsfextractor.c | 373 | nsfextractor.c |
376 | libextractor_nsf_la_LDFLAGS = \ | 374 | libextractor_nsf_la_LDFLAGS = \ |
diff --git a/src/plugins/sidextractor.c b/src/plugins/sid_extractor.c index 5c9c6b4..2465982 100644 --- a/src/plugins/sidextractor.c +++ b/src/plugins/sid_extractor.c | |||
@@ -18,10 +18,8 @@ | |||
18 | * Boston, MA 02111-1307, USA. | 18 | * Boston, MA 02111-1307, USA. |
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | |||
22 | #include "platform.h" | 21 | #include "platform.h" |
23 | #include "extractor.h" | 22 | #include "extractor.h" |
24 | #include "convert.h" | ||
25 | 23 | ||
26 | 24 | ||
27 | #define SID1_HEADER_SIZE 0x76 | 25 | #define SID1_HEADER_SIZE 0x76 |
@@ -59,37 +57,28 @@ struct header | |||
59 | sidwrd reserved; | 57 | sidwrd reserved; |
60 | }; | 58 | }; |
61 | 59 | ||
62 | int | 60 | static int |
63 | sidword (sidwrd data) | 61 | sidword (const sidwrd data) |
64 | { | 62 | { |
65 | int value = (unsigned char) data[0] * 0x100 + (unsigned char) data[1]; | 63 | int value = (unsigned char) data[0] * 0x100 + (unsigned char) data[1]; |
64 | return value; | ||
66 | 65 | ||
67 | return (value); | ||
68 | |||
69 | } | ||
70 | |||
71 | static struct EXTRACTOR_Keywords *addkword | ||
72 | (EXTRACTOR_KeywordList * oldhead, | ||
73 | const char *phrase, EXTRACTOR_KeywordType type) | ||
74 | { | ||
75 | EXTRACTOR_KeywordList *keyword; | ||
76 | |||
77 | keyword = malloc (sizeof (EXTRACTOR_KeywordList)); | ||
78 | keyword->next = oldhead; | ||
79 | keyword->keyword = strdup (phrase); | ||
80 | keyword->keywordType = type; | ||
81 | return (keyword); | ||
82 | } | 66 | } |
83 | 67 | ||
68 | #define ADD(s,t) do { if (0 != proc (proc_cls, "sid", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen(s)+1)) return 1; } while (0) | ||
84 | 69 | ||
85 | /* "extract" keyword from a SID file | 70 | /* "extract" keyword from a SID file |
86 | * | 71 | * |
87 | * This plugin is based on the nsf extractor | 72 | * This plugin is based on the nsf extractor |
88 | * | 73 | * |
89 | */ | 74 | */ |
90 | struct EXTRACTOR_Keywords *libextractor_sid_extract | 75 | |
91 | (const char *filename, | 76 | int |
92 | char *data, size_t size, struct EXTRACTOR_Keywords *prev) | 77 | EXTRACTOR_sid_extract (const char *data, |
78 | size_t size, | ||
79 | EXTRACTOR_MetaDataProcessor proc, | ||
80 | void *proc_cls, | ||
81 | const char *options) | ||
93 | { | 82 | { |
94 | unsigned int flags; | 83 | unsigned int flags; |
95 | int version; | 84 | int version; |
@@ -99,92 +88,74 @@ struct EXTRACTOR_Keywords *libextractor_sid_extract | |||
99 | char songs[32]; | 88 | char songs[32]; |
100 | char startingsong[32]; | 89 | char startingsong[32]; |
101 | char sidversion[32]; | 90 | char sidversion[32]; |
102 | struct header *head; | 91 | const struct header *head; |
103 | 92 | ||
104 | /* Check header size */ | 93 | /* Check header size */ |
105 | 94 | ||
106 | if (size < SID1_HEADER_SIZE) | 95 | if (size < SID1_HEADER_SIZE) |
107 | { | 96 | return 0; |
108 | return (prev); | 97 | head = (const struct header *) data; |
109 | } | ||
110 | |||
111 | head = (struct header *) data; | ||
112 | 98 | ||
113 | /* Check "magic" id bytes */ | 99 | /* Check "magic" id bytes */ |
114 | 100 | if (memcmp (head->magicid, "PSID", 4) && | |
115 | if (memcmp (head->magicid, "PSID", 4) && memcmp (head->magicid, "RSID", 4)) | 101 | memcmp (head->magicid, "RSID", 4)) |
116 | { | 102 | return 0; |
117 | return (prev); | ||
118 | } | ||
119 | |||
120 | 103 | ||
121 | /* Mime-type */ | 104 | /* Mime-type */ |
122 | 105 | ADD ("audio/prs.sid", EXTRACTOR_METATYPE_MIMETYPE); | |
123 | prev = addkword (prev, "audio/prs.sid", EXTRACTOR_MIMETYPE); | ||
124 | |||
125 | 106 | ||
126 | /* Version of SID format */ | 107 | /* Version of SID format */ |
127 | |||
128 | version = sidword (head->sidversion); | 108 | version = sidword (head->sidversion); |
129 | sprintf (sidversion, "%d", version); | 109 | snprintf (sidversion, |
130 | prev = addkword (prev, sidversion, EXTRACTOR_FORMAT_VERSION); | 110 | sizeof(sidversion), |
131 | 111 | "%d", | |
112 | version); | ||
113 | ADD (sidversion, EXTRACTOR_METATYPE_FORMAT_VERSION); | ||
132 | 114 | ||
133 | /* Get song count */ | 115 | /* Get song count */ |
134 | 116 | snprintf (songs, | |
135 | sprintf (songs, "%d", sidword (head->songs)); | 117 | sizeof(songs), |
136 | prev = addkword (prev, songs, EXTRACTOR_SONG_COUNT); | 118 | "%d", sidword (head->songs)); |
137 | 119 | ADD (songs, EXTRACTOR_METATYPE_SONG_COUNT); | |
138 | 120 | ||
139 | /* Get number of the first song to be played */ | 121 | /* Get number of the first song to be played */ |
140 | 122 | snprintf (startingsong, | |
141 | sprintf (startingsong, "%d", sidword (head->firstsong)); | 123 | sizeof(startingsong), |
142 | prev = addkword (prev, startingsong, EXTRACTOR_STARTING_SONG); | 124 | "%d", |
125 | sidword (head->firstsong)); | ||
126 | ADD (startingsong, EXTRACTOR_METATYPE_STARTING_SONG); | ||
143 | 127 | ||
144 | 128 | ||
145 | /* name, artist, copyright fields */ | 129 | /* name, artist, copyright fields */ |
146 | |||
147 | memcpy (&album, head->title, 32); | 130 | memcpy (&album, head->title, 32); |
131 | album[32] = '\0'; | ||
132 | ADD (album, EXTRACTOR_METATYPE_ALBUM); | ||
133 | |||
148 | memcpy (&artist, head->artist, 32); | 134 | memcpy (&artist, head->artist, 32); |
135 | artist[32] = '\0'; | ||
136 | ADD (artist, EXTRACTOR_METATYPE_ARTIST); | ||
137 | |||
149 | memcpy (©right, head->copyright, 32); | 138 | memcpy (©right, head->copyright, 32); |
150 | |||
151 | album[32] = '\0'; | ||
152 | artist[32] = '\0'; | ||
153 | copyright[32] = '\0'; | 139 | copyright[32] = '\0'; |
140 | ADD (copyright, EXTRACTOR_METATYPE_COPYRIGHT); | ||
154 | 141 | ||
155 | prev = addkword (prev, album, EXTRACTOR_ALBUM); | ||
156 | prev = addkword (prev, artist, EXTRACTOR_ARTIST); | ||
157 | prev = addkword (prev, copyright, EXTRACTOR_COPYRIGHT); | ||
158 | 142 | ||
159 | 143 | if ( (version < 2) || (size < SID2_HEADER_SIZE)) | |
160 | if (version < 2 || size < SID2_HEADER_SIZE) | 144 | return 0; |
161 | { | ||
162 | return (prev); | ||
163 | } | ||
164 | 145 | ||
165 | /* Version 2 specific options follow | 146 | /* Version 2 specific options follow |
166 | * | 147 | * |
167 | * Note: Had some troubles understanding specification | 148 | * Note: Had some troubles understanding specification |
168 | * on the flags in version 2. I hope this is correct. | 149 | * on the flags in version 2. I hope this is correct. |
169 | * | ||
170 | */ | 150 | */ |
171 | |||
172 | flags = sidword (head->flags); | 151 | flags = sidword (head->flags); |
173 | |||
174 | |||
175 | /* MUS data */ | 152 | /* MUS data */ |
176 | 153 | if (flags & MUSPLAYER_FLAG) | |
177 | if (flags & MUSPLAYER_FLAG) | 154 | ADD ("Compute!'s Sidplayer", EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE); |
178 | { | ||
179 | prev = addkword (prev, "Compute!'s Sidplayer", EXTRACTOR_DEPENDENCY); | ||
180 | } | ||
181 | 155 | ||
182 | /* PlaySID data */ | 156 | /* PlaySID data */ |
183 | 157 | if (flags & PLAYSID_FLAG) | |
184 | if (flags & PLAYSID_FLAG) | 158 | ADD ("PlaySID", EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE); |
185 | { | ||
186 | prev = addkword (prev, "PlaySID", EXTRACTOR_DEPENDENCY); | ||
187 | } | ||
188 | 159 | ||
189 | 160 | ||
190 | /* PAL or NTSC */ | 161 | /* PAL or NTSC */ |
@@ -192,43 +163,29 @@ struct EXTRACTOR_Keywords *libextractor_sid_extract | |||
192 | if (flags & PAL_FLAG) | 163 | if (flags & PAL_FLAG) |
193 | { | 164 | { |
194 | if (flags & NTSC_FLAG) | 165 | if (flags & NTSC_FLAG) |
195 | { | 166 | ADD ("PAL/NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); |
196 | prev = addkword (prev, "PAL/NTSC", EXTRACTOR_TELEVISION_SYSTEM); | 167 | else |
197 | } | 168 | ADD ("PAL", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); |
198 | else | ||
199 | { | ||
200 | prev = addkword (prev, "PAL", EXTRACTOR_TELEVISION_SYSTEM); | ||
201 | } | ||
202 | } | 169 | } |
203 | else | 170 | else |
204 | { | 171 | { |
205 | if (flags & NTSC_FLAG) | 172 | if (flags & NTSC_FLAG) |
206 | { | 173 | ADD ("NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); |
207 | prev = addkword (prev, "NTSC", EXTRACTOR_TELEVISION_SYSTEM); | ||
208 | } | ||
209 | } | 174 | } |
210 | 175 | ||
211 | /* Detect SID Chips suitable for play the files */ | 176 | /* Detect SID Chips suitable for play the files */ |
212 | |||
213 | if (flags & MOS6581_FLAG) | 177 | if (flags & MOS6581_FLAG) |
214 | { | 178 | { |
215 | if (flags & MOS8580_FLAG) | 179 | if (flags & MOS8580_FLAG) |
216 | { | 180 | ADD ("MOS6581/MOS8580", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); |
217 | prev = | ||
218 | addkword (prev, "MOS6581/MOS8580", EXTRACTOR_HARDWARE_DEPENDENCY); | ||
219 | } | ||
220 | else | 181 | else |
221 | { | 182 | ADD ("MOS6581", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); |
222 | prev = addkword (prev, "MOS6581", EXTRACTOR_HARDWARE_DEPENDENCY); | ||
223 | } | ||
224 | } | 183 | } |
225 | else | 184 | else |
226 | { | 185 | { |
227 | if (flags & MOS8580_FLAG) | 186 | if (flags & MOS8580_FLAG) |
228 | { | 187 | ADD ("MOS8580", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); |
229 | prev = addkword (prev, "MOS8580", EXTRACTOR_HARDWARE_DEPENDENCY); | ||
230 | } | ||
231 | } | 188 | } |
232 | 189 | ||
233 | return (prev); | 190 | return 0; |
234 | } | 191 | } |