Mercurial > libavformat.hg
annotate oggparsevorbis.c @ 2279:3c02e08e7b5a libavformat
use the most appropriate codec id for A_MPEG/L1 and L2
author | aurel |
---|---|
date | Wed, 25 Jul 2007 15:59:26 +0000 |
parents | 7c13baaa4f87 |
children | a7755990bb9c |
rev | line source |
---|---|
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
1 /** |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
2 Copyright (C) 2005 Michael Ahlberg, Måns Rullgård |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
3 |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
4 Permission is hereby granted, free of charge, to any person |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
5 obtaining a copy of this software and associated documentation |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
6 files (the "Software"), to deal in the Software without |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
7 restriction, including without limitation the rights to use, copy, |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
8 modify, merge, publish, distribute, sublicense, and/or sell copies |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
9 of the Software, and to permit persons to whom the Software is |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
10 furnished to do so, subject to the following conditions: |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
11 |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
12 The above copyright notice and this permission notice shall be |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
13 included in all copies or substantial portions of the Software. |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
14 |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
16 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
17 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
18 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
19 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
20 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
22 DEALINGS IN THE SOFTWARE. |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
23 **/ |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
24 |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
25 #include <stdlib.h> |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
26 #include "avformat.h" |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
27 #include "bitstream.h" |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
28 #include "bswap.h" |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
29 #include "ogg2.h" |
2194 | 30 #include "avstring.h" |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
31 |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
32 extern int |
2197 | 33 vorbis_comment(AVFormatContext * as, uint8_t *buf, int size) |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
34 { |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
35 char *p = buf; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
36 int s, n, j; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
37 |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
38 if (size < 4) |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
39 return -1; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
40 |
2196 | 41 s = AV_RL32(p); |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
42 p += 4; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
43 size -= 4; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
44 |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
45 if (size < s + 4) |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
46 return -1; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
47 |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
48 p += s; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
49 size -= s; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
50 |
2196 | 51 n = AV_RL32(p); |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
52 p += 4; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
53 size -= 4; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
54 |
2197 | 55 while (size >= 4) { |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
56 char *t, *v; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
57 int tl, vl; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
58 |
2196 | 59 s = AV_RL32(p); |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
60 p += 4; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
61 size -= 4; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
62 |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
63 if (size < s) |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
64 break; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
65 |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
66 t = p; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
67 p += s; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
68 size -= s; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
69 n--; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
70 |
2197 | 71 v = memchr(t, '=', s); |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
72 if (!v) |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
73 continue; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
74 |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
75 tl = v - t; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
76 vl = s - tl - 1; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
77 v++; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
78 |
2197 | 79 if (tl && vl) { |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
80 char tt[tl + 1]; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
81 char ct[vl + 1]; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
82 |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
83 for (j = 0; j < tl; j++) |
2197 | 84 tt[j] = toupper(t[j]); |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
85 tt[tl] = 0; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
86 |
2197 | 87 memcpy(ct, v, vl); |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
88 ct[vl] = 0; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
89 |
885 | 90 // took from Vorbis_I_spec |
2197 | 91 if (!strcmp(tt, "AUTHOR") || !strcmp(tt, "ARTIST")) |
92 av_strlcpy(as->author, ct, sizeof(as->author)); | |
93 else if (!strcmp(tt, "TITLE")) | |
94 av_strlcpy(as->title, ct, sizeof(as->title)); | |
95 else if (!strcmp(tt, "COPYRIGHT")) | |
96 av_strlcpy(as->copyright, ct, sizeof(as->copyright)); | |
97 else if (!strcmp(tt, "DESCRIPTION")) | |
98 av_strlcpy(as->comment, ct, sizeof(as->comment)); | |
99 else if (!strcmp(tt, "GENRE")) | |
100 av_strlcpy(as->genre, ct, sizeof(as->genre)); | |
101 else if (!strcmp(tt, "TRACKNUMBER")) | |
102 as->track = atoi(ct); | |
2195 | 103 else if (!strcmp(tt, "ALBUM")) |
104 av_strlcpy(as->album, ct, sizeof(as->album)); | |
105 else if (!strcmp(tt, "GENRE")) | |
106 av_strlcpy(as->genre, ct, sizeof(as->genre)); | |
107 else if (!strcmp(tt, "DESCRIPTION")) | |
108 av_strlcpy(as->comment, ct, sizeof(as->comment)); | |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
109 } |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
110 } |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
111 |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
112 if (size > 0) |
2197 | 113 av_log(as, AV_LOG_INFO, "%i bytes of comment header remain\n", size); |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
114 if (n > 0) |
2197 | 115 av_log(as, AV_LOG_INFO, |
116 "truncated comment header, %i comments not found\n", n); | |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
117 |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
118 return 0; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
119 } |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
120 |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
121 |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
122 /** Parse the vorbis header |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
123 * Vorbis Identification header from Vorbis_I_spec.html#vorbis-spec-codec |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
124 * [vorbis_version] = read 32 bits as unsigned integer | Not used |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
125 * [audio_channels] = read 8 bit integer as unsigned | Used |
885 | 126 * [audio_sample_rate] = read 32 bits as unsigned integer | Used |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
127 * [bitrate_maximum] = read 32 bits as signed integer | Not used yet |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
128 * [bitrate_nominal] = read 32 bits as signed integer | Not used yet |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
129 * [bitrate_minimum] = read 32 bits as signed integer | Used as bitrate |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
130 * [blocksize_0] = read 4 bits as unsigned integer | Not Used |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
131 * [blocksize_1] = read 4 bits as unsigned integer | Not Used |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
132 * [framing_flag] = read one bit | Not Used |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
133 * */ |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
134 |
760 | 135 typedef struct { |
136 unsigned int len[3]; | |
137 unsigned char *packet[3]; | |
138 } oggvorbis_private_t; | |
139 | |
140 | |
141 static unsigned int | |
142 fixup_vorbis_headers(AVFormatContext * as, oggvorbis_private_t *priv, | |
2198 | 143 uint8_t **buf) |
760 | 144 { |
145 int i,offset, len; | |
146 unsigned char *ptr; | |
147 | |
148 len = priv->len[0] + priv->len[1] + priv->len[2]; | |
149 ptr = *buf = av_mallocz(len + len/255 + 64); | |
150 | |
151 ptr[0] = 2; | |
152 offset = 1; | |
153 offset += av_xiphlacing(&ptr[offset], priv->len[0]); | |
154 offset += av_xiphlacing(&ptr[offset], priv->len[1]); | |
2197 | 155 for (i = 0; i < 3; i++) { |
760 | 156 memcpy(&ptr[offset], priv->packet[i], priv->len[i]); |
157 offset += priv->len[i]; | |
158 } | |
159 *buf = av_realloc(*buf, offset); | |
160 return offset; | |
161 } | |
162 | |
163 | |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
164 static int |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
165 vorbis_header (AVFormatContext * s, int idx) |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
166 { |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
167 ogg_t *ogg = s->priv_data; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
168 ogg_stream_t *os = ogg->streams + idx; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
169 AVStream *st = s->streams[idx]; |
760 | 170 oggvorbis_private_t *priv; |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
171 |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
172 if (os->seq > 2) |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
173 return 0; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
174 |
2197 | 175 if (os->seq == 0) { |
760 | 176 os->private = av_mallocz(sizeof(oggvorbis_private_t)); |
2197 | 177 if (!os->private) |
760 | 178 return 0; |
179 } | |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
180 |
760 | 181 priv = os->private; |
182 priv->len[os->seq] = os->psize; | |
183 priv->packet[os->seq] = av_mallocz(os->psize); | |
184 memcpy(priv->packet[os->seq], os->buf + os->pstart, os->psize); | |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
185 if (os->buf[os->pstart] == 1) { |
729 | 186 uint8_t *p = os->buf + os->pstart + 11; //skip up to the audio channels |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
760
diff
changeset
|
187 st->codec->channels = *p++; |
2196 | 188 st->codec->sample_rate = AV_RL32(p); |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
189 p += 8; //skip maximum and and nominal bitrate |
2196 | 190 st->codec->bit_rate = AV_RL32(p); //Minimum bitrate |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
191 |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
760
diff
changeset
|
192 st->codec->codec_type = CODEC_TYPE_AUDIO; |
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
760
diff
changeset
|
193 st->codec->codec_id = CODEC_ID_VORBIS; |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
194 |
1077 | 195 st->time_base.num = 1; |
196 st->time_base.den = st->codec->sample_rate; | |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
197 } else if (os->buf[os->pstart] == 3) { |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
198 vorbis_comment (s, os->buf + os->pstart + 7, os->psize - 8); |
760 | 199 } else { |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
760
diff
changeset
|
200 st->codec->extradata_size = |
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
760
diff
changeset
|
201 fixup_vorbis_headers(s, priv, &st->codec->extradata); |
726
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
202 } |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
203 |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
204 return os->seq < 3; |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
205 } |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
206 |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
207 ogg_codec_t vorbis_codec = { |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
208 .magic = "\001vorbis", |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
209 .magicsize = 7, |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
210 .header = vorbis_header |
17178af951b4
Ogg demuxer ported from tcvp by Luca Barbato <lu_zero at gentoo dot org>,
mru
parents:
diff
changeset
|
211 }; |