Added ID3 tag 'genre': %ig

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2950 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Björn Stenberg 2002-12-05 15:21:18 +00:00
parent 345f7c62ba
commit a5587d0298
3 changed files with 52 additions and 2 deletions

View file

@ -63,6 +63,33 @@ static int ff_rewind_count;
bool wps_time_countup = true;
static bool wps_loaded = false;
static const char* const genres[] = {
"Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge",
"Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", "Pop", "R&B",
"Rap", "Reggae", "Rock", "Techno", "Industrial", "Alternative", "Ska",
"Death Metal", "Pranks", "Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop",
"Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical", "Instrumental",
"Acid", "House", "Game", "Sound Clip", "Gospel", "Noise", "AlternRock",
"Bass", "Soul", "Punk", "Space", "Meditative", "Instrumental Pop",
"Instrumental Rock", "Ethnic", "Gothic", "Darkwave", "Techno-Industrial",
"Electronic", "Pop-Folk", "Eurodance", "Dream", "Southern Rock", "Comedy",
"Cult", "Gangsta", "Top 40", "Christian Rap", "Pop/Funk", "Jungle",
"Native American", "Cabaret", "New Wave", "Psychadelic", "Rave",
"Showtunes", "Trailer", "Lo-Fi", "Tribal", "Acid Punk", "Acid Jazz",
"Polka", "Retro", "Musical", "Rock & Roll", "Hard Rock",
/* winamp extensions */
"Folk", "Folk-Rock", "National Folk", "Swing", "Fast Fusion", "Bebob",
"Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock",
"Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Slow Rock",
"Big Band", "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech",
"Chanson", "Opera", "Chamber Music", "Sonata", "Symphony", "Booty Bass",
"Primus", "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba",
"Folklore", "Ballad", "Power Ballad", "Rhythmic Soul", "Freestyle",
"Duet", "Punk Rock", "Drum Solo", "A capella", "Euro-House", "Dance Hall"
};
/* Set format string to use for WPS, splitting it into lines */
static void wps_format(char* fmt)
{
@ -260,6 +287,13 @@ static char* get_tag(struct mp3entry* id3,
else
return NULL;
break;
case 'g': /* genre */
if (id3->genre < sizeof(genres)/sizeof(char*))
return (char*)genres[id3->genre];
else
return NULL;
break;
}
break;

View file

@ -156,7 +156,7 @@ static int unicode_munge(char** string, int *len) {
static bool setid3v1title(int fd, struct mp3entry *entry)
{
unsigned char buffer[128];
static int offsets[] = {3, 33, 63, 93, 125};
static char offsets[] = {3, 33, 63, 93, 125, 127};
int i, j;
if (-1 == lseek(fd, -128, SEEK_END))
@ -168,7 +168,7 @@ static bool setid3v1title(int fd, struct mp3entry *entry)
if (strncmp(buffer, "TAG", 3))
return false;
for (i=0;i<5;i++) {
for (i=0; i < (int)sizeof offsets; i++) {
char* ptr = buffer + offsets[i];
if (i<3) {
@ -204,6 +204,11 @@ static bool setid3v1title(int fd, struct mp3entry *entry)
if (*ptr == 0)
entry->tracknum = ptr[1];
break;
case 5:
/* genre */
entry->genre = ptr[0];
break;
}
}
@ -339,6 +344,16 @@ static void setid3v2title(int fd, struct mp3entry *entry)
bufferpos += bytesread + 1;
size -= bytesread;
}
else if(!strncmp(header, "TCON", 4)) {
char* ptr = buffer + bufferpos;
bytesread = read(fd, ptr, framelen);
if (ptr[1] == '(' && ptr[2] != '(')
entry->genre = atoi(ptr+2);
else
entry->genre = 0xff;
bufferpos += bytesread + 1;
size -= bytesread;
}
else {
/* Unknown frame, skip it using the total size in case
it was truncated */

View file

@ -30,6 +30,7 @@ struct mp3entry {
int version;
int layer;
int year;
unsigned char genre;
unsigned int bitrate;
unsigned int frequency;
unsigned int id3v2len;