annotate id3v2.c @ 5016:eb6dd7717805 libavformat

Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c. patch by Patrick Dehne, patrick mysonicweb com
author diego
date Thu, 11 Jun 2009 15:26:57 +0000
parents d05b13327b07
children 1763f7d0d8d0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4221
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
1 /*
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
2 * ID3v2 header parser
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
3 * Copyright (c) 2003 Fabrice Bellard
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
4 *
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
5 * This file is part of FFmpeg.
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
6 *
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
11 *
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
15 * Lesser General Public License for more details.
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
16 *
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
20 */
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
21
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
22 #include "id3v2.h"
5016
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
23 #include "id3v1.h"
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
24 #include "libavutil/avstring.h"
4221
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
25
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
26 int ff_id3v2_match(const uint8_t *buf)
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
27 {
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
28 return buf[0] == 'I' &&
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
29 buf[1] == 'D' &&
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
30 buf[2] == '3' &&
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
31 buf[3] != 0xff &&
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
32 buf[4] != 0xff &&
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
33 (buf[6] & 0x80) == 0 &&
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
34 (buf[7] & 0x80) == 0 &&
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
35 (buf[8] & 0x80) == 0 &&
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
36 (buf[9] & 0x80) == 0;
55f448c99135 Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff changeset
37 }
4254
d05b13327b07 Fix probing of files with ID3v2 tags. Discussed at
alexc
parents: 4221
diff changeset
38
d05b13327b07 Fix probing of files with ID3v2 tags. Discussed at
alexc
parents: 4221
diff changeset
39 int ff_id3v2_tag_len(const uint8_t * buf)
d05b13327b07 Fix probing of files with ID3v2 tags. Discussed at
alexc
parents: 4221
diff changeset
40 {
d05b13327b07 Fix probing of files with ID3v2 tags. Discussed at
alexc
parents: 4221
diff changeset
41 int len = ((buf[6] & 0x7f) << 21) +
d05b13327b07 Fix probing of files with ID3v2 tags. Discussed at
alexc
parents: 4221
diff changeset
42 ((buf[7] & 0x7f) << 14) +
d05b13327b07 Fix probing of files with ID3v2 tags. Discussed at
alexc
parents: 4221
diff changeset
43 ((buf[8] & 0x7f) << 7) +
d05b13327b07 Fix probing of files with ID3v2 tags. Discussed at
alexc
parents: 4221
diff changeset
44 (buf[9] & 0x7f) +
d05b13327b07 Fix probing of files with ID3v2 tags. Discussed at
alexc
parents: 4221
diff changeset
45 ID3v2_HEADER_SIZE;
d05b13327b07 Fix probing of files with ID3v2 tags. Discussed at
alexc
parents: 4221
diff changeset
46 if (buf[5] & 0x10)
d05b13327b07 Fix probing of files with ID3v2 tags. Discussed at
alexc
parents: 4221
diff changeset
47 len += ID3v2_HEADER_SIZE;
d05b13327b07 Fix probing of files with ID3v2 tags. Discussed at
alexc
parents: 4221
diff changeset
48 return len;
d05b13327b07 Fix probing of files with ID3v2 tags. Discussed at
alexc
parents: 4221
diff changeset
49 }
5016
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
50
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
51 static unsigned int get_size(ByteIOContext *s, int len)
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
52 {
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
53 int v=0;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
54 while(len--)
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
55 v= (v<<7) + (get_byte(s)&0x7F);
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
56 return v;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
57 }
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
58
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
59 static void read_ttag(AVFormatContext *s, int taglen, const char *key)
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
60 {
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
61 char *q, dst[512];
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
62 int len, dstlen = sizeof(dst) - 1;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
63 unsigned genre;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
64
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
65 dst[0]= 0;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
66 if(taglen < 1)
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
67 return;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
68
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
69 taglen--; /* account for encoding type byte */
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
70
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
71 switch(get_byte(s->pb)) { /* encoding type */
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
72
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
73 case 0: /* ISO-8859-1 (0 - 255 maps directly into unicode) */
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
74 q = dst;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
75 while(taglen--) {
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
76 uint8_t tmp;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
77 PUT_UTF8(get_byte(s->pb), tmp, if (q - dst < dstlen - 1) *q++ = tmp;)
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
78 }
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
79 *q = '\0';
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
80 break;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
81
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
82 case 3: /* UTF-8 */
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
83 len = FFMIN(taglen, dstlen-1);
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
84 get_buffer(s->pb, dst, len);
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
85 dst[len] = 0;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
86 break;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
87 }
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
88
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
89 if (!strcmp(key, "genre")
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
90 && (sscanf(dst, "(%d)", &genre) == 1 || sscanf(dst, "%d", &genre) == 1)
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
91 && genre <= ID3v1_GENRE_MAX)
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
92 av_strlcpy(dst, ff_id3v1_genre_str[genre], sizeof(dst));
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
93
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
94 if (*dst)
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
95 av_metadata_set(&s->metadata, key, dst);
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
96 }
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
97
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
98 void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags)
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
99 {
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
100 int isv34, tlen;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
101 uint32_t tag;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
102 int64_t next;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
103 int taghdrlen;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
104 const char *reason;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
105
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
106 switch(version) {
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
107 case 2:
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
108 if(flags & 0x40) {
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
109 reason = "compression";
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
110 goto error;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
111 }
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
112 isv34 = 0;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
113 taghdrlen = 6;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
114 break;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
115
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
116 case 3:
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
117 case 4:
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
118 isv34 = 1;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
119 taghdrlen = 10;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
120 break;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
121
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
122 default:
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
123 reason = "version";
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
124 goto error;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
125 }
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
126
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
127 if(flags & 0x80) {
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
128 reason = "unsynchronization";
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
129 goto error;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
130 }
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
131
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
132 if(isv34 && flags & 0x40) /* Extended header present, just skip over it */
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
133 url_fskip(s->pb, get_size(s->pb, 4));
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
134
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
135 while(len >= taghdrlen) {
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
136 if(isv34) {
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
137 tag = get_be32(s->pb);
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
138 tlen = get_size(s->pb, 4);
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
139 get_be16(s->pb); /* flags */
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
140 } else {
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
141 tag = get_be24(s->pb);
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
142 tlen = get_size(s->pb, 3);
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
143 }
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
144 len -= taghdrlen + tlen;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
145
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
146 if(len < 0)
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
147 break;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
148
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
149 next = url_ftell(s->pb) + tlen;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
150
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
151 switch(tag) {
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
152 case MKBETAG('T', 'I', 'T', '2'):
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
153 case MKBETAG(0, 'T', 'T', '2'):
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
154 read_ttag(s, tlen, "title");
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
155 break;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
156 case MKBETAG('T', 'P', 'E', '1'):
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
157 case MKBETAG(0, 'T', 'P', '1'):
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
158 read_ttag(s, tlen, "author");
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
159 break;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
160 case MKBETAG('T', 'A', 'L', 'B'):
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
161 case MKBETAG(0, 'T', 'A', 'L'):
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
162 read_ttag(s, tlen, "album");
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
163 break;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
164 case MKBETAG('T', 'C', 'O', 'N'):
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
165 case MKBETAG(0, 'T', 'C', 'O'):
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
166 read_ttag(s, tlen, "genre");
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
167 break;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
168 case MKBETAG('T', 'C', 'O', 'P'):
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
169 case MKBETAG(0, 'T', 'C', 'R'):
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
170 read_ttag(s, tlen, "copyright");
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
171 break;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
172 case MKBETAG('T', 'R', 'C', 'K'):
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
173 case MKBETAG(0, 'T', 'R', 'K'):
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
174 read_ttag(s, tlen, "track");
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
175 break;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
176 case 0:
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
177 /* padding, skip to end */
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
178 url_fskip(s->pb, len);
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
179 len = 0;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
180 continue;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
181 }
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
182 /* Skip to end of tag */
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
183 url_fseek(s->pb, next, SEEK_SET);
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
184 }
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
185
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
186 if(version == 4 && flags & 0x10) /* Footer preset, always 10 bytes, skip over it */
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
187 url_fskip(s->pb, 10);
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
188 return;
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
189
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
190 error:
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
191 av_log(s, AV_LOG_INFO, "ID3v2.%d tag skipped, cannot handle %s\n", version, reason);
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
192 url_fskip(s->pb, len);
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
193 }
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4254
diff changeset
194