forked from len0rd/rockbox
Added id3 version wps tag: %iv. Fixed id3v1 parsing bug.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2967 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
fd25bbd8ff
commit
cf1317c336
3 changed files with 60 additions and 12 deletions
|
|
@ -295,6 +295,27 @@ static char* get_tag(struct mp3entry* id3,
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'v': /* id3 version */
|
||||||
|
switch (id3->id3version) {
|
||||||
|
case ID3_VER_1_0:
|
||||||
|
return "1";
|
||||||
|
|
||||||
|
case ID3_VER_1_1:
|
||||||
|
return "1.1";
|
||||||
|
|
||||||
|
case ID3_VER_2_2:
|
||||||
|
return "2.2";
|
||||||
|
|
||||||
|
case ID3_VER_2_3:
|
||||||
|
return "2.3";
|
||||||
|
|
||||||
|
case ID3_VER_2_4:
|
||||||
|
return "2.4";
|
||||||
|
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,8 @@ static bool setid3v1title(int fd, struct mp3entry *entry)
|
||||||
if (strncmp(buffer, "TAG", 3))
|
if (strncmp(buffer, "TAG", 3))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
entry->id3version = ID3_VER_1_0;
|
||||||
|
|
||||||
for (i=0; i < (int)sizeof offsets; i++) {
|
for (i=0; i < (int)sizeof offsets; i++) {
|
||||||
char* ptr = buffer + offsets[i];
|
char* ptr = buffer + offsets[i];
|
||||||
|
|
||||||
|
|
@ -179,17 +181,17 @@ static bool setid3v1title(int fd, struct mp3entry *entry)
|
||||||
|
|
||||||
switch(i) {
|
switch(i) {
|
||||||
case 0:
|
case 0:
|
||||||
strcpy(entry->id3v1buf[2], ptr);
|
strncpy(entry->id3v1buf[2], ptr, 30);
|
||||||
entry->title = entry->id3v1buf[2];
|
entry->title = entry->id3v1buf[2];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
strcpy(entry->id3v1buf[0], ptr);
|
strncpy(entry->id3v1buf[0], ptr, 30);
|
||||||
entry->artist = entry->id3v1buf[0];
|
entry->artist = entry->id3v1buf[0];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
strcpy(entry->id3v1buf[1], ptr);
|
strncpy(entry->id3v1buf[1], ptr, 30);
|
||||||
entry->album = entry->id3v1buf[1];
|
entry->album = entry->id3v1buf[1];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -201,8 +203,10 @@ static bool setid3v1title(int fd, struct mp3entry *entry)
|
||||||
case 4:
|
case 4:
|
||||||
/* id3v1.1 uses last two bytes of comment field for track
|
/* id3v1.1 uses last two bytes of comment field for track
|
||||||
number: first must be 0 and second is track num */
|
number: first must be 0 and second is track num */
|
||||||
if (*ptr == 0)
|
if (!ptr[0] && ptr[1]) {
|
||||||
entry->tracknum = ptr[1];
|
entry->tracknum = ptr[1];
|
||||||
|
entry->id3version = ID3_VER_1_1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
|
|
@ -230,7 +234,7 @@ static void setid3v2title(int fd, struct mp3entry *entry)
|
||||||
int size;
|
int size;
|
||||||
int bufferpos = 0, totframelen, framelen;
|
int bufferpos = 0, totframelen, framelen;
|
||||||
char header[10];
|
char header[10];
|
||||||
unsigned short int version;
|
unsigned char version;
|
||||||
char *buffer = entry->id3v2buf;
|
char *buffer = entry->id3v2buf;
|
||||||
char *tracknum = NULL;
|
char *tracknum = NULL;
|
||||||
int bytesread = 0;
|
int bytesread = 0;
|
||||||
|
|
@ -245,16 +249,30 @@ static void setid3v2title(int fd, struct mp3entry *entry)
|
||||||
if(10 != read(fd, header, 10))
|
if(10 != read(fd, header, 10))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
version = (unsigned short int)header[3];
|
|
||||||
|
|
||||||
/* Get the total ID3 tag size */
|
/* Get the total ID3 tag size */
|
||||||
size = entry->id3v2len - 10;
|
size = entry->id3v2len - 10;
|
||||||
|
|
||||||
/* Set minimum frame size according to ID3v2 version */
|
version = header[3];
|
||||||
if(version > 2)
|
switch ( version ) {
|
||||||
minframesize = 12;
|
case 2:
|
||||||
else
|
entry->id3version = ID3_VER_2_2;
|
||||||
minframesize = 8;
|
minframesize = 8;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
entry->id3version = ID3_VER_2_3;
|
||||||
|
minframesize = 12;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
entry->id3version = ID3_VER_2_4;
|
||||||
|
minframesize = 12;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* unsupported id3 version */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We must have at least minframesize bytes left for the
|
* We must have at least minframesize bytes left for the
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ struct mp3entry {
|
||||||
int version;
|
int version;
|
||||||
int layer;
|
int layer;
|
||||||
int year;
|
int year;
|
||||||
|
unsigned char id3version;
|
||||||
unsigned char genre;
|
unsigned char genre;
|
||||||
unsigned int bitrate;
|
unsigned int bitrate;
|
||||||
unsigned int frequency;
|
unsigned int frequency;
|
||||||
|
|
@ -62,6 +63,14 @@ struct mp3entry {
|
||||||
#define VBR_BYTES_FLAG 0x02
|
#define VBR_BYTES_FLAG 0x02
|
||||||
#define VBR_TOC_FLAG 0x04
|
#define VBR_TOC_FLAG 0x04
|
||||||
|
|
||||||
|
enum {
|
||||||
|
ID3_VER_1_0 = 1,
|
||||||
|
ID3_VER_1_1,
|
||||||
|
ID3_VER_2_2,
|
||||||
|
ID3_VER_2_3,
|
||||||
|
ID3_VER_2_4
|
||||||
|
};
|
||||||
|
|
||||||
bool mp3info(struct mp3entry *entry, char *filename);
|
bool mp3info(struct mp3entry *entry, char *filename);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue