~ubuntu-branches/ubuntu/hoary/flac/hoary

« back to all changes in this revision

Viewing changes to src/plugin_common/id3v1.c

  • Committer: Bazaar Package Importer
  • Author(s): Matt Zimmerman
  • Date: 2004-04-16 15:14:31 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040416151431-eyloggqxpwbwpogz
Tags: 1.1.0-11
Ensure that libFLAC is linked with -lm on all architectures, and
regardless of whether nasm is present

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* plugin_common - Routines common to several plugins
 
2
 * Copyright (C) 2002,2003  Josh Coalson
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU General Public License
 
6
 * as published by the Free Software Foundation; either version 2
 
7
 * of the License, or (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
17
 */
 
18
 
 
19
#include <stdio.h>
 
20
 
 
21
#include "FLAC/assert.h"
 
22
#include "id3v1.h"
 
23
#include "locale_hack.h"
 
24
 
 
25
 
 
26
/* 
 
27
 * Do not sort genres!!
 
28
 * Last Update: 2000/04/30
 
29
 */
 
30
static const char * const FLAC_plugin__id3v1_tag_genre_table[] =
 
31
{
 
32
        "Blues",                /* 0 */
 
33
        "Classic Rock",
 
34
        "Country",
 
35
        "Dance",
 
36
        "Disco",
 
37
        "Funk",                 /* 5 */
 
38
        "Grunge",
 
39
        "Hip-Hop", 
 
40
        "Jazz",
 
41
        "Metal",
 
42
        "New Age",              /* 10 */                
 
43
        "Oldies",
 
44
        "Other", 
 
45
        "Pop",
 
46
        "R&B",
 
47
        "Rap",                  /* 15 */
 
48
        "Reggae", 
 
49
        "Rock",
 
50
        "Techno",
 
51
        "Industrial",
 
52
        "Alternative",          /* 20 */
 
53
        "Ska",
 
54
        "Death Metal", 
 
55
        "Pranks",
 
56
        "Soundtrack",
 
57
        "Euro-Techno",          /* 25 */
 
58
        "Ambient",
 
59
        "Trip-Hop", 
 
60
        "Vocal",
 
61
        "Jazz+Funk", 
 
62
        "Fusion",               /* 30 */
 
63
        "Trance",
 
64
        "Classical",
 
65
        "Instrumental", 
 
66
        "Acid",
 
67
        "House",                /* 35 */
 
68
        "Game",
 
69
        "Sound Clip", 
 
70
        "Gospel",
 
71
        "Noise",
 
72
        "Altern Rock",          /* 40 */
 
73
        "Bass",
 
74
        "Soul",
 
75
        "Punk",
 
76
        "Space",
 
77
        "Meditative",           /* 45 */
 
78
        "Instrumental Pop",
 
79
        "Instrumental Rock", 
 
80
        "Ethnic",
 
81
        "Gothic",
 
82
        "Darkwave",             /* 50 */
 
83
        "Techno-Industrial", 
 
84
        "Electronic", 
 
85
        "Pop-Folk",
 
86
        "Eurodance", 
 
87
        "Dream",                /* 55 */
 
88
        "Southern Rock", 
 
89
        "Comedy", 
 
90
        "Cult",
 
91
        "Gangsta",
 
92
        "Top 40",               /* 60 */
 
93
        "Christian Rap", 
 
94
        "Pop/Funk", 
 
95
        "Jungle",
 
96
        "Native American", 
 
97
        "Cabaret",              /* 65 */
 
98
        "New Wave",
 
99
        "Psychadelic", 
 
100
        "Rave",
 
101
        "Showtunes", 
 
102
        "Trailer",              /* 70 */
 
103
        "Lo-Fi",
 
104
        "Tribal",
 
105
        "Acid Punk",
 
106
        "Acid Jazz", 
 
107
        "Polka",                /* 75 */
 
108
        "Retro",
 
109
        "Musical",
 
110
        "Rock & Roll", 
 
111
        "Hard Rock", 
 
112
        "Folk",                 /* 80 */
 
113
        "Folk/Rock",
 
114
        "National Folk", 
 
115
        "Fast Fusion",
 
116
        "Swing",
 
117
        "Bebob",                /* 85 */
 
118
        "Latin",
 
119
        "Revival",
 
120
        "Celtic",
 
121
        "Bluegrass",
 
122
        "Avantgarde",           /* 90 */
 
123
        "Gothic Rock",
 
124
        "Progressive Rock",
 
125
        "Psychedelic Rock", 
 
126
        "Symphonic Rock", 
 
127
        "Slow Rock",            /* 95 */
 
128
        "Big Band", 
 
129
        "Chorus",
 
130
        "Easy Listening", 
 
131
        "Acoustic", 
 
132
        "Humour",               /* 100 */
 
133
        "Speech",
 
134
        "Chanson", 
 
135
        "Opera",
 
136
        "Chamber Music", 
 
137
        "Sonata",               /* 105 */
 
138
        "Symphony",
 
139
        "Booty Bass", 
 
140
        "Primus",
 
141
        "Porn Groove", 
 
142
        "Satire",               /* 110 */
 
143
        "Slow Jam", 
 
144
        "Club",
 
145
        "Tango",
 
146
        "Samba",
 
147
        "Folklore",             /* 115 */
 
148
        "Ballad",
 
149
        "Power Ballad",
 
150
        "Rhythmic Soul",
 
151
        "Freestyle",
 
152
        "Duet",                 /* 120 */
 
153
        "Punk Rock",
 
154
        "Drum Solo",
 
155
        "A Capella",
 
156
        "Euro-House",
 
157
        "Dance Hall",           /* 125 */
 
158
        "Goa",
 
159
        "Drum & Bass",
 
160
        "Club-House",
 
161
        "Hardcore",
 
162
        "Terror",               /* 130 */
 
163
        "Indie",
 
164
        "BritPop",
 
165
        "Negerpunk",
 
166
        "Polsk Punk",
 
167
        "Beat",                 /* 135 */
 
168
        "Christian Gangsta Rap",
 
169
        "Heavy Metal",
 
170
        "Black Metal",
 
171
        "Crossover",
 
172
        "Contemporary Christian",/* 140 */
 
173
        "Christian Rock",
 
174
        "Merengue",
 
175
        "Salsa",
 
176
        "Thrash Metal",
 
177
        "Anime",                /* 145 */
 
178
        "JPop",
 
179
        "Synthpop"
 
180
};
 
181
 
 
182
 
 
183
FLAC__bool FLAC_plugin__id3v1_tag_get(const char *filename, FLAC_Plugin__Id3v1_Tag *tag)
 
184
{
 
185
        char raw[128];
 
186
        FILE *f;
 
187
 
 
188
        FLAC__ASSERT(0 != filename);
 
189
        FLAC__ASSERT(0 != tag);
 
190
 
 
191
        memset(tag, 0, sizeof(FLAC_Plugin__Id3v1_Tag));
 
192
 
 
193
        if(0 == (f = fopen(filename, "rb")))
 
194
                return false;
 
195
        if(-1 == fseek(f, -128, SEEK_END)) {
 
196
                fclose(f);
 
197
                return false;
 
198
        }
 
199
        if(fread(raw, 1, 128, f) < 128) {
 
200
                fclose(f);
 
201
                return false;
 
202
        }
 
203
        fclose(f);
 
204
        if(strncmp(raw, "TAG", 3))
 
205
                return false;
 
206
        else {
 
207
                memcpy(tag->tag, raw, 3);
 
208
                memcpy(tag->title, raw+3, 30);
 
209
                memcpy(tag->artist, raw+33, 30);
 
210
                memcpy(tag->album, raw+63, 30);
 
211
                memcpy(tag->year, raw+93, 4);
 
212
                memcpy(tag->comment.v1_0.comment, raw+97, 30);
 
213
                tag->genre = raw[127];
 
214
                return true;
 
215
        }
 
216
}
 
217
 
 
218
const char *FLAC_plugin__id3v1_tag_get_genre_as_string(unsigned char genre_code)
 
219
{
 
220
        if (genre_code < FLAC_plugin__id3v1_tag_genre_table_max())
 
221
                return gettext(FLAC_plugin__id3v1_tag_genre_table[genre_code]);
 
222
 
 
223
        return "";
 
224
}
 
225
 
 
226
unsigned FLAC_plugin__id3v1_tag_genre_table_max()
 
227
{
 
228
        return sizeof(FLAC_plugin__id3v1_tag_genre_table) / sizeof(FLAC_plugin__id3v1_tag_genre_table[0]) - 1;
 
229
}