1 /*
2 * BRSTM demuxer
3 * Copyright (c) 2012 Paul B Mahol
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
26
36
38 {
43 return 0;
44 }
45
47 {
49
52
53 return 0;
54 }
55
57 {
59 int bom, major, minor, codec, chunk;
60 int64_t pos, h1offset, toffset;
64
66 if (!st)
69
71
73 if (bom != 0xFEFF && bom != 0xFFFE) {
76 }
77 if (bom == 0xFFFE) {
80 }
81
86 if (size < 14)
88
94 if (size < 256)
98 if (h1offset > size)
102 if (toffset > size)
104
107
108 switch (codec) {
112 default:
115 }
116
122
127
133
140 }
141
146
152
155
157 int ch;
158
161 if (toffset > size)
163
168
172 goto fail;
173 }
175 }
176 }
177
180 goto fail;
181 }
183
187 if (size < 8) {
189 goto fail;
190 }
191 size -= 8;
192 switch (chunk) {
193 case MKTAG(
'A',
'D',
'P',
'C'):
195 goto skip;
196
198 if (size < asize) {
200 goto fail;
201 }
204 goto skip;
205 } else {
209 goto fail;
210 }
213 }
214 break;
215 case MKTAG(
'D',
'A',
'T',
'A'):
219 goto fail;
220 }
222
223 if (major != 1 || minor)
225
226 return 0;
227 default:
229 skip:
231 }
232 }
233
234 fail:
236
238 }
239
241 {
244 uint32_t samples,
size;
246
252 samples = size / (8 * codec->
channels) * 14;
256 } else {
258 }
259
262
266 bytestream_put_be32(&dst, size);
267 bytestream_put_be32(&dst, samples);
271
273 if (ret != size)
276 } else {
278 }
279
281
282 if (ret != size)
284
286 }
287
296 .extensions = "brstm",
297 };