Mercurial > libavformat.hg
annotate id3v2.c @ 4852:ecf9f13948f1 libavformat
Use get_le32/get_be32 in wc3movie demuxer instead of reading everything into
a buffer first.
author | reimar |
---|---|
date | Sat, 11 Apr 2009 18:58:55 +0000 |
parents | d05b13327b07 |
children | eb6dd7717805 |
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" |
55f448c99135
Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff
changeset
|
23 |
55f448c99135
Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff
changeset
|
24 int ff_id3v2_match(const uint8_t *buf) |
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 return buf[0] == 'I' && |
55f448c99135
Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff
changeset
|
27 buf[1] == 'D' && |
55f448c99135
Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff
changeset
|
28 buf[2] == '3' && |
55f448c99135
Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff
changeset
|
29 buf[3] != 0xff && |
55f448c99135
Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff
changeset
|
30 buf[4] != 0xff && |
55f448c99135
Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff
changeset
|
31 (buf[6] & 0x80) == 0 && |
55f448c99135
Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff
changeset
|
32 (buf[7] & 0x80) == 0 && |
55f448c99135
Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff
changeset
|
33 (buf[8] & 0x80) == 0 && |
55f448c99135
Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff
changeset
|
34 (buf[9] & 0x80) == 0; |
55f448c99135
Factorise id3v2 header parsing from mp3.c to be shared
superdump
parents:
diff
changeset
|
35 } |
4254 | 36 |
37 int ff_id3v2_tag_len(const uint8_t * buf) | |
38 { | |
39 int len = ((buf[6] & 0x7f) << 21) + | |
40 ((buf[7] & 0x7f) << 14) + | |
41 ((buf[8] & 0x7f) << 7) + | |
42 (buf[9] & 0x7f) + | |
43 ID3v2_HEADER_SIZE; | |
44 if (buf[5] & 0x10) | |
45 len += ID3v2_HEADER_SIZE; | |
46 return len; | |
47 } |