Mercurial > libavformat.hg
annotate id3v2.c @ 5332:ff45ef768724 libavformat
compute codec bitrate in mov demuxer, patch by haim alon, haim dot alter at gmail dot com
author | bcoudurier |
---|---|
date | Sat, 24 Oct 2009 20:40:00 +0000 |
parents | 3ce92654e943 |
children | 97b8e17cfbd4 |
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 { |
5017
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
28 return buf[0] == 'I' && |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
29 buf[1] == 'D' && |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
30 buf[2] == '3' && |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
31 buf[3] != 0xff && |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
32 buf[4] != 0xff && |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
33 (buf[6] & 0x80) == 0 && |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
34 (buf[7] & 0x80) == 0 && |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
35 (buf[8] & 0x80) == 0 && |
5018
2d29b49bae3e
cosmetics: Prettyprint one more line to have columns line up.
diego
parents:
5017
diff
changeset
|
36 (buf[9] & 0x80) == 0; |
4221
55f448c99135
Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff
changeset
|
37 } |
4254 | 38 |
39 int ff_id3v2_tag_len(const uint8_t * buf) | |
40 { | |
41 int len = ((buf[6] & 0x7f) << 21) + | |
5017
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
42 ((buf[7] & 0x7f) << 14) + |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
43 ((buf[8] & 0x7f) << 7) + |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
44 (buf[9] & 0x7f) + |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
45 ID3v2_HEADER_SIZE; |
4254 | 46 if (buf[5] & 0x10) |
47 len += ID3v2_HEADER_SIZE; | |
48 return len; | |
49 } | |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
50 |
5045
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5018
diff
changeset
|
51 void ff_id3v2_read(AVFormatContext *s) |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5018
diff
changeset
|
52 { |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5018
diff
changeset
|
53 int len, ret; |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5018
diff
changeset
|
54 uint8_t buf[ID3v2_HEADER_SIZE]; |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5018
diff
changeset
|
55 |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5018
diff
changeset
|
56 ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE); |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5018
diff
changeset
|
57 if (ret != ID3v2_HEADER_SIZE) |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5018
diff
changeset
|
58 return; |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5018
diff
changeset
|
59 if (ff_id3v2_match(buf)) { |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5018
diff
changeset
|
60 /* parse ID3v2 header */ |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5018
diff
changeset
|
61 len = ((buf[6] & 0x7f) << 21) | |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5018
diff
changeset
|
62 ((buf[7] & 0x7f) << 14) | |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5018
diff
changeset
|
63 ((buf[8] & 0x7f) << 7) | |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5018
diff
changeset
|
64 (buf[9] & 0x7f); |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5018
diff
changeset
|
65 ff_id3v2_parse(s, len, buf[3], buf[5]); |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5018
diff
changeset
|
66 } else { |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5018
diff
changeset
|
67 url_fseek(s->pb, 0, SEEK_SET); |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5018
diff
changeset
|
68 } |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5018
diff
changeset
|
69 } |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5018
diff
changeset
|
70 |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
71 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
|
72 { |
5017
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
73 int v = 0; |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
74 while (len--) |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
75 v = (v << 7) + (get_byte(s) & 0x7F); |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
76 return v; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
77 } |
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 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
|
80 { |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
81 char *q, dst[512]; |
5265
79be5a6fd62f
id3v2: Export all text information frames with correct names.
ramiro
parents:
5264
diff
changeset
|
82 const char *val = NULL; |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
83 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
|
84 unsigned genre; |
5231 | 85 unsigned int (*get)(ByteIOContext*) = get_be16; |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
86 |
5017
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
87 dst[0] = 0; |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
88 if (taglen < 1) |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
89 return; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
90 |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
91 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
|
92 |
5017
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
93 switch (get_byte(s->pb)) { /* encoding type */ |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
94 |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
95 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
|
96 q = dst; |
5229
4a01407f678d
id3v2: check for enough space to write full UTF-8 characters.
diego
parents:
5077
diff
changeset
|
97 while (taglen-- && q - dst < dstlen - 7) { |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
98 uint8_t tmp; |
5229
4a01407f678d
id3v2: check for enough space to write full UTF-8 characters.
diego
parents:
5077
diff
changeset
|
99 PUT_UTF8(get_byte(s->pb), tmp, *q++ = tmp;) |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
100 } |
5230 | 101 *q = 0; |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
102 break; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
103 |
5231 | 104 case 1: /* UTF-16 with BOM */ |
105 taglen -= 2; | |
106 switch (get_be16(s->pb)) { | |
107 case 0xfffe: | |
108 get = get_le16; | |
109 case 0xfeff: | |
110 break; | |
111 default: | |
112 av_log(s, AV_LOG_ERROR, "Incorrect BOM value in tag %s.\n", key); | |
113 return; | |
114 } | |
115 // fall-through | |
116 | |
117 case 2: /* UTF-16BE without BOM */ | |
118 q = dst; | |
119 while (taglen > 1 && q - dst < dstlen - 7) { | |
120 uint32_t ch; | |
121 uint8_t tmp; | |
122 | |
123 GET_UTF16(ch, ((taglen -= 2) >= 0 ? get(s->pb) : 0), break;) | |
124 PUT_UTF8(ch, tmp, *q++ = tmp;) | |
125 } | |
126 *q = 0; | |
127 break; | |
128 | |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
129 case 3: /* UTF-8 */ |
5017
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
130 len = FFMIN(taglen, dstlen - 1); |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
131 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
|
132 dst[len] = 0; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
133 break; |
5231 | 134 default: |
135 av_log(s, AV_LOG_WARNING, "Unknown encoding in tag %s\n.", key); | |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
136 } |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
137 |
5265
79be5a6fd62f
id3v2: Export all text information frames with correct names.
ramiro
parents:
5264
diff
changeset
|
138 if (!(strcmp(key, "TCON") && strcmp(key, "TCO")) |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
139 && (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
|
140 && genre <= ID3v1_GENRE_MAX) |
5265
79be5a6fd62f
id3v2: Export all text information frames with correct names.
ramiro
parents:
5264
diff
changeset
|
141 val = ff_id3v1_genre_str[genre]; |
79be5a6fd62f
id3v2: Export all text information frames with correct names.
ramiro
parents:
5264
diff
changeset
|
142 else if (!(strcmp(key, "TXXX") && strcmp(key, "TXX"))) { |
79be5a6fd62f
id3v2: Export all text information frames with correct names.
ramiro
parents:
5264
diff
changeset
|
143 /* dst now contains two 0-terminated strings */ |
79be5a6fd62f
id3v2: Export all text information frames with correct names.
ramiro
parents:
5264
diff
changeset
|
144 dst[dstlen] = 0; |
79be5a6fd62f
id3v2: Export all text information frames with correct names.
ramiro
parents:
5264
diff
changeset
|
145 len = strlen(dst); |
79be5a6fd62f
id3v2: Export all text information frames with correct names.
ramiro
parents:
5264
diff
changeset
|
146 key = dst; |
79be5a6fd62f
id3v2: Export all text information frames with correct names.
ramiro
parents:
5264
diff
changeset
|
147 val = dst + FFMIN(len + 1, dstlen); |
79be5a6fd62f
id3v2: Export all text information frames with correct names.
ramiro
parents:
5264
diff
changeset
|
148 } |
79be5a6fd62f
id3v2: Export all text information frames with correct names.
ramiro
parents:
5264
diff
changeset
|
149 else if (*dst) |
79be5a6fd62f
id3v2: Export all text information frames with correct names.
ramiro
parents:
5264
diff
changeset
|
150 val = dst; |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
151 |
5265
79be5a6fd62f
id3v2: Export all text information frames with correct names.
ramiro
parents:
5264
diff
changeset
|
152 if (val) |
79be5a6fd62f
id3v2: Export all text information frames with correct names.
ramiro
parents:
5264
diff
changeset
|
153 av_metadata_set(&s->metadata, key, val); |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
154 } |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
155 |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
156 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
|
157 { |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
158 int isv34, tlen; |
5265
79be5a6fd62f
id3v2: Export all text information frames with correct names.
ramiro
parents:
5264
diff
changeset
|
159 char tag[5]; |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
160 int64_t next; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
161 int taghdrlen; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
162 const char *reason; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
163 |
5017
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
164 switch (version) { |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
165 case 2: |
5017
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
166 if (flags & 0x40) { |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
167 reason = "compression"; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
168 goto error; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
169 } |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
170 isv34 = 0; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
171 taghdrlen = 6; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
172 break; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
173 |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
174 case 3: |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
175 case 4: |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
176 isv34 = 1; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
177 taghdrlen = 10; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
178 break; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
179 |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
180 default: |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
181 reason = "version"; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
182 goto error; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
183 } |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
184 |
5017
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
185 if (flags & 0x80) { |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
186 reason = "unsynchronization"; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
187 goto error; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
188 } |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
189 |
5017
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
190 if (isv34 && flags & 0x40) /* Extended header present, just skip over it */ |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
191 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
|
192 |
5017
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
193 while (len >= taghdrlen) { |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
194 if (isv34) { |
5265
79be5a6fd62f
id3v2: Export all text information frames with correct names.
ramiro
parents:
5264
diff
changeset
|
195 get_buffer(s->pb, tag, 4); |
79be5a6fd62f
id3v2: Export all text information frames with correct names.
ramiro
parents:
5264
diff
changeset
|
196 tag[4] = 0; |
5076
e07fb352a12c
id3v2.4.0 uses syncsafe integers for sizes of frames.
michael
parents:
5073
diff
changeset
|
197 if(version==3){ |
5077 | 198 tlen = get_be32(s->pb); |
5076
e07fb352a12c
id3v2.4.0 uses syncsafe integers for sizes of frames.
michael
parents:
5073
diff
changeset
|
199 }else |
e07fb352a12c
id3v2.4.0 uses syncsafe integers for sizes of frames.
michael
parents:
5073
diff
changeset
|
200 tlen = get_size(s->pb, 4); |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
201 get_be16(s->pb); /* flags */ |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
202 } else { |
5265
79be5a6fd62f
id3v2: Export all text information frames with correct names.
ramiro
parents:
5264
diff
changeset
|
203 get_buffer(s->pb, tag, 3); |
79be5a6fd62f
id3v2: Export all text information frames with correct names.
ramiro
parents:
5264
diff
changeset
|
204 tag[3] = 0; |
5073 | 205 tlen = get_be24(s->pb); |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
206 } |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
207 len -= taghdrlen + tlen; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
208 |
5017
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
209 if (len < 0) |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
210 break; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
211 |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
212 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
|
213 |
5265
79be5a6fd62f
id3v2: Export all text information frames with correct names.
ramiro
parents:
5264
diff
changeset
|
214 if (tag[0] == 'T') |
79be5a6fd62f
id3v2: Export all text information frames with correct names.
ramiro
parents:
5264
diff
changeset
|
215 read_ttag(s, tlen, tag); |
5286 | 216 else if (!tag[0]) { |
217 if (tag[1]) | |
218 av_log(s, AV_LOG_WARNING, "invalid frame id, assuming padding"); | |
219 url_fskip(s->pb, len); | |
220 break; | |
221 } | |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
222 /* Skip to end of tag */ |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
223 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
|
224 } |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
225 |
5017
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
226 if (version == 4 && flags & 0x10) /* Footer preset, always 10 bytes, skip over it */ |
5016
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
227 url_fskip(s->pb, 10); |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
228 return; |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
229 |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
230 error: |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
231 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
|
232 url_fskip(s->pb, len); |
eb6dd7717805
Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents:
4254
diff
changeset
|
233 } |
5236
1403c88b1ce7
Add id3v2 metadata conversion table and use it in mp3 muxer.
cehoyos
parents:
5231
diff
changeset
|
234 |
1403c88b1ce7
Add id3v2 metadata conversion table and use it in mp3 muxer.
cehoyos
parents:
5231
diff
changeset
|
235 const AVMetadataConv ff_id3v2_metadata_conv[] = { |
1403c88b1ce7
Add id3v2 metadata conversion table and use it in mp3 muxer.
cehoyos
parents:
5231
diff
changeset
|
236 { "TALB", "album"}, |
1403c88b1ce7
Add id3v2 metadata conversion table and use it in mp3 muxer.
cehoyos
parents:
5231
diff
changeset
|
237 { "TCOM", "composer"}, |
1403c88b1ce7
Add id3v2 metadata conversion table and use it in mp3 muxer.
cehoyos
parents:
5231
diff
changeset
|
238 { "TCON", "genre"}, |
1403c88b1ce7
Add id3v2 metadata conversion table and use it in mp3 muxer.
cehoyos
parents:
5231
diff
changeset
|
239 { "TCOP", "copyright"}, |
1403c88b1ce7
Add id3v2 metadata conversion table and use it in mp3 muxer.
cehoyos
parents:
5231
diff
changeset
|
240 { "TDRL", "date"}, |
1403c88b1ce7
Add id3v2 metadata conversion table and use it in mp3 muxer.
cehoyos
parents:
5231
diff
changeset
|
241 { "TENC", "encoder"}, |
1403c88b1ce7
Add id3v2 metadata conversion table and use it in mp3 muxer.
cehoyos
parents:
5231
diff
changeset
|
242 { "TIT2", "title"}, |
1403c88b1ce7
Add id3v2 metadata conversion table and use it in mp3 muxer.
cehoyos
parents:
5231
diff
changeset
|
243 { "TLAN", "language"}, |
1403c88b1ce7
Add id3v2 metadata conversion table and use it in mp3 muxer.
cehoyos
parents:
5231
diff
changeset
|
244 { "TPE1", "author"}, |
1403c88b1ce7
Add id3v2 metadata conversion table and use it in mp3 muxer.
cehoyos
parents:
5231
diff
changeset
|
245 { "TPOS", "disc"}, |
1403c88b1ce7
Add id3v2 metadata conversion table and use it in mp3 muxer.
cehoyos
parents:
5231
diff
changeset
|
246 { "TPUB", "publisher"}, |
1403c88b1ce7
Add id3v2 metadata conversion table and use it in mp3 muxer.
cehoyos
parents:
5231
diff
changeset
|
247 { "TRCK", "track"}, |
1403c88b1ce7
Add id3v2 metadata conversion table and use it in mp3 muxer.
cehoyos
parents:
5231
diff
changeset
|
248 { "TSOA", "albumsort"}, |
1403c88b1ce7
Add id3v2 metadata conversion table and use it in mp3 muxer.
cehoyos
parents:
5231
diff
changeset
|
249 { "TSOP", "authorsort"}, |
1403c88b1ce7
Add id3v2 metadata conversion table and use it in mp3 muxer.
cehoyos
parents:
5231
diff
changeset
|
250 { "TSOT", "titlesort"}, |
1403c88b1ce7
Add id3v2 metadata conversion table and use it in mp3 muxer.
cehoyos
parents:
5231
diff
changeset
|
251 { 0 } |
1403c88b1ce7
Add id3v2 metadata conversion table and use it in mp3 muxer.
cehoyos
parents:
5231
diff
changeset
|
252 }; |
5264 | 253 |
254 const char ff_id3v2_tags[][4] = { | |
255 "TALB", "TBPM", "TCOM", "TCON", "TCOP", "TDEN", "TDLY", "TDOR", "TDRC", | |
256 "TDRL", "TDTG", "TENC", "TEXT", "TFLT", "TIPL", "TIT1", "TIT2", "TIT3", | |
257 "TKEY", "TLAN", "TLEN", "TMCL", "TMED", "TMOO", "TOAL", "TOFN", "TOLY", | |
258 "TOPE", "TOWN", "TPE1", "TPE2", "TPE3", "TPE4", "TPOS", "TPRO", "TPUB", | |
259 "TRCK", "TRSN", "TRSO", "TSOA", "TSOP", "TSOT", "TSRC", "TSSE", "TSST", | |
260 { 0 }, | |
261 }; |