Revision 46a2da76 libavformat/id3v2.c
libavformat/id3v2.c | ||
---|---|---|
50 | 50 |
return len; |
51 | 51 |
} |
52 | 52 |
|
53 |
void ff_id3v2_read(AVFormatContext *s, const char *magic) |
|
54 |
{ |
|
55 |
int len, ret; |
|
56 |
uint8_t buf[ID3v2_HEADER_SIZE]; |
|
57 |
int found_header; |
|
58 |
int64_t off; |
|
59 |
|
|
60 |
do { |
|
61 |
/* save the current offset in case there's nothing to read/skip */ |
|
62 |
off = url_ftell(s->pb); |
|
63 |
ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE); |
|
64 |
if (ret != ID3v2_HEADER_SIZE) |
|
65 |
return; |
|
66 |
found_header = ff_id3v2_match(buf, magic); |
|
67 |
if (found_header) { |
|
68 |
/* parse ID3v2 header */ |
|
69 |
len = ((buf[6] & 0x7f) << 21) | |
|
70 |
((buf[7] & 0x7f) << 14) | |
|
71 |
((buf[8] & 0x7f) << 7) | |
|
72 |
(buf[9] & 0x7f); |
|
73 |
ff_id3v2_parse(s, len, buf[3], buf[5]); |
|
74 |
} else { |
|
75 |
url_fseek(s->pb, off, SEEK_SET); |
|
76 |
} |
|
77 |
} while (found_header); |
|
78 |
} |
|
79 |
|
|
80 | 53 |
static unsigned int get_size(ByteIOContext *s, int len) |
81 | 54 |
{ |
82 | 55 |
int v = 0; |
... | ... | |
162 | 135 |
av_metadata_set2(&s->metadata, key, val, 0); |
163 | 136 |
} |
164 | 137 |
|
165 |
void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags) |
|
138 |
static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags)
|
|
166 | 139 |
{ |
167 | 140 |
int isv34, tlen, unsync; |
168 | 141 |
char tag[5]; |
... | ... | |
276 | 249 |
av_free(buffer); |
277 | 250 |
} |
278 | 251 |
|
252 |
void ff_id3v2_read(AVFormatContext *s, const char *magic) |
|
253 |
{ |
|
254 |
int len, ret; |
|
255 |
uint8_t buf[ID3v2_HEADER_SIZE]; |
|
256 |
int found_header; |
|
257 |
int64_t off; |
|
258 |
|
|
259 |
do { |
|
260 |
/* save the current offset in case there's nothing to read/skip */ |
|
261 |
off = url_ftell(s->pb); |
|
262 |
ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE); |
|
263 |
if (ret != ID3v2_HEADER_SIZE) |
|
264 |
return; |
|
265 |
found_header = ff_id3v2_match(buf, magic); |
|
266 |
if (found_header) { |
|
267 |
/* parse ID3v2 header */ |
|
268 |
len = ((buf[6] & 0x7f) << 21) | |
|
269 |
((buf[7] & 0x7f) << 14) | |
|
270 |
((buf[8] & 0x7f) << 7) | |
|
271 |
(buf[9] & 0x7f); |
|
272 |
ff_id3v2_parse(s, len, buf[3], buf[5]); |
|
273 |
} else { |
|
274 |
url_fseek(s->pb, off, SEEK_SET); |
|
275 |
} |
|
276 |
} while (found_header); |
|
277 |
} |
|
278 |
|
|
279 | 279 |
const AVMetadataConv ff_id3v2_metadata_conv[] = { |
280 | 280 |
{ "TALB", "album"}, |
281 | 281 |
{ "TAL", "album"}, |
Also available in: Unified diff