summaryrefslogtreecommitdiff
path: root/src/demuxers/id3.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/demuxers/id3.c')
-rw-r--r--src/demuxers/id3.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/demuxers/id3.c b/src/demuxers/id3.c
index 070ca2650..15599ffea 100644
--- a/src/demuxers/id3.c
+++ b/src/demuxers/id3.c
@@ -29,7 +29,7 @@
*
* ID3v2 specs: http://www.id3.org/
*/
-
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -84,7 +84,7 @@ static const char* const id3_encoding[] = {
"UTF-16", /* 0x01 */
"UTF-16BE", /* 0x02 */
"UTF-8"}; /* 0x03 */
-
+
int id3v1_parse_tag (input_plugin_t *input, xine_stream_t *stream) {
off_t len;
@@ -113,7 +113,7 @@ int id3v1_parse_tag (input_plugin_t *input, xine_stream_t *stream) {
if (tag.genre < ID3_GENRE_COUNT) {
_x_meta_info_set(stream, XINE_META_INFO_GENRE, id3_genre[tag.genre]);
}
-
+
}
return 1;
} else {
@@ -126,12 +126,12 @@ static int id3v2_parse_genre(char* dest, char *src, int len) {
int state = 0;
char *buf = dest;
unsigned int index = 0;
-
+
while (*src) {
lprintf("state=%d\n", state);
if ((buf - dest) >= len)
return 0;
-
+
switch (state) {
case 0:
/* initial state */
@@ -278,7 +278,7 @@ static int id3v22_interp_frame(input_plugin_t *input,
const size_t bufsize = frame_header->size + 2;
if ( bufsize < 3 ) /* frames has to be _at least_ 1 byte */
return 0;
-
+
buf = malloc(bufsize);
if (buf == NULL) {
lprintf("malloc error");
@@ -296,7 +296,7 @@ static int id3v22_interp_frame(input_plugin_t *input,
case ( FOURCC_TAG(0, 'T', 'C', 'O') ):
{
char tmp[1024];
-
+
if (id3v2_parse_genre(tmp, buf + 1, 1024)) {
_x_meta_info_set(stream, XINE_META_INFO_GENRE, tmp);
}
@@ -352,21 +352,21 @@ static int id3v22_parse_tag(input_plugin_t *input,
if (tag_header.flags & ID3V22_ZERO_FLAG) {
/* invalid flags */
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
+ xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
LOG_MODULE ": invalid header flags (%02x)\n", tag_header.flags);
input->seek (input, tag_header.size - pos, SEEK_CUR);
return 0;
}
if (tag_header.flags & ID3V22_COMPRESS_FLAG) {
/* compressed tag: not supported */
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
+ xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
LOG_MODULE ": compressed tags are not supported\n");
input->seek (input, tag_header.size - pos, SEEK_CUR);
return 0;
}
if (tag_header.flags & ID3V22_UNSYNCH_FLAG) {
/* unsynchronized tag: not supported */
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
+ xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
LOG_MODULE ": unsynchronized tags are not supported\n");
input->seek (input, tag_header.size - pos, SEEK_CUR);
return 0;
@@ -378,11 +378,11 @@ static int id3v22_parse_tag(input_plugin_t *input,
if (tag_frame_header.id) {
if ((pos + tag_frame_header.size) <= tag_header.size) {
if (!id3v22_interp_frame(input, stream, &tag_frame_header)) {
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
+ xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
LOG_MODULE ": invalid frame content\n");
}
} else {
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
+ xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
LOG_MODULE ": invalid frame header\n");
input->seek (input, tag_header.size - pos, SEEK_CUR);
return 1;
@@ -394,7 +394,7 @@ static int id3v22_parse_tag(input_plugin_t *input,
return 1;
}
} else {
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
+ xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
LOG_MODULE ": id3v2_parse_frame_header problem\n");
return 0;
}
@@ -433,9 +433,9 @@ static int id3v23_parse_frame_ext_header(input_plugin_t *input,
uint8_t buf[14];
if (input->read (input, buf, 4) == 4) {
-
+
frame_ext_header->size = _X_BE_32(&buf[0]);
-
+
if (frame_ext_header->size == 6) {
if (input->read (input, buf + 4, 6) == 6) {
frame_ext_header->flags = _X_BE_16(buf + 4);
@@ -443,7 +443,7 @@ static int id3v23_parse_frame_ext_header(input_plugin_t *input,
frame_ext_header->crc = 0;
} else {
return 0;
- }
+ }
} else if (frame_ext_header->size == 10) {
if (input->read (input, buf + 4, 10) == 10) {
@@ -476,7 +476,7 @@ static int id3v23_interp_frame(input_plugin_t *input,
const size_t bufsize = frame_header->size + 2;
if ( bufsize < 3 ) /* frames has to be _at least_ 1 byte */
return 0;
-
+
buf = malloc(bufsize);
if (buf == NULL) {
lprintf("malloc error");
@@ -494,7 +494,7 @@ static int id3v23_interp_frame(input_plugin_t *input,
case ( FOURCC_TAG('T', 'C', 'O', 'N') ):
{
char tmp[1024];
-
+
if (id3v2_parse_genre(tmp, buf + 1, 1024)) {
_x_meta_info_set(stream, XINE_META_INFO_GENRE, tmp);
}
@@ -550,14 +550,14 @@ static int id3v23_parse_tag(input_plugin_t *input,
if (tag_header.flags & ID3V23_ZERO_FLAG) {
/* invalid flags */
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
+ xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
LOG_MODULE ": invalid header flags (%02x)\n", tag_header.flags);
input->seek (input, tag_header.size - pos, SEEK_CUR);
return 0;
}
if (tag_header.flags & ID3V23_UNSYNCH_FLAG) {
/* unsynchronized tag: not supported */
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
+ xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
LOG_MODULE ": unsynchronized tags are not supported\n");
input->seek (input, tag_header.size - pos, SEEK_CUR);
return 0;
@@ -576,11 +576,11 @@ static int id3v23_parse_tag(input_plugin_t *input,
if (tag_frame_header.id) {
if ((pos + tag_frame_header.size) <= tag_header.size) {
if (!id3v23_interp_frame(input, stream, &tag_frame_header)) {
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
+ xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
LOG_MODULE ": invalid frame content\n");
}
} else {
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
+ xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
LOG_MODULE ": invalid frame header\n");
input->seek (input, tag_header.size - pos, SEEK_CUR);
return 1;
@@ -593,7 +593,7 @@ static int id3v23_parse_tag(input_plugin_t *input,
return 1;
}
} else {
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
+ xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
LOG_MODULE ": id3v2_parse_frame_header problem\n");
return 0;
}
@@ -610,7 +610,7 @@ static int id3v23_parse_tag(input_plugin_t *input,
/* id3v2 "genre" parsing code. what a ugly format ! */
static int id3v24_parse_genre(char* dest, char *src, int len) {
unsigned int index = 0;
-
+
dest[0] = '\0';
if (sscanf(src, "%u", &index) == 1) {
if (index < ID3_GENRE_COUNT) {
@@ -648,7 +648,7 @@ static int id3v24_parse_ext_header(input_plugin_t *input,
uint8_t buf[5];
if (input->read (input, buf, 4) == 4) {
-
+
frame_ext_header->size = _X_BE_32(&buf[0]);
if (input->read (input, buf, 2) == 2) {
@@ -731,7 +731,7 @@ static int id3v24_interp_frame(input_plugin_t *input,
const size_t bufsize = frame_header->size + 2;
if ( bufsize < 3 ) /* frames has to be _at least_ 1 byte */
return 0;
-
+
buf = malloc(bufsize);
if (buf == NULL) {
lprintf("malloc error");
@@ -744,14 +744,14 @@ static int id3v24_interp_frame(input_plugin_t *input,
enc = buf[0];
if( enc >= ID3_ENCODING_COUNT )
enc = 0;
-
+
lprintf("data: %s\n", buf+1);
switch (frame_header->id) {
case ( FOURCC_TAG('T', 'C', 'O', 'N') ):
{
char tmp[1024];
-
+
if (id3v24_parse_genre(tmp, buf + 1, 1024)) {
_x_meta_info_set(stream, XINE_META_INFO_GENRE, tmp);
}
@@ -808,7 +808,7 @@ static int id3v24_parse_tag(input_plugin_t *input,
if (tag_header.flags & ID3V24_ZERO_FLAG) {
/* invalid flags */
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
+ xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
LOG_MODULE ": invalid header flags (%02x)\n", tag_header.flags);
input->seek (input, tag_header.size - pos, SEEK_CUR);
return 0;
@@ -833,11 +833,11 @@ static int id3v24_parse_tag(input_plugin_t *input,
if (tag_frame_header.id) {
if ((pos + tag_frame_header.size) <= tag_header.size) {
if (!id3v24_interp_frame(input, stream, &tag_frame_header)) {
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
+ xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
LOG_MODULE ": invalid frame content\n");
}
} else {
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
+ xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
LOG_MODULE ": invalid frame header\n");
input->seek (input, tag_header.size - pos, SEEK_CUR);
return 1;
@@ -849,7 +849,7 @@ static int id3v24_parse_tag(input_plugin_t *input,
return 1;
}
} else {
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
+ xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
LOG_MODULE ": id3v2_parse_frame_header problem\n");
return 0;
}
@@ -877,7 +877,7 @@ int id3v2_parse_tag(input_plugin_t *input,
xprintf(stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": ID3V2.2 tag\n");
result = id3v22_parse_tag(input, stream, mp3_frame_header);
break;
-
+
case 3:
xprintf(stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": ID3V2.3 tag\n");
result = id3v23_parse_tag(input, stream, mp3_frame_header);