1 /*
2 * RIFF demuxing functions and data
3 * Copyright (c) 2000 Fabrice Bellard
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
30
32 {
34 av_assert0(
sizeof(*
g) == 16);
//compiler will optimize this out
37 memset(*
g, 0,
sizeof(*
g));
39 }
40 return 0;
41 }
42
44 {
50 }
51
52 /* We could be given one of the three possible structures here:
53 * WAVEFORMAT, PCMWAVEFORMAT or WAVEFORMATEX. Each structure
54 * is an expansion of the previous one with the fields added
55 * at the bottom. PCMWAVEFORMAT adds 'WORD wBitsPerSample' and
56 * WAVEFORMATEX adds 'WORD cbSize' and basically makes itself
57 * an openended structure.
58 */
59
61 {
64
69
71 if (!memcmp(subformat + 4,
73 !memcmp(subformat + 4,
75 !memcmp(subformat + 4,
80 } else {
86 }
87 }
88
89 /* "big_endian" values are needed for RIFX file format */
92 {
95
99 }
100
102 if (!big_endian) {
104 if (id != 0x0165) {
109 }
110 } else {
116 }
117 if (
size == 14) {
/* We're dealing with plain vanilla WAVEFORMAT */
119 } else {
120 if (!big_endian) {
122 } else {
124 }
125 }
126 if (id == 0xFFFE) {
128 } else {
132 }
133 if (
size >= 18 &&
id != 0x0165) {
/* We're obviously dealing with WAVEFORMATEX */
135 if (big_endian) {
138 }
141 if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */
143 cbSize -= 22;
145 }
146 if (cbSize > 0) {
150 }
151
152 /* It is possible for the chunk to contain garbage at the end */
155 }
else if (
id == 0x0165 &&
size >= 32) {
157
169 }
170
172
177 }
179 /* Channels and sample_rate values are those prior to applying SBR
180 * and/or PS. */
183 }
184 /* override bits_per_coded_sample for G.726 */
187
188 return 0;
189 }
190
192 {
195 if (id <= 0)
197
202
206 }
207
209 {
210 int tag1;
224 return tag1;
225 }
226
228 {
229 int64_t start, end, cur;
231
234
236 cur <= end - 8 /* = tag + size */) {
237 uint32_t chunk_code;
238 int64_t chunk_size;
241
245 if (chunk_code || chunk_size) {
248 }
250 }
251 if (chunk_size > end ||
252 end - chunk_size < cur ||
253 chunk_size == UINT_MAX) {
257 if (chunk_size > end || end - chunk_size < cur || chunk_size == UINT_MAX) {
260 }
261 }
262
263 chunk_size += (chunk_size & 1);
264
265 if (!chunk_code) {
266 if (chunk_size)
271 }
272 continue;
273 }
274
278 "out of memory, unable to read INFO tag\n");
280 }
281
283 // Work around VC++ 2015 Update 1 code-gen bug:
284 // https://connect.microsoft.com/VisualStudio/feedback/details/2291638
286
289 "premature end of file while reading INFO tag\n");
290 }
291
293 }
294
295 return 0;
296 }