diff options
Diffstat (limited to 'src/demuxers/id3.c')
-rw-r--r-- | src/demuxers/id3.c | 245 |
1 files changed, 93 insertions, 152 deletions
diff --git a/src/demuxers/id3.c b/src/demuxers/id3.c index b707166b6..f65d5564c 100644 --- a/src/demuxers/id3.c +++ b/src/demuxers/id3.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * * ID3 tag parser * @@ -28,8 +28,6 @@ * unzip support * * ID3v2 specs: http://www.id3.org/ - * - * $Id: id3.c,v 1.13 2007/03/03 00:58:52 dgp85 Exp $ */ #ifdef HAVE_CONFIG_H @@ -42,12 +40,12 @@ #define LOG */ -#include "xine_internal.h" -#include "xineutils.h" +#include <xine/xine_internal.h> +#include <xine/xineutils.h> #include "bswap.h" #include "id3.h" -#define ID3_GENRE_COUNT 126 +#define ID3_GENRE_COUNT (sizeof (id3_genre) / sizeof (id3_genre[0])) static const char* const id3_genre[] = {"Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge", "Hip-Hop", "Jazz", "Metal", @@ -74,7 +72,11 @@ static const char* const id3_genre[] = "Satire", "Slow Jam", "Club", "Tango", "Samba", "Folklore", "Ballad", "Power Ballad", "Rhythmic Soul", "Freestyle", "Duet", "Punk Rock", "Drum Solo", "A capella", "Euro-House", - "Dance Hall" }; + "Dance Hall", "Goa", "Drum & Bass", "Club-House", "Hardcore", "Terror", + "Indie", "BritPop", "Negerpunk", "Polsk Punk", "Beat", + "Christian Gangsta Rap", "Heavy Metal", "Black Metal", "Crossover", + "Contemporary Christian", "Christian Rock", "Merengue", "Salsa", + "Thrash Metal", "Anime", "JPop", "Synthpop" }; #define ID3_ENCODING_COUNT 4 static const char* const id3_encoding[] = { @@ -227,49 +229,17 @@ static int id3v2_parse_genre(char* dest, char *src, int len) { return 1; } -#if 0 -/* parse an unsynchronized 16bits integer */ -static uint16_t BE_16_synchsafe(uint8_t buf[2]) { - return ((uint16_t)(buf[0] & 0x7F) << 7) | - (uint16_t)(buf[1] & 0x7F); -} -#endif - -/* parse an unsynchronized 24bits integer */ -static uint32_t BE_24_synchsafe(uint8_t buf[3]) { - return ((uint32_t)(buf[0] & 0x7F) << 14) | - ((uint32_t)(buf[1] & 0x7F) << 7) | - (uint32_t)(buf[2] & 0x7F); -} - -/* parse an unsynchronized 32bits integer */ -static uint32_t BE_32_synchsafe(uint8_t buf[4]) { - return ((uint32_t)(buf[0] & 0x7F) << 21) | - ((uint32_t)(buf[1] & 0x7F) << 14) | - ((uint32_t)(buf[2] & 0x7F) << 7) | - (uint32_t)(buf[3] & 0x7F); -} - -/* parse an unsynchronized 35bits integer */ -static uint32_t BE_35_synchsafe(uint8_t buf[5]) { - return ((uint32_t)(buf[0] & 0x07) << 28) | - ((uint32_t)(buf[1] & 0x7F) << 21) | - ((uint32_t)(buf[2] & 0x7F) << 14) | - ((uint32_t)(buf[3] & 0x7F) << 7) | - (uint32_t)(buf[4] & 0x7F); -} - -static int id3v2_parse_header(input_plugin_t *input, uint8_t *mp3_frame_header, +static int id3v2_parse_header(input_plugin_t *input, uint32_t id3_signature, id3v2_header_t *tag_header) { uint8_t buf[6]; - tag_header->id = BE_32(mp3_frame_header); + tag_header->id = be2me_32(id3_signature); if (input->read (input, buf, 6) == 6) { tag_header->revision = buf[0]; tag_header->flags = buf[1]; - tag_header->size = BE_32_synchsafe(&buf[2]); + tag_header->size = _X_BE_32_synchsafe(&buf[2]); - lprintf("tag: ID3 v2.%d.%d\n", mp3_frame_header[3], tag_header->revision); + lprintf("tag: ID3 v2.%d.%d\n", tag_header->id & 0xFF, tag_header->revision); lprintf("flags: %d\n", tag_header->flags); lprintf("size: %d\n", tag_header->size); return 1; @@ -289,7 +259,7 @@ static int id3v22_parse_frame_header(input_plugin_t *input, if (len == ID3V22_FRAME_HEADER_SIZE) { frame_header->id = (buf[0] << 16) + (buf[1] << 8) + buf[2]; - frame_header->size = BE_24_synchsafe(&buf[3]); + frame_header->size = _X_BE_24_synchsafe(&buf[3]); lprintf("frame: %c%c%c: size: %d\n", buf[0], buf[1], buf[2], frame_header->size); @@ -303,15 +273,9 @@ static int id3v22_parse_frame_header(input_plugin_t *input, static int id3v22_interp_frame(input_plugin_t *input, xine_stream_t *stream, id3v22_frame_header_t *frame_header) { - char *buf; + char buf[frame_header->size + 1]; int enc; - buf = malloc(frame_header->size + 1); - if (buf == NULL) { - lprintf("malloc error"); - return 0; - } - if (input->read (input, buf, frame_header->size) == frame_header->size) { buf[frame_header->size] = 0; enc = buf[0]; @@ -319,7 +283,7 @@ static int id3v22_interp_frame(input_plugin_t *input, enc = 0; switch (frame_header->id) { - case ( FOURCC_TAG(0, 'T', 'C', 'O') ): + case ( BE_FOURCC(0, 'T', 'C', 'O') ): { char tmp[1024]; @@ -329,27 +293,27 @@ static int id3v22_interp_frame(input_plugin_t *input, } break; - case ( FOURCC_TAG(0, 'T', 'T', '2') ): + case ( BE_FOURCC(0, 'T', 'T', '2') ): _x_meta_info_set_generic(stream, XINE_META_INFO_TITLE, buf + 1, id3_encoding[enc]); break; - case ( FOURCC_TAG(0, 'T', 'P', '1') ): + case ( BE_FOURCC(0, 'T', 'P', '1') ): _x_meta_info_set_generic(stream, XINE_META_INFO_ARTIST, buf + 1, id3_encoding[enc]); break; - case ( FOURCC_TAG(0, 'T', 'A', 'L') ): + case ( BE_FOURCC(0, 'T', 'A', 'L') ): _x_meta_info_set_generic(stream, XINE_META_INFO_ALBUM, buf + 1, id3_encoding[enc]); break; - case ( FOURCC_TAG(0, 'T', 'Y', 'E') ): + case ( BE_FOURCC(0, 'T', 'Y', 'E') ): _x_meta_info_set_generic(stream, XINE_META_INFO_YEAR, buf + 1, id3_encoding[enc]); break; - case ( FOURCC_TAG(0, 'C', 'O', 'M') ): + case ( BE_FOURCC(0, 'C', 'O', 'M') ): _x_meta_info_set_generic(stream, XINE_META_INFO_COMMENT, buf + 1 + 3, id3_encoding[enc]); break; - case ( FOURCC_TAG(0, 'T', 'R', 'K') ): + case ( BE_FOURCC(0, 'T', 'R', 'K') ): _x_meta_info_set(stream, XINE_META_INFO_TRACK_NUMBER, buf + 1); break; @@ -357,11 +321,9 @@ static int id3v22_interp_frame(input_plugin_t *input, lprintf("unhandled frame\n"); } - free(buf); return 1; } else { lprintf("read error\n"); - free(buf); return 0; } } @@ -369,31 +331,31 @@ static int id3v22_interp_frame(input_plugin_t *input, int id3v22_parse_tag(input_plugin_t *input, xine_stream_t *stream, - int8_t *mp3_frame_header) { + uint32_t id3_signature) { id3v2_header_t tag_header; id3v22_frame_header_t tag_frame_header; int pos = 0; - if (id3v2_parse_header(input, mp3_frame_header, &tag_header)) { + if (id3v2_parse_header(input, id3_signature, &tag_header)) { if (tag_header.flags & ID3V22_ZERO_FLAG) { /* invalid flags */ xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: invalid header flags\n"); + 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, - "id3: compressed tags are not supported\n"); + 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, - "id3: unsynchronized tags are not supported\n"); + LOG_MODULE ": unsynchronized tags are not supported\n"); input->seek (input, tag_header.size - pos, SEEK_CUR); return 0; } @@ -405,11 +367,11 @@ int id3v22_parse_tag(input_plugin_t *input, if ((pos + tag_frame_header.size) <= tag_header.size) { if (!id3v22_interp_frame(input, stream, &tag_frame_header)) { xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: invalid frame content\n"); + LOG_MODULE ": invalid frame content\n"); } } else { xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: invalid frame header\n"); + LOG_MODULE ": invalid frame header\n"); input->seek (input, tag_header.size - pos, SEEK_CUR); return 1; } @@ -421,13 +383,13 @@ int id3v22_parse_tag(input_plugin_t *input, } } else { xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: id3v2_parse_frame_header problem\n"); + LOG_MODULE ": id3v2_parse_frame_header problem\n"); return 0; } } return 1; } else { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "id3: id3v2_parse_header problem\n"); + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": id3v2_parse_header problem\n"); return 0; } } @@ -441,9 +403,9 @@ static int id3v23_parse_frame_header(input_plugin_t *input, len = input->read (input, buf, ID3V23_FRAME_HEADER_SIZE); if (len == ID3V23_FRAME_HEADER_SIZE) { - frame_header->id = BE_32(buf); - frame_header->size = BE_32(&buf[4]); - frame_header->flags = BE_16(buf + 8); + frame_header->id = _X_BE_32(buf); + frame_header->size = _X_BE_32(&buf[4]); + frame_header->flags = _X_BE_16(buf + 8); lprintf("frame: %c%c%c%c, size: %d, flags: %X\n", buf[0], buf[1], buf[2], buf[3], frame_header->size, frame_header->flags); @@ -460,12 +422,12 @@ static int id3v23_parse_frame_ext_header(input_plugin_t *input, if (input->read (input, buf, 4) == 4) { - frame_ext_header->size = BE_32_synchsafe(&buf[0]); + frame_ext_header->size = _X_BE_32_synchsafe(&buf[0]); if (frame_ext_header->size == 6) { if (input->read (input, buf + 4, 6) == 6) { - frame_ext_header->flags = BE_16(buf + 4); - frame_ext_header->padding_size = BE_32(buf + 6); + frame_ext_header->flags = _X_BE_16(buf + 4); + frame_ext_header->padding_size = _X_BE_32(buf + 6); frame_ext_header->crc = 0; } else { return 0; @@ -473,9 +435,9 @@ static int id3v23_parse_frame_ext_header(input_plugin_t *input, } else if (frame_ext_header->size == 10) { if (input->read (input, buf + 4, 10) == 10) { - frame_ext_header->flags = BE_16(buf + 4); - frame_ext_header->padding_size = BE_32(buf + 6); - frame_ext_header->crc = BE_32(buf + 10); + frame_ext_header->flags = _X_BE_16(buf + 4); + frame_ext_header->padding_size = _X_BE_32(buf + 6); + frame_ext_header->crc = _X_BE_32(buf + 10); } else { return 0; } @@ -497,15 +459,9 @@ static int id3v23_parse_frame_ext_header(input_plugin_t *input, static int id3v23_interp_frame(input_plugin_t *input, xine_stream_t *stream, id3v23_frame_header_t *frame_header) { - char *buf; + char buf[frame_header->size + 1]; int enc; - buf = malloc(frame_header->size + 1); - if (buf == NULL) { - lprintf("malloc error"); - return 0; - } - if (input->read (input, buf, frame_header->size) == frame_header->size) { buf[frame_header->size] = 0; enc = buf[0]; @@ -513,7 +469,7 @@ static int id3v23_interp_frame(input_plugin_t *input, enc = 0; switch (frame_header->id) { - case ( FOURCC_TAG('T', 'C', 'O', 'N') ): + case ( BE_FOURCC('T', 'C', 'O', 'N') ): { char tmp[1024]; @@ -523,27 +479,27 @@ static int id3v23_interp_frame(input_plugin_t *input, } break; - case ( FOURCC_TAG('T', 'I', 'T', '2') ): + case ( BE_FOURCC('T', 'I', 'T', '2') ): _x_meta_info_set_generic(stream, XINE_META_INFO_TITLE, buf + 1, id3_encoding[enc]); break; - case ( FOURCC_TAG('T', 'P', 'E', '1') ): + case ( BE_FOURCC('T', 'P', 'E', '1') ): _x_meta_info_set_generic(stream, XINE_META_INFO_ARTIST, buf + 1, id3_encoding[enc]); break; - case ( FOURCC_TAG('T', 'A', 'L', 'B') ): + case ( BE_FOURCC('T', 'A', 'L', 'B') ): _x_meta_info_set_generic(stream, XINE_META_INFO_ALBUM, buf + 1, id3_encoding[enc]); break; - case ( FOURCC_TAG('T', 'Y', 'E', 'R') ): + case ( BE_FOURCC('T', 'Y', 'E', 'R') ): _x_meta_info_set_generic(stream, XINE_META_INFO_YEAR, buf + 1, id3_encoding[enc]); break; - case ( FOURCC_TAG('C', 'O', 'M', 'M') ): + case ( BE_FOURCC('C', 'O', 'M', 'M') ): _x_meta_info_set_generic(stream, XINE_META_INFO_COMMENT, buf + 1 + 3, id3_encoding[enc]); break; - case ( FOURCC_TAG('T', 'R', 'C', 'K') ): + case ( BE_FOURCC('T', 'R', 'C', 'K') ): _x_meta_info_set(stream, XINE_META_INFO_TRACK_NUMBER, buf + 1); break; @@ -551,36 +507,34 @@ static int id3v23_interp_frame(input_plugin_t *input, lprintf("unhandled frame\n"); } - free(buf); return 1; } else { lprintf("read error\n"); - free(buf); return 0; } } int id3v23_parse_tag(input_plugin_t *input, xine_stream_t *stream, - int8_t *mp3_frame_header) { + uint32_t id3_signature) { id3v2_header_t tag_header; id3v23_frame_header_t tag_frame_header; id3v23_frame_ext_header_t tag_frame_ext_header; int pos = 0; - if (id3v2_parse_header(input, mp3_frame_header, &tag_header)) { + if (id3v2_parse_header(input, id3_signature, &tag_header)) { if (tag_header.flags & ID3V23_ZERO_FLAG) { /* invalid flags */ xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: invalid header flags\n"); + 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, - "id3: unsynchronized tags are not supported\n"); + LOG_MODULE ": unsynchronized tags are not supported\n"); input->seek (input, tag_header.size - pos, SEEK_CUR); return 0; } @@ -598,11 +552,11 @@ int id3v23_parse_tag(input_plugin_t *input, if ((pos + tag_frame_header.size) <= tag_header.size) { if (!id3v23_interp_frame(input, stream, &tag_frame_header)) { xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: invalid frame content\n"); + LOG_MODULE ": invalid frame content\n"); } } else { xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: invalid frame header\n"); + LOG_MODULE ": invalid frame header\n"); input->seek (input, tag_header.size - pos, SEEK_CUR); return 1; } @@ -614,13 +568,13 @@ int id3v23_parse_tag(input_plugin_t *input, } } else { xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: id3v2_parse_frame_header problem\n"); + LOG_MODULE ": id3v2_parse_frame_header problem\n"); return 0; } } return 1; } else { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "id3v23: id3v2_parse_header problem\n"); + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": id3v2_parse_header problem\n"); return 0; } } @@ -629,15 +583,15 @@ 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) { - int index = 0; + unsigned int index = 0; dest[0] = '\0'; - if (sscanf(src, "%2d", &index) == 1) { + if (sscanf(src, "%u", &index) == 1) { if (index < ID3_GENRE_COUNT) { strncpy(dest, id3_genre[index], len); dest[len - 1] = '\0'; } else { - lprintf("invalid index: %d\n", index); + lprintf("invalid index: %u\n", index); } } return 1; @@ -650,9 +604,9 @@ static int id3v24_parse_frame_header(input_plugin_t *input, len = input->read (input, buf, ID3V24_FRAME_HEADER_SIZE); if (len == ID3V24_FRAME_HEADER_SIZE) { - frame_header->id = BE_32(buf); - frame_header->size = BE_32_synchsafe(&buf[4]); - frame_header->flags = BE_16(&buf[8]); + frame_header->id = _X_BE_32(buf); + frame_header->size = _X_BE_32_synchsafe(&buf[4]); + frame_header->flags = _X_BE_16(&buf[8]); lprintf("frame: %c%c%c%c, size: %d, flags: %X\n", buf[0], buf[1], buf[2], buf[3], frame_header->size, frame_header->flags); @@ -669,7 +623,7 @@ static int id3v24_parse_ext_header(input_plugin_t *input, if (input->read (input, buf, 4) == 4) { - frame_ext_header->size = BE_32_synchsafe(&buf[0]); + frame_ext_header->size = _X_BE_32_synchsafe(&buf[0]); if (input->read (input, buf, 2) == 2) { uint8_t flags_size = buf[0]; @@ -746,15 +700,9 @@ static int id3v24_parse_ext_header(input_plugin_t *input, static int id3v24_interp_frame(input_plugin_t *input, xine_stream_t *stream, id3v24_frame_header_t *frame_header) { - char *buf; + char buf[frame_header->size + 1]; int enc; - buf = malloc(frame_header->size + 1); - if (buf == NULL) { - lprintf("malloc error"); - return 0; - } - if (input->read (input, buf, frame_header->size) == frame_header->size) { buf[frame_header->size] = 0; enc = buf[0]; @@ -764,7 +712,7 @@ static int id3v24_interp_frame(input_plugin_t *input, lprintf("data: %s\n", buf+1); switch (frame_header->id) { - case ( FOURCC_TAG('T', 'C', 'O', 'N') ): + case ( BE_FOURCC('T', 'C', 'O', 'N') ): { char tmp[1024]; @@ -774,27 +722,27 @@ static int id3v24_interp_frame(input_plugin_t *input, } break; - case ( FOURCC_TAG('T', 'I', 'T', '2') ): + case ( BE_FOURCC('T', 'I', 'T', '2') ): _x_meta_info_set_generic(stream, XINE_META_INFO_TITLE, buf + 1, id3_encoding[enc]); break; - case ( FOURCC_TAG('T', 'P', 'E', '1') ): + case ( BE_FOURCC('T', 'P', 'E', '1') ): _x_meta_info_set_generic(stream, XINE_META_INFO_ARTIST, buf + 1, id3_encoding[enc]); break; - case ( FOURCC_TAG('T', 'A', 'L', 'B') ): + case ( BE_FOURCC('T', 'A', 'L', 'B') ): _x_meta_info_set_generic(stream, XINE_META_INFO_ALBUM, buf + 1, id3_encoding[enc]); break; - case ( FOURCC_TAG('T', 'Y', 'E', 'R') ): + case ( BE_FOURCC('T', 'Y', 'E', 'R') ): _x_meta_info_set_generic(stream, XINE_META_INFO_YEAR, buf + 1, id3_encoding[enc]); break; - case ( FOURCC_TAG('C', 'O', 'M', 'M') ): + case ( BE_FOURCC('C', 'O', 'M', 'M') ): _x_meta_info_set_generic(stream, XINE_META_INFO_COMMENT, buf + 1 + 3, id3_encoding[enc]); break; - case ( FOURCC_TAG('T', 'R', 'C', 'K') ): + case ( BE_FOURCC('T', 'R', 'C', 'K') ): _x_meta_info_set(stream, XINE_META_INFO_TRACK_NUMBER, buf + 1); break; @@ -802,29 +750,27 @@ static int id3v24_interp_frame(input_plugin_t *input, lprintf("unhandled frame\n"); } - free(buf); return 1; } else { lprintf("read error\n"); - free(buf); return 0; } } int id3v24_parse_tag(input_plugin_t *input, xine_stream_t *stream, - int8_t *mp3_frame_header) { + uint32_t id3_signature) { id3v2_header_t tag_header; id3v24_frame_header_t tag_frame_header; id3v24_frame_ext_header_t tag_frame_ext_header; int pos = 0; - if (id3v2_parse_header(input, mp3_frame_header, &tag_header)) { + if (id3v2_parse_header(input, id3_signature, &tag_header)) { if (tag_header.flags & ID3V24_ZERO_FLAG) { /* invalid flags */ xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: invalid header flags\n"); + LOG_MODULE ": invalid header flags (%02x)\n", tag_header.flags); input->seek (input, tag_header.size - pos, SEEK_CUR); return 0; } @@ -848,11 +794,11 @@ int id3v24_parse_tag(input_plugin_t *input, if ((pos + tag_frame_header.size) <= tag_header.size) { if (!id3v24_interp_frame(input, stream, &tag_frame_header)) { xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: invalid frame content\n"); + LOG_MODULE ": invalid frame content\n"); } } else { xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: invalid frame header\n"); + LOG_MODULE ": invalid frame header\n"); input->seek (input, tag_header.size - pos, SEEK_CUR); return 1; } @@ -864,7 +810,7 @@ int id3v24_parse_tag(input_plugin_t *input, } } else { xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: id3v2_parse_frame_header problem\n"); + LOG_MODULE ": id3v2_parse_frame_header problem\n"); return 0; } } @@ -874,37 +820,32 @@ int id3v24_parse_tag(input_plugin_t *input, } return 1; } else { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "id3v23: id3v2_parse_header problem\n"); + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": id3v2_parse_header problem\n"); return 0; } } int id3v2_parse_tag(input_plugin_t *input, xine_stream_t *stream, - int8_t *mp3_frame_header) { - _x_assert(mp3_frame_header[0] == 'I' && mp3_frame_header[1] == 'D' && mp3_frame_header[2] == '3'); - - int result = 0; + uint32_t id3_signature) { + _x_assert((id3_signature & ID3V2X_MASK) == ID3V2X_TAG); - switch(mp3_frame_header[3]) { - case 2: - xprintf(stream->xine, XINE_VERBOSITY_LOG, "ID3V2.2 tag\n"); - result = id3v22_parse_tag(input, stream, mp3_frame_header); - break; + switch(id3_signature) { + case ID3V22_TAG: + xprintf(stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": ID3V2.2 tag\n"); + return id3v22_parse_tag(input, stream, id3_signature); - case 3: - xprintf(stream->xine, XINE_VERBOSITY_LOG, "ID3V2.3 tag\n"); - result = id3v23_parse_tag(input, stream, mp3_frame_header); - break; + case ID3V23_TAG: + xprintf(stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": ID3V2.3 tag\n"); + return id3v23_parse_tag(input, stream, id3_signature); - case 4: - xprintf(stream->xine, XINE_VERBOSITY_LOG, "ID3V2.3 tag\n"); - result = id3v24_parse_tag(input, stream, mp3_frame_header); - break; + case ID3V24_TAG: + xprintf(stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": ID3V2.4 tag\n"); + return id3v24_parse_tag(input, stream, id3_signature); default: - xprintf(stream->xine, XINE_VERBOSITY_LOG, "Unknown ID3v2 version: 0x%02x.\n", mp3_frame_header[3]); + xprintf(stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": Unknown ID3v2 signature: 0x%08x.\n", be2me_32(id3_signature)); } - - return result; + + return 0; } |