Mercurial > libavcodec.hg
annotate xiph.c @ 7287:697213189d07 libavcodec
Print slice num as well.
author | michael |
---|---|
date | Wed, 16 Jul 2008 01:57:28 +0000 |
parents | 2574def95b50 |
children | 2acf0ae7b041 |
rev | line source |
---|---|
4722
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
1 /* |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
2 * Copyright (C) 2007 FFmpeg Project |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
3 * |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
4 * This file is part of FFmpeg. |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
5 * |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
6 * FFmpeg is free software; you can redistribute it and/or |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
7 * modify it under the terms of the GNU Lesser General Public |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
8 * License as published by the Free Software Foundation; either |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
9 * version 2.1 of the License, or (at your option) any later version. |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
10 * |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
11 * FFmpeg is distributed in the hope that it will be useful, |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
14 * Lesser General Public License for more details. |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
15 * |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
16 * You should have received a copy of the GNU Lesser General Public |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
17 * License along with FFmpeg; if not, write to the Free Software |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
19 */ |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
20 |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
21 #include "xiph.h" |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
22 |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
23 int ff_split_xiph_headers(uint8_t *extradata, int extradata_size, |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
24 int first_header_size, uint8_t *header_start[3], |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
25 int header_len[3]) |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
26 { |
6657 | 27 int i; |
4722
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
28 |
6656
b1049dd41dd4
Add checks to ff_split_xiph_headers to ensure that returned header_len and
reimar
parents:
4722
diff
changeset
|
29 if (extradata_size >= 6 && AV_RB16(extradata) == first_header_size) { |
b1049dd41dd4
Add checks to ff_split_xiph_headers to ensure that returned header_len and
reimar
parents:
4722
diff
changeset
|
30 int overall_len = 6; |
4722
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
31 for (i=0; i<3; i++) { |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
32 header_len[i] = AV_RB16(extradata); |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
33 extradata += 2; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
34 header_start[i] = extradata; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
35 extradata += header_len[i]; |
6656
b1049dd41dd4
Add checks to ff_split_xiph_headers to ensure that returned header_len and
reimar
parents:
4722
diff
changeset
|
36 if (overall_len > extradata_size - header_len[i]) |
b1049dd41dd4
Add checks to ff_split_xiph_headers to ensure that returned header_len and
reimar
parents:
4722
diff
changeset
|
37 return -1; |
b1049dd41dd4
Add checks to ff_split_xiph_headers to ensure that returned header_len and
reimar
parents:
4722
diff
changeset
|
38 overall_len += header_len[i]; |
4722
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
39 } |
6656
b1049dd41dd4
Add checks to ff_split_xiph_headers to ensure that returned header_len and
reimar
parents:
4722
diff
changeset
|
40 } else if (extradata_size >= 3 && extradata_size < INT_MAX - 0x1ff && extradata[0] == 2) { |
b1049dd41dd4
Add checks to ff_split_xiph_headers to ensure that returned header_len and
reimar
parents:
4722
diff
changeset
|
41 int overall_len = 3; |
6657 | 42 extradata++; |
43 for (i=0; i<2; i++, extradata++) { | |
4722
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
44 header_len[i] = 0; |
6657 | 45 for (; overall_len < extradata_size && *extradata==0xff; extradata++) { |
4722
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
46 header_len[i] += 0xff; |
6656
b1049dd41dd4
Add checks to ff_split_xiph_headers to ensure that returned header_len and
reimar
parents:
4722
diff
changeset
|
47 overall_len += 0xff + 1; |
4722
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
48 } |
6657 | 49 header_len[i] += *extradata; |
50 overall_len += *extradata; | |
6656
b1049dd41dd4
Add checks to ff_split_xiph_headers to ensure that returned header_len and
reimar
parents:
4722
diff
changeset
|
51 if (overall_len > extradata_size) |
4722
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
52 return -1; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
53 } |
6657 | 54 header_len[2] = extradata_size - overall_len; |
4722
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
55 header_start[0] = extradata; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
56 header_start[1] = header_start[0] + header_len[0]; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
57 header_start[2] = header_start[1] + header_len[1]; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
58 } else { |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
59 return -1; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
60 } |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
61 return 0; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
62 } |