1 /*
2 * WavPack demuxer
3 * Copyright (c) 2006,2011 Konstantin Shishkov
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
43 };
44
46 6000, 8000, 9600, 11025, 12000, 16000, 22050, 24000,
47 32000, 44100, 48000, 64000, 88200, 96000, 192000, -1
48 };
49
58
61
63 {
64 /* check file header */
66 return 0;
73 else
74 return 0;
75 }
76
78 {
81 int rate, bpp, chan;
82 uint32_t chmask,
flags;
83
85
86 /* don't return bogus packets with the ape tag data */
89
93
95 if (ret < 0) {
98 }
99
103 }
104
105 /* Blocks with zero samples don't contain actual audio information
106 * and should be ignored */
108 return 0;
109 // parse flags
111 bpp = ((flags & 3) + 1) << 3;
114 rate =
wv_rates[(flags >> 23) & 0xF];
119 }
124 "Cannot determine additional parameters\n");
126 }
131 size <<= 1;
132 if (id & 0x40)
133 size--;
134 switch (id & 0x3F) {
135 case 0xD:
136 if (size <= 1) {
138 "Insufficient channel information\n");
140 }
142 switch (size - 2) {
143 case 0:
145 break;
146 case 1:
148 break;
149 case 2:
151 break;
152 case 3:
154 break;
155 case 5:
157 chan |= (
avio_r8(pb) & 0xF) << 8;
159 break;
160 default:
162 "Invalid channel info size %d\n", size);
164 }
165 break;
166 case 0x27:
168 break;
169 default:
171 }
172 if (id & 0x40)
174 }
175 if (rate == -1) {
177 "Cannot determine custom sampling rate\n");
179 }
181 }
190
191 if (flags && bpp != wc->
bpp) {
193 "Bits per sample differ, this block: %i, header block: %i\n",
196 }
199 "Channels differ, this block: %i, header block: %i\n",
202 }
203 if (flags && rate != -1 && rate != wc->
rate) {
205 "Sampling rate differ, this block: %i, header block: %i\n",
208 }
209 return 0;
210 }
211
213 {
218
220 for (;;) {
225 else
226 break;
227 }
228
229 /* now we are ready: build format streams */
231 if (!st)
243
250 }
251
252 return 0;
253 }
254
256 {
259 int off;
260 int64_t pos;
261 uint32_t block_samples;
262
268 }
269
278 }
283 }
284
289 }
291
296 }
297 }
302 if (block_samples > INT32_MAX)
304 "Too many samples in block: %"PRIu32"\n", block_samples);
305 else
307
309 return 0;
310 }
311
313 int64_t timestamp,
int flags)
314 {
321
322 /* if found, seek there */
323 if (index >= 0 &&
327 return 0;
328 }
329 /* if timestamp is out of bounds, return error */
330 if (timestamp < 0 || timestamp >= s->
duration)
332
334 do {
336 if (ret < 0) {
339 }
342 } while(pts < timestamp);
343 return 0;
344 }
345
354 };