Mercurial > libavcodec.hg
annotate xiph.c @ 5297:fc46b3f5de1a libavcodec
indent
author | mru |
---|---|
date | Thu, 12 Jul 2007 22:55:35 +0000 |
parents | 7595ead28402 |
children | b1049dd41dd4 |
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 { |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
27 int i, j; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
28 |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
29 if (AV_RB16(extradata) == first_header_size) { |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
30 for (i=0; i<3; i++) { |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
31 header_len[i] = AV_RB16(extradata); |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
32 extradata += 2; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
33 header_start[i] = extradata; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
34 extradata += header_len[i]; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
35 } |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
36 } else if (extradata[0] == 2) { |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
37 for (i=0,j=1; i<2; i++,j++) { |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
38 header_len[i] = 0; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
39 for (; j<extradata_size && extradata[j]==0xff; j++) { |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
40 header_len[i] += 0xff; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
41 } |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
42 if (j >= extradata_size) |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
43 return -1; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
44 |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
45 header_len[i] += extradata[j]; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
46 } |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
47 header_len[2] = extradata_size - header_len[0] - header_len[1] - j; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
48 extradata += j; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
49 header_start[0] = extradata; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
50 header_start[1] = header_start[0] + header_len[0]; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
51 header_start[2] = header_start[1] + header_len[1]; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
52 } else { |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
53 return -1; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
54 } |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
55 return 0; |
7595ead28402
extract vorbis header spliting code into a reusable function
aurel
parents:
diff
changeset
|
56 } |