FFmpeg
Loading...
Searching...
No Matches
wavdec.c
Go to the documentation of this file.
1/*
2 * WAV demuxer
3 * Copyright (c) 2001, 2002 Fabrice Bellard
4 *
5 * Sony Wave64 demuxer
6 * RF64 demuxer
7 * Copyright (c) 2009 Daniel Verkamp
8 *
9 * BW64 demuxer
10 *
11 * This file is part of FFmpeg.
12 *
13 * FFmpeg is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
17 *
18 * FFmpeg is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with FFmpeg; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 */
27
28#include <stdint.h>
29
30#include "config_components.h"
31#include "libavutil/avassert.h"
32#include "libavutil/dict.h"
34#include "libavutil/log.h"
36#include "libavutil/mem.h"
37#include "libavutil/opt.h"
38#include "libavcodec/internal.h"
39#include "avformat.h"
40#include "avio.h"
41#include "avio_internal.h"
42#include "demux.h"
43#include "id3v2.h"
44#include "internal.h"
45#include "metadata.h"
46#include "pcm.h"
47#include "riff.h"
48#include "w64.h"
49#include "spdif.h"
50
51typedef struct WAVDemuxContext {
52 const AVClass *class;
54 int w64;
65 int spdif;
67 int unaligned; // e.g. if an odd number of bytes ID3 tag was prepended
68 int rifx; // RIFX: integer byte order for parameters is big endian
70
71#define OFFSET(x) offsetof(WAVDemuxContext, x)
72#define DEC AV_OPT_FLAG_DECODING_PARAM
73static const AVOption demux_options[] = {
74#define W64_DEMUXER_OPTIONS_OFFSET (1 * CONFIG_WAV_DEMUXER)
75#if CONFIG_WAV_DEMUXER
76 { "ignore_length", "Ignore length", OFFSET(ignore_length), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC },
77#endif
78 { "max_size", "max size of single packet", OFFSET(max_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1 << 22, DEC },
79 { NULL },
80};
81
83{
84 if (wav->max_size <= 0) {
85 int max_size = ff_pcm_default_packet_size(st->codecpar);
86 wav->max_size = max_size < 0 ? 4096 : max_size;
87 }
88}
89
91{
92 if (CONFIG_SPDIF_DEMUXER && s->streams[0]->codecpar->codec_tag == 1) {
93 enum AVCodecID codec;
94 int len = 1<<16;
95 int ret = ffio_ensure_seekback(s->pb, len);
96
97 if (ret >= 0) {
99 if (!buf) {
100 ret = AVERROR(ENOMEM);
101 } else {
102 int64_t pos = avio_tell(s->pb);
103 len = ret = avio_read(s->pb, buf, len);
104 if (len >= 0) {
105 ret = ff_spdif_probe(buf, len, &codec);
106 if (ret > AVPROBE_SCORE_EXTENSION) {
107 s->streams[0]->codecpar->codec_id = codec;
108 wav->spdif = 1;
109 }
110 }
111 avio_seek(s->pb, pos, SEEK_SET);
112 av_free(buf);
113 }
114 }
115
116 if (ret < 0)
117 av_log(s, AV_LOG_WARNING, "Cannot check for SPDIF\n");
118 }
119}
120
121#if CONFIG_WAV_DEMUXER
122
123static int64_t next_tag(AVIOContext *pb, uint32_t *tag, int big_endian)
124{
125 *tag = avio_rl32(pb);
126 if (!big_endian) {
127 return avio_rl32(pb);
128 } else {
129 return avio_rb32(pb);
130 }
131}
132
133/* RIFF chunks are always at even offsets relative to where they start. */
134static int64_t wav_seek_tag(WAVDemuxContext * wav, AVIOContext *s, int64_t offset)
135{
136 offset += offset < INT64_MAX && offset + wav->unaligned & 1;
137
138 return avio_seek(s, offset, SEEK_SET);
139}
140
141/* return the size of the found tag */
142static int64_t find_tag(WAVDemuxContext * wav, AVIOContext *pb, uint32_t tag1)
143{
144 unsigned int tag;
146
147 if (avio_tell(pb) + wav->unaligned & 1)
148 avio_skip(pb, 1);
149
150 for (;;) {
151 if (avio_feof(pb))
152 return AVERROR_EOF;
153 size = next_tag(pb, &tag, wav->rifx);
154 if (tag == tag1)
155 break;
156 avio_skip(pb, size + (size & 1));
157 }
158 return size;
159}
160
161static int wav_probe(const AVProbeData *p)
162{
163 /* check file header */
164 if (p->buf_size <= 32)
165 return 0;
166 if (!memcmp(p->buf + 8, "WAVE", 4)) {
167 if (!memcmp(p->buf, "RIFF", 4) || !memcmp(p->buf, "RIFX", 4))
168 /* Since the ACT demuxer has a standard WAV header at the top of
169 * its own, the returned score is decreased to avoid a probe
170 * conflict between ACT and WAV. */
171 return AVPROBE_SCORE_MAX - 1;
172 else if ((!memcmp(p->buf, "RF64", 4) ||
173 !memcmp(p->buf, "BW64", 4)) &&
174 !memcmp(p->buf + 12, "ds64", 4))
175 return AVPROBE_SCORE_MAX;
176 }
177 return 0;
178}
179
180static void handle_stream_probing(AVStream *st)
181{
183 FFStream *const sti = ffstream(st);
185 sti->probe_packets = FFMIN(sti->probe_packets, 32);
186 }
187}
188
189static int wav_parse_fmt_tag(AVFormatContext *s, int64_t size, AVStream *st)
190{
191 AVIOContext *pb = s->pb;
192 WAVDemuxContext *wav = s->priv_data;
193 int ret;
194
195 /* parse fmt header */
196 ret = ff_get_wav_header(s, pb, st->codecpar, size, wav->rifx);
197 if (ret < 0)
198 return ret;
199 handle_stream_probing(st);
200
202
204
205 return 0;
206}
207
208static int wav_parse_xma2_tag(AVFormatContext *s, int64_t size, AVStream *st)
209{
210 AVIOContext *pb = s->pb;
211 int version, num_streams, i, channels = 0, ret;
212
213 if (size < 36)
214 return AVERROR_INVALIDDATA;
215
219
220 version = avio_r8(pb);
221 if (version != 3 && version != 4)
222 return AVERROR_INVALIDDATA;
223 num_streams = avio_r8(pb);
224 if (size != (32 + ((version==3)?0:8) + 4*num_streams))
225 return AVERROR_INVALIDDATA;
226 avio_skip(pb, 10);
227 st->codecpar->sample_rate = avio_rb32(pb);
228 if (version == 4)
229 avio_skip(pb, 8);
230 avio_skip(pb, 4);
231 st->duration = avio_rb32(pb);
232 avio_skip(pb, 8);
233
234 for (i = 0; i < num_streams; i++) {
235 channels += avio_r8(pb);
236 avio_skip(pb, 3);
237 }
241
242 if (st->codecpar->ch_layout.nb_channels <= 0 || st->codecpar->sample_rate <= 0)
243 return AVERROR_INVALIDDATA;
244
246
247 avio_seek(pb, -size, SEEK_CUR);
248 if ((ret = ff_get_extradata(s, st->codecpar, pb, size)) < 0)
249 return ret;
250
251 return 0;
252}
253
254static inline int wav_parse_bext_string(AVFormatContext *s, const char *key,
255 int length)
256{
257 char temp[257];
258 int ret;
259
260 av_assert0(length < sizeof(temp));
261 if ((ret = ffio_read_size(s->pb, temp, length)) < 0)
262 return ret;
263
264 temp[length] = 0;
265
266 if (strlen(temp))
267 return av_dict_set(&s->metadata, key, temp, 0);
268
269 return 0;
270}
271
272static int wav_parse_bext_tag(AVFormatContext *s, int64_t size)
273{
274 char temp[131], *coding_history;
275 int ret, x;
276 uint64_t time_reference;
277 int64_t umid_parts[8], umid_mask = 0;
278
279 if ((ret = wav_parse_bext_string(s, "description", 256)) < 0 ||
280 (ret = wav_parse_bext_string(s, "originator", 32)) < 0 ||
281 (ret = wav_parse_bext_string(s, "originator_reference", 32)) < 0 ||
282 (ret = wav_parse_bext_string(s, "origination_date", 10)) < 0 ||
283 (ret = wav_parse_bext_string(s, "origination_time", 8)) < 0)
284 return ret;
285
286 time_reference = avio_rl64(s->pb);
287 snprintf(temp, sizeof(temp), "%"PRIu64, time_reference);
288 if ((ret = av_dict_set(&s->metadata, "time_reference", temp, 0)) < 0)
289 return ret;
290
291 /* check if version is >= 1, in which case an UMID may be present */
292 if (avio_rl16(s->pb) >= 1) {
293 for (x = 0; x < 8; x++)
294 umid_mask |= umid_parts[x] = avio_rb64(s->pb);
295
296 if (umid_mask) {
297 /* the string formatting below is per SMPTE 330M-2004 Annex C */
298 if (umid_parts[4] == 0 && umid_parts[5] == 0 &&
299 umid_parts[6] == 0 && umid_parts[7] == 0) {
300 /* basic UMID */
301 snprintf(temp, sizeof(temp),
302 "0x%016"PRIX64"%016"PRIX64"%016"PRIX64"%016"PRIX64,
303 umid_parts[0], umid_parts[1],
304 umid_parts[2], umid_parts[3]);
305 } else {
306 /* extended UMID */
307 snprintf(temp, sizeof(temp),
308 "0x%016"PRIX64"%016"PRIX64"%016"PRIX64"%016"PRIX64
309 "%016"PRIX64"%016"PRIX64"%016"PRIX64"%016"PRIX64,
310 umid_parts[0], umid_parts[1],
311 umid_parts[2], umid_parts[3],
312 umid_parts[4], umid_parts[5],
313 umid_parts[6], umid_parts[7]);
314 }
315
316 if ((ret = av_dict_set(&s->metadata, "umid", temp, 0)) < 0)
317 return ret;
318 }
319
320 avio_skip(s->pb, 190);
321 } else
322 avio_skip(s->pb, 254);
323
324 if (size > 602) {
325 /* CodingHistory present */
326 int64_t coding_history_size = size - 602;
327
328 /* Professional BEXT coding history rarely exceeds a few KB.
329 * Cap to 1MB to prevent excessive allocation from crafted files
330 * while remaining well within ffio_read_size's int range. */
331 if (coding_history_size > 1024 * 1024) {
332 av_log(s, AV_LOG_ERROR, "BEXT coding history too large (%"PRId64")\n", coding_history_size);
333 return AVERROR_INVALIDDATA;
334 }
335
336 if (!(coding_history = av_malloc(coding_history_size + 1)))
337 return AVERROR(ENOMEM);
338
339 if ((ret = ffio_read_size(s->pb, coding_history, coding_history_size)) < 0) {
340 av_free(coding_history);
341 return ret;
342 }
343
344 coding_history[coding_history_size] = 0;
345 if ((ret = av_dict_set(&s->metadata, "coding_history", coding_history,
347 return ret;
348 }
349
350 return 0;
351}
352
353static const AVMetadataConv wav_metadata_conv[] = {
354 { "description", "comment" },
355 { "originator", "encoded_by" },
356 { "origination_date", "date" },
357 { "origination_time", "creation_time" },
358 { 0 },
359};
360
361/* wav input */
362static int wav_read_header(AVFormatContext *s)
363{
364 int64_t size, av_uninit(data_size);
365 int64_t sample_count = 0;
366 int rf64 = 0, bw64 = 0;
367 uint32_t tag;
368 AVIOContext *pb = s->pb;
369 AVStream *st = NULL;
370 WAVDemuxContext *wav = s->priv_data;
371 int ret, got_fmt = 0, got_xma2 = 0;
372 int64_t next_tag_ofs, data_ofs = -1;
374
375 wav->unaligned = avio_tell(s->pb) & 1;
376
377 wav->smv_data_ofs = -1;
378
379 filesize = avio_size(pb);
380 /* read chunk ID */
381 tag = avio_rl32(pb);
382 switch (tag) {
383 case MKTAG('R', 'I', 'F', 'F'):
384 break;
385 case MKTAG('R', 'I', 'F', 'X'):
386 wav->rifx = 1;
387 break;
388 case MKTAG('R', 'F', '6', '4'):
389 rf64 = 1;
390 break;
391 case MKTAG('B', 'W', '6', '4'):
392 bw64 = 1;
393 break;
394 default:
395 av_log(s, AV_LOG_ERROR, "invalid start code %s in RIFF header\n",
397 return AVERROR_INVALIDDATA;
398 }
399
400 /* read chunk size */
401 avio_rl32(pb);
402
403 /* read format */
404 if (avio_rl32(pb) != MKTAG('W', 'A', 'V', 'E')) {
405 av_log(s, AV_LOG_ERROR, "invalid format in RIFF header\n");
406 return AVERROR_INVALIDDATA;
407 }
408
409 if (rf64 || bw64) {
410 if (avio_rl32(pb) != MKTAG('d', 's', '6', '4'))
411 return AVERROR_INVALIDDATA;
412 size = avio_rl32(pb);
413 if (size < 24)
414 return AVERROR_INVALIDDATA;
415 avio_rl64(pb); /* RIFF size */
416
417 data_size = avio_rl64(pb);
418 sample_count = avio_rl64(pb);
419
420 if (data_size < 0 || sample_count < 0) {
421 av_log(s, AV_LOG_ERROR, "negative data_size and/or sample_count in "
422 "ds64: data_size = %"PRId64", sample_count = %"PRId64"\n",
423 data_size, sample_count);
424 return AVERROR_INVALIDDATA;
425 }
426 avio_skip(pb, size - 24); /* skip rest of ds64 chunk */
427
428 }
429
430 /* Create the audio stream now so that its index is always zero */
432 if (!st)
433 return AVERROR(ENOMEM);
434
435 for (;;) {
436 AVStream *vst;
437 size = next_tag(pb, &tag, wav->rifx);
438 next_tag_ofs = avio_tell(pb) + size + (size & 1);
439
440 if (avio_feof(pb))
441 break;
442
443 switch (tag) {
444 case MKTAG('f', 'm', 't', ' '):
445 /* only parse the first 'fmt ' tag found */
446 if (!got_xma2 && !got_fmt && (ret = wav_parse_fmt_tag(s, size, st)) < 0) {
447 return ret;
448 } else if (got_fmt)
449 av_log(s, AV_LOG_WARNING, "found more than one 'fmt ' tag\n");
450
451 got_fmt = 1;
452 break;
453 case MKTAG('X', 'M', 'A', '2'):
454 /* only parse the first 'XMA2' tag found */
455 if (!got_fmt && !got_xma2 && (ret = wav_parse_xma2_tag(s, size, st)) < 0) {
456 return ret;
457 } else if (got_xma2)
458 av_log(s, AV_LOG_WARNING, "found more than one 'XMA2' tag\n");
459
460 got_xma2 = 1;
461 break;
462 case MKTAG('d', 'a', 't', 'a'):
463 if (!(pb->seekable & AVIO_SEEKABLE_NORMAL) && !got_fmt && !got_xma2) {
465 "found no 'fmt ' tag before the 'data' tag\n");
466 return AVERROR_INVALIDDATA;
467 }
468
469 if (rf64 || bw64) {
470 wav->data_end = av_sat_add64(avio_tell(pb), data_size);
471 next_tag_ofs = wav->data_end + (data_size & 1);
472 } else if (size > 0 && size != 0xFFFFFFFF) {
473 data_size = size;
474 wav->data_end = avio_tell(pb) + size;
475 next_tag_ofs = wav->data_end + (size & 1);
476 } else {
477 av_log(s, AV_LOG_WARNING, "Ignoring maximum wav data size, "
478 "file may be invalid\n");
479 data_size = 0;
480 next_tag_ofs = wav->data_end = INT64_MAX;
481 }
482
483 data_ofs = avio_tell(pb);
484
485 /* don't look for footer metadata if we can't seek or if we don't
486 * know where the data tag ends
487 */
488 if (!(pb->seekable & AVIO_SEEKABLE_NORMAL) || (!(rf64 && !bw64) && !size))
489 goto break_loop;
490 break;
491 case MKTAG('f', 'a', 'c', 't'):
492 if (!sample_count)
493 sample_count = (!wav->rifx ? avio_rl32(pb) : avio_rb32(pb));
494 break;
495 case MKTAG('b', 'e', 'x', 't'):
496 if ((ret = wav_parse_bext_tag(s, size)) < 0)
497 return ret;
498 break;
499 case MKTAG('S','M','V','0'):
500 if (!got_fmt) {
501 av_log(s, AV_LOG_ERROR, "found no 'fmt ' tag before the 'SMV0' tag\n");
502 return AVERROR_INVALIDDATA;
503 }
504 // SMV file, a wav file with video appended.
505 if (size != MKTAG('0','2','0','0')) {
506 av_log(s, AV_LOG_ERROR, "Unknown SMV version found\n");
507 goto break_loop;
508 }
509 av_log(s, AV_LOG_DEBUG, "Found SMV data\n");
510 wav->smv_given_first = 0;
511 vst = avformat_new_stream(s, NULL);
512 if (!vst)
513 return AVERROR(ENOMEM);
514 wav->vst = vst;
515 avio_r8(pb);
516 vst->id = 1;
519 vst->codecpar->width = avio_rl24(pb);
520 vst->codecpar->height = avio_rl24(pb);
521 if ((ret = ff_alloc_extradata(vst->codecpar, 4)) < 0) {
522 av_log(s, AV_LOG_ERROR, "Could not allocate extradata.\n");
523 return ret;
524 }
525 size = avio_rl24(pb);
526 wav->smv_data_ofs = avio_tell(pb) + (size - 5) * 3;
527 avio_rl24(pb);
528 wav->smv_block_size = avio_rl24(pb);
529 if (!wav->smv_block_size)
530 return AVERROR_INVALIDDATA;
531 avpriv_set_pts_info(vst, 32, 1, avio_rl24(pb));
532 vst->duration = avio_rl24(pb);
533 avio_rl24(pb);
534 avio_rl24(pb);
536 if (wav->smv_frames_per_jpeg > 65536) {
537 av_log(s, AV_LOG_ERROR, "too many frames per jpeg\n");
538 return AVERROR_INVALIDDATA;
539 }
541 goto break_loop;
542 case MKTAG('L', 'I', 'S', 'T'):
543 case MKTAG('l', 'i', 's', 't'):
544 if (size < 4) {
545 av_log(s, AV_LOG_ERROR, "too short LIST tag\n");
546 return AVERROR_INVALIDDATA;
547 }
548 switch (avio_rl32(pb)) {
549 case MKTAG('I', 'N', 'F', 'O'):
551 break;
552 case MKTAG('a', 'd', 't', 'l'):
553 if (s->nb_chapters > 0) {
554 while (avio_tell(pb) < next_tag_ofs &&
555 !avio_feof(pb)) {
556 char cue_label[512];
557 unsigned id, sub_size;
558
559 if (avio_rl32(pb) != MKTAG('l', 'a', 'b', 'l'))
560 break;
561
562 sub_size = avio_rl32(pb);
563 if (sub_size < 5)
564 break;
565 id = avio_rl32(pb);
566 avio_get_str(pb, sub_size - 4, cue_label, sizeof(cue_label));
567 avio_skip(pb, avio_tell(pb) & 1);
568
569 for (int i = 0; i < s->nb_chapters; i++) {
570 if (s->chapters[i]->id == id) {
571 av_dict_set(&s->chapters[i]->metadata, "title", cue_label, 0);
572 break;
573 }
574 }
575 }
576 }
577 break;
578 }
579 break;
580 case MKTAG('I', 'D', '3', ' '):
581 case MKTAG('i', 'd', '3', ' '): {
582 ID3v2ExtraMeta *id3v2_extra_meta;
583 ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta, 0);
584 if (id3v2_extra_meta) {
585 ff_id3v2_parse_apic(s, id3v2_extra_meta);
586 ff_id3v2_parse_chapters(s, id3v2_extra_meta);
587 ff_id3v2_parse_priv(s, id3v2_extra_meta);
588 }
589 ff_id3v2_free_extra_meta(&id3v2_extra_meta);
590 }
591 break;
592 case MKTAG('c', 'u', 'e', ' '):
593 if (size >= 4 && got_fmt && st->codecpar->sample_rate > 0) {
594 AVRational tb = {1, st->codecpar->sample_rate};
595 unsigned nb_cues = avio_rl32(pb);
596
597 if (size >= nb_cues * 24LL + 4LL) {
598 for (int i = 0; i < nb_cues; i++) {
599 unsigned offset, id = avio_rl32(pb);
600
601 if (avio_feof(pb))
602 return AVERROR_INVALIDDATA;
603
604 avio_skip(pb, 16);
605 offset = avio_rl32(pb);
606
608 return AVERROR(ENOMEM);
609 }
610 }
611 }
612 break;
613 }
614
615 /* seek to next tag unless we know that we'll run into EOF */
616 if ((avio_size(pb) > 0 && next_tag_ofs >= avio_size(pb)) ||
617 wav_seek_tag(wav, pb, next_tag_ofs) < 0) {
618 break;
619 }
620 }
621
622break_loop:
623 if (!got_fmt && !got_xma2) {
624 av_log(s, AV_LOG_ERROR, "no 'fmt ' or 'XMA2' tag found\n");
625 return AVERROR_INVALIDDATA;
626 }
627
628 if (data_ofs < 0) {
629 av_log(s, AV_LOG_ERROR, "no 'data' tag found\n");
630 return AVERROR_INVALIDDATA;
631 }
632
633 avio_seek(pb, data_ofs, SEEK_SET);
634
635 if (data_size > (INT64_MAX>>3)) {
636 av_log(s, AV_LOG_WARNING, "Data size %"PRId64" is too large\n", data_size);
637 data_size = 0;
638 }
639
640 if ( st->codecpar->bit_rate > 0 && data_size > 0
641 && st->codecpar->sample_rate > 0
642 && sample_count > 0 && st->codecpar->ch_layout.nb_channels > 1
643 && sample_count % st->codecpar->ch_layout.nb_channels == 0) {
644 if (fabs(8.0 * data_size * st->codecpar->ch_layout.nb_channels * st->codecpar->sample_rate /
645 sample_count /st->codecpar->bit_rate - 1.0) < 0.3)
646 sample_count /= st->codecpar->ch_layout.nb_channels;
647 }
648
649 if (data_size > 0 && sample_count && st->codecpar->ch_layout.nb_channels &&
650 (data_size << 3) / sample_count / st->codecpar->ch_layout.nb_channels > st->codecpar->bits_per_coded_sample + 1) {
651 av_log(s, AV_LOG_WARNING, "ignoring wrong sample_count %"PRId64"\n", sample_count);
652 sample_count = 0;
653 }
654
655 /* G.729 hack (for Ticket4577)
656 * FIXME: Come up with cleaner, more general solution */
657 if (st->codecpar->codec_id == AV_CODEC_ID_G729 && sample_count && (data_size << 3) > sample_count) {
658 av_log(s, AV_LOG_WARNING, "ignoring wrong sample_count %"PRId64"\n", sample_count);
659 sample_count = 0;
660 }
661
662 if (!sample_count || av_get_exact_bits_per_sample(st->codecpar->codec_id) > 0)
664 && data_size
666 && wav->data_end <= filesize)
667 sample_count = (data_size << 3)
668 /
670
671 if (sample_count)
672 st->duration = sample_count;
673
676 st->codecpar->bits_per_coded_sample == 32 &&
677 st->codecpar->extradata_size == 2 &&
678 AV_RL16(st->codecpar->extradata) == 1) {
681 } else if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S24LE &&
683 st->codecpar->bits_per_coded_sample == 24) {
685 } else if (st->codecpar->codec_id == AV_CODEC_ID_XMA1 ||
687 st->codecpar->block_align = 2048;
688 } else if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_MS && st->codecpar->ch_layout.nb_channels > 2 &&
689 st->codecpar->block_align < INT_MAX / st->codecpar->ch_layout.nb_channels) {
691 }
692
693 ff_metadata_conv_ctx(s, NULL, wav_metadata_conv);
695
696 set_spdif(s, wav);
697 set_max_size(st, wav);
698
699 return 0;
700}
701
702/**
703 * Find chunk with w64 GUID by skipping over other chunks.
704 * @return the size of the found chunk
705 */
706static int64_t find_guid(AVIOContext *pb, const uint8_t guid1[16])
707{
708 uint8_t guid[16];
710
711 while (!avio_feof(pb)) {
712 if (avio_read(pb, guid, 16) != 16)
713 break;
714 size = avio_rl64(pb);
715 if (size <= 24 || size > INT64_MAX - 8)
716 return AVERROR_INVALIDDATA;
717 if (!memcmp(guid, guid1, 16))
718 return size;
719 avio_skip(pb, FFALIGN(size, INT64_C(8)) - 24);
720 }
721 return AVERROR_EOF;
722}
723
724static int wav_read_packet(AVFormatContext *s, AVPacket *pkt)
725{
726 int ret, size;
728 WAVDemuxContext *wav = s->priv_data;
729 AVStream *st = s->streams[0];
730
731 if (CONFIG_SPDIF_DEMUXER && wav->spdif == 1)
732 return ff_spdif_read_packet(s, pkt);
733
734 if (wav->smv_data_ofs > 0) {
736 AVStream *vst = wav->vst;
737smv_retry:
740
742 /*We always return a video frame first to get the pixel format first*/
743 wav->smv_last_stream = wav->smv_given_first ?
745 audio_dts, st->time_base) > 0 : 0;
746 wav->smv_given_first = 1;
747 }
748 wav->smv_last_stream = !wav->smv_last_stream;
749 wav->smv_last_stream |= wav->audio_eof;
750 wav->smv_last_stream &= !wav->smv_eof;
751 if (wav->smv_last_stream) {
752 uint64_t old_pos = avio_tell(s->pb);
753 uint64_t new_pos = wav->smv_data_ofs +
754 wav->smv_block * (int64_t)wav->smv_block_size;
755 if (avio_seek(s->pb, new_pos, SEEK_SET) < 0) {
756 ret = AVERROR_EOF;
757 goto smv_out;
758 }
759 size = avio_rl24(s->pb);
760 if (size > wav->smv_block_size) {
761 ret = AVERROR_EOF;
762 goto smv_out;
763 }
764 ret = av_get_packet(s->pb, pkt, size);
765 if (ret < 0)
766 goto smv_out;
767 pkt->pos -= 3;
768 pkt->pts = wav->smv_block * wav->smv_frames_per_jpeg;
769 pkt->duration = wav->smv_frames_per_jpeg;
770 wav->smv_block++;
771
772 pkt->stream_index = vst->index;
773smv_out:
774 avio_seek(s->pb, old_pos, SEEK_SET);
775 if (ret == AVERROR_EOF) {
776 wav->smv_eof = 1;
777 goto smv_retry;
778 }
779 return ret;
780 }
781 }
782
783 left = wav->data_end - avio_tell(s->pb);
784 if (wav->ignore_length)
785 left = INT_MAX;
786 if (left <= 0) {
787 if (CONFIG_W64_DEMUXER && wav->w64)
788 left = find_guid(s->pb, ff_w64_guid_data) - 24;
789 else
790 left = find_tag(wav, s->pb, MKTAG('d', 'a', 't', 'a'));
791 if (left < 0) {
792 wav->audio_eof = 1;
793 if (wav->smv_data_ofs > 0 && !wav->smv_eof)
794 goto smv_retry;
795 return AVERROR_EOF;
796 }
797 if (INT64_MAX - left < avio_tell(s->pb))
798 return AVERROR_INVALIDDATA;
799 wav->data_end = avio_tell(s->pb) + left;
800 }
801
802 size = wav->max_size;
803 if (st->codecpar->block_align > 1) {
804 if (size < st->codecpar->block_align)
807 }
808 size = FFMIN(size, left);
809 ret = av_get_packet(s->pb, pkt, size);
810 if (ret < 0)
811 return ret;
812 pkt->stream_index = 0;
813
814 return ret;
815}
816
817static int wav_read_seek(AVFormatContext *s,
818 int stream_index, int64_t timestamp, int flags)
819{
820 WAVDemuxContext *wav = s->priv_data;
821 AVStream *ast = s->streams[0], *vst = wav->vst;
822 wav->smv_eof = 0;
823 wav->audio_eof = 0;
824
825 if (stream_index != 0 && (!vst || stream_index != vst->index))
826 return AVERROR(EINVAL);
827 if (wav->smv_data_ofs > 0) {
828 int64_t smv_timestamp = timestamp;
829 if (stream_index == 0)
830 smv_timestamp = av_rescale_q(timestamp, ast->time_base, vst->time_base);
831 else
832 timestamp = av_rescale_q(smv_timestamp, vst->time_base, ast->time_base);
833 if (wav->smv_frames_per_jpeg > 0) {
834 wav->smv_block = smv_timestamp / wav->smv_frames_per_jpeg;
835 }
836 }
837
838 switch (ast->codecpar->codec_id) {
839 case AV_CODEC_ID_MP2:
840 case AV_CODEC_ID_MP3:
841 case AV_CODEC_ID_AC3:
842 case AV_CODEC_ID_DTS:
843 case AV_CODEC_ID_XMA2:
844 /* use generic seeking with dynamically generated indexes */
845 return -1;
846 default:
847 break;
848 }
849 return ff_pcm_read_seek(s, 0, timestamp, flags);
850}
851
852static const AVClass wav_demuxer_class = {
853 .class_name = "WAV demuxer",
854 .item_name = av_default_item_name,
855 .option = demux_options,
856 .version = LIBAVUTIL_VERSION_INT,
857};
859 .p.name = "wav",
860 .p.long_name = NULL_IF_CONFIG_SMALL("WAV / WAVE (Waveform Audio)"),
861 .p.flags = AVFMT_GENERIC_INDEX,
862 .p.codec_tag = ff_wav_codec_tags_list,
863 .p.priv_class = &wav_demuxer_class,
864 .priv_data_size = sizeof(WAVDemuxContext),
865 .flags_internal = FF_INFMT_FLAG_ID3V2_AUTO,
866 .read_probe = wav_probe,
867 .read_header = wav_read_header,
868 .read_packet = wav_read_packet,
869 .read_seek = wav_read_seek,
870};
871#endif /* CONFIG_WAV_DEMUXER */
872
873#if CONFIG_W64_DEMUXER
874static int w64_probe(const AVProbeData *p)
875{
876 if (p->buf_size <= 40)
877 return 0;
878 if (!memcmp(p->buf, ff_w64_guid_riff, 16) &&
879 !memcmp(p->buf + 24, ff_w64_guid_wave, 16))
880 return AVPROBE_SCORE_MAX;
881 else
882 return 0;
883}
884
885static int w64_read_header(AVFormatContext *s)
886{
887 int64_t size, data_ofs = 0;
888 AVIOContext *pb = s->pb;
889 WAVDemuxContext *wav = s->priv_data;
890 AVStream *st;
891 uint8_t guid[16];
892 int ret = ffio_read_size(pb, guid, 16);
893
894 if (ret < 0)
895 return ret;
896
897 if (memcmp(guid, ff_w64_guid_riff, 16))
898 return AVERROR_INVALIDDATA;
899
900 /* riff + wave + fmt + sizes */
901 if (avio_rl64(pb) < 16 + 8 + 16 + 8 + 16 + 8)
902 return AVERROR_INVALIDDATA;
903
904 ret = ffio_read_size(pb, guid, 16);
905 if (ret < 0)
906 return ret;
907 if (memcmp(guid, ff_w64_guid_wave, 16)) {
908 av_log(s, AV_LOG_ERROR, "could not find wave guid\n");
909 return AVERROR_INVALIDDATA;
910 }
911
912 wav->w64 = 1;
913
915 if (!st)
916 return AVERROR(ENOMEM);
917
918 while (!avio_feof(pb)) {
919 if (avio_read(pb, guid, 16) != 16)
920 break;
921 size = avio_rl64(pb);
922 if (size <= 24 || INT64_MAX - size - 7 < avio_tell(pb)) {
923 if (data_ofs)
924 break;
925 return AVERROR_INVALIDDATA;
926 }
927
928 if (!memcmp(guid, ff_w64_guid_fmt, 16)) {
929 /* subtract chunk header size - normal wav file doesn't count it */
930 ret = ff_get_wav_header(s, pb, st->codecpar, size - 24, 0);
931 if (ret < 0)
932 return ret;
933 avio_skip(pb, FFALIGN(size, INT64_C(8)) - size);
934 if (st->codecpar->block_align &&
936 st->codecpar->bits_per_coded_sample < 128) {
937 int64_t block_align = st->codecpar->block_align;
938
939 block_align = FFMAX(block_align,
940 ((st->codecpar->bits_per_coded_sample + 7LL) / 8) *
942 if (block_align > st->codecpar->block_align) {
943 av_log(s, AV_LOG_WARNING, "invalid block_align: %d, broken file.\n",
944 st->codecpar->block_align);
945 st->codecpar->block_align = block_align;
946 }
947 }
949 } else if (!memcmp(guid, ff_w64_guid_fact, 16)) {
950 int64_t samples;
951
952 samples = avio_rl64(pb);
953 if (samples > 0)
954 st->duration = samples;
955 avio_skip(pb, FFALIGN(size, INT64_C(8)) - 32);
956 } else if (!memcmp(guid, ff_w64_guid_data, 16)) {
957 wav->data_end = avio_tell(pb) + size - 24;
958
959 data_ofs = avio_tell(pb);
960 if (!(pb->seekable & AVIO_SEEKABLE_NORMAL))
961 break;
962
963 avio_skip(pb, size - 24);
964 } else if (!memcmp(guid, ff_w64_guid_summarylist, 16)) {
965 int64_t start, end, cur;
966 uint32_t count, chunk_size, i;
968
969 start = avio_tell(pb);
970 end = start + FFALIGN(size, INT64_C(8)) - 24;
971 count = avio_rl32(pb);
972
973 for (i = 0; i < count; i++) {
974 char chunk_key[5], *value;
975
976 if (avio_feof(pb) || (cur = avio_tell(pb)) < 0 || cur > end - 8 /* = tag + size */)
977 break;
978
979 chunk_key[4] = 0;
980 avio_read(pb, chunk_key, 4);
981 chunk_size = avio_rl32(pb);
982 if (chunk_size == UINT32_MAX || (filesize >= 0 && chunk_size > filesize))
983 return AVERROR_INVALIDDATA;
984
985 value = av_malloc(chunk_size + 1);
986 if (!value)
987 return AVERROR(ENOMEM);
988
989 ret = avio_get_str16le(pb, chunk_size, value, chunk_size);
990 if (ret < 0) {
991 av_free(value);
992 return ret;
993 }
994 avio_skip(pb, chunk_size - ret);
995
996 av_dict_set(&s->metadata, chunk_key, value, AV_DICT_DONT_STRDUP_VAL);
997 }
998
999 avio_skip(pb, end - avio_tell(pb));
1000 } else {
1001 av_log(s, AV_LOG_DEBUG, "unknown guid: "FF_PRI_GUID"\n", FF_ARG_GUID(guid));
1002 avio_skip(pb, FFALIGN(size, INT64_C(8)) - 24);
1003 }
1004 }
1005
1006 if (!data_ofs)
1007 return AVERROR_EOF;
1008
1009 ff_metadata_conv_ctx(s, NULL, wav_metadata_conv);
1011
1012 handle_stream_probing(st);
1014
1015 avio_seek(pb, data_ofs, SEEK_SET);
1016
1017 set_spdif(s, wav);
1018 set_max_size(st, wav);
1019
1020 return 0;
1021}
1022
1023static const AVClass w64_demuxer_class = {
1024 .class_name = "W64 demuxer",
1025 .item_name = av_default_item_name,
1027 .version = LIBAVUTIL_VERSION_INT,
1028};
1029
1031 .p.name = "w64",
1032 .p.long_name = NULL_IF_CONFIG_SMALL("Sony Wave64"),
1033 .p.flags = AVFMT_GENERIC_INDEX,
1034 .p.codec_tag = ff_wav_codec_tags_list,
1035 .p.priv_class = &w64_demuxer_class,
1036 .priv_data_size = sizeof(WAVDemuxContext),
1037 .read_probe = w64_probe,
1038 .read_header = w64_read_header,
1039 .read_packet = wav_read_packet,
1040 .read_seek = wav_read_seek,
1041};
1042#endif /* CONFIG_W64_DEMUXER */
const FFInputFormat ff_wav_demuxer
const FFInputFormat ff_w64_demuxer
static int64_t audio_dts
static int64_t video_dts
channels
Definition aptx.h:31
static const GUIDParseTable * find_guid(ff_asf_guid guid)
Definition asfdec_o.c:1523
return
int32_t
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition avformat.c:834
Main libavformat public API header.
#define AVPROBE_SCORE_MAX
maximum score
Definition avformat.h:483
#define AVPROBE_SCORE_EXTENSION
score for file extension
Definition avformat.h:481
int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
Allocate and read the payload of a packet and initialize its fields with default values.
Definition utils.c:98
#define AVFMT_GENERIC_INDEX
Use generic index building code.
Definition avformat.h:499
@ AVSTREAM_PARSE_FULL_RAW
full parsing and repack with timestamp and position generation by parser for raw this assumes that ea...
Definition avformat.h:615
Buffered I/O operations.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition aviobuf.c:236
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
Definition avio.h:41
uint64_t avio_rb64(AVIOContext *s)
Definition aviobuf.c:911
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition aviobuf.c:326
int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a UTF-16 string from pb and convert it to UTF-8.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Definition aviobuf.c:349
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition avio.h:494
unsigned int avio_rl16(AVIOContext *s)
Definition aviobuf.c:717
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition aviobuf.c:321
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition aviobuf.c:615
unsigned int avio_rl32(AVIOContext *s)
Definition aviobuf.c:733
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
Definition aviobuf.c:869
unsigned int avio_rl24(AVIOContext *s)
Definition aviobuf.c:725
unsigned int avio_rb32(AVIOContext *s)
Definition aviobuf.c:764
int avio_r8(AVIOContext *s)
Definition aviobuf.c:606
uint64_t avio_rl64(AVIOContext *s)
Definition aviobuf.c:741
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
Definition aviobuf.c:1026
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition aviobuf.c:665
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
static int read_probe(const AVProbeData *p)
Definition cdg.c:30
#define av_sat_add64
Definition common.h:139
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
static __device__ float fabs(float a)
AVChapter * avpriv_new_chapter(AVFormatContext *s, int64_t id, AVRational time_base, int64_t start, int64_t end, const char *title)
Add a new chapter.
Definition demux_utils.c:46
#define FF_INFMT_FLAG_ID3V2_AUTO
Automatically parse ID3v2 metadata.
Definition demux.h:45
int ff_get_extradata(void *logctx, AVCodecParameters *par, AVIOContext *pb, int size)
Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end which is always set to 0 and f...
static AVPacket * pkt
Public dictionary API.
enum AVCodecID id
Definition dts2pts.c:607
double value
Definition eval.c:102
static int64_t filesize(AVIOContext *pb)
Definition ffmpeg_mux.c:51
const char * key
static int read_header(FFV1Context *f, RangeCoder *c)
Definition ffv1dec.c:578
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
Definition utils.c:556
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition codec_id.h:47
int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
Definition utils.c:461
@ AV_CODEC_ID_PCM_F24LE
Definition codec_id.h:364
@ AV_CODEC_ID_G729
Definition codec_id.h:506
@ AV_CODEC_ID_PCM_S16LE
Definition codec_id.h:330
@ AV_CODEC_ID_XMA1
Definition codec_id.h:532
@ AV_CODEC_ID_PCM_F16LE
Definition codec_id.h:363
@ AV_CODEC_ID_XMA2
Definition codec_id.h:533
@ AV_CODEC_ID_PCM_S24LE
Definition codec_id.h:342
@ AV_CODEC_ID_PCM_S32LE
Definition codec_id.h:338
@ AV_CODEC_ID_ADPCM_MS
Definition codec_id.h:376
@ AV_CODEC_ID_MP2
Definition codec_id.h:453
@ AV_CODEC_ID_DTS
Definition codec_id.h:457
@ AV_CODEC_ID_SMVJPEG
Definition codec_id.h:259
@ AV_CODEC_ID_AC3
Definition codec_id.h:456
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition codec_id.h:454
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
Definition defs.h:40
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
Definition dict.h:79
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition dict.c:86
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR_EOF
End of file.
Definition error.h:57
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
Compare two timestamps each in its own time base.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
#define av_fourcc2str(fourcc)
Definition avutil.h:323
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition avutil.h:247
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
if(svq3)
void ff_id3v2_read(AVFormatContext *s, const char *magic, ID3v2ExtraMeta **extra_meta, unsigned int max_search_size)
Read an ID3v2 tag, including supported extra metadata.
Definition id3v2.c:1180
void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta)
Free memory allocated parsing special (non-text) metadata.
Definition id3v2.c:1186
int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta *extra_meta)
Create a stream for each APIC (attached picture) extracted from the ID3v2 header.
Definition id3v2.c:1202
int ff_id3v2_parse_priv(AVFormatContext *s, ID3v2ExtraMeta *extra_meta)
Add metadata for all PRIV tags in the ID3v2 header.
Definition id3v2.c:1298
int ff_id3v2_parse_chapters(AVFormatContext *s, ID3v2ExtraMeta *cur)
Create chapters for all CHAP tags found in the ID3v2 header.
Definition id3v2.c:1233
#define ID3v2_DEFAULT_MAGIC
Default magic bytes for ID3v2 header: "ID3".
Definition id3v2.h:35
#define AV_WL32(p, v)
#define AV_RL16(p)
unsigned offset
Definition libaomenc.c:763
common internal api header.
#define FF_SANE_NB_CHANNELS
Definition internal.h:37
static av_always_inline FFStream * ffstream(AVStream *st)
Definition internal.h:365
int ff_alloc_extradata(AVCodecParameters *par, int size)
Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end which is always set to 0.
Definition utils.c:237
int ff_pcm_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Definition pcm.c:73
int ff_pcm_default_packet_size(AVCodecParameters *par)
Definition pcm.c:29
#define av_uninit(x)
Definition attributes.h:187
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition libcdio.c:151
version
Definition libkvazaar.c:313
#define DEC
Definition librsvgdec.c:149
#define FFMIN(a, b)
Definition macros.h:49
#define MKTAG(a, b, c, d)
Definition macros.h:55
#define FFMAX(a, b)
Definition macros.h:47
#define FFALIGN(x, a)
Definition macros.h:78
Memory handling functions.
void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv, const AVMetadataConv *s_conv)
Definition metadata.c:59
internal metadata API header see avformat.h or the public API!
uint32_t tag
Definition movenc.c:2087
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
#define av_malloc(s)
Definition ops_static.c:52
AVOptions.
const AVMetadataConv ff_riff_info_conv[]
Definition riff.c:632
internal header for RIFF based (de)muxers do NOT include this in end user applications
#define FF_PRI_GUID
Definition riff.h:105
int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int size, int big_endian)
Definition riffdec.c:141
#define FF_ARG_GUID(g)
Definition riff.h:109
int ff_read_riff_info(AVFormatContext *s, int64_t size)
Definition riffdec.c:313
const AVCodecTag *const ff_wav_codec_tags_list[]
#define snprintf
Definition snprintf.h:34
int ff_spdif_probe(const uint8_t *p_buf, int buf_size, enum AVCodecID *codec)
Definition spdifdec.c:122
int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition spdifdec.c:192
unsigned int pos
Definition spdifenc.c:431
enum AVChannelOrder order
Channel order used in this layout.
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
Definition log.h:76
int extradata_size
Size of the extradata content in bytes.
Definition codec_par.h:75
int height
The height of the video frame in pixels.
Definition codec_par.h:150
int bits_per_coded_sample
The number of bits per sample in the codedwords.
Definition codec_par.h:113
AVChannelLayout ch_layout
The channel layout and number of channels.
Definition codec_par.h:207
int width
The width of the video frame in pixels.
Definition codec_par.h:143
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
Definition codec_par.h:99
enum AVMediaType codec_type
General type of the encoded data.
Definition codec_par.h:53
int block_align
The number of bytes per coded audio frame, required by some formats.
Definition codec_par.h:221
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition codec_par.h:71
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition codec_par.h:57
int sample_rate
The number of audio samples per second.
Definition codec_par.h:213
Format I/O context.
Definition avformat.h:1333
Bytestream IO Context.
Definition avio.h:160
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
Definition avio.h:261
AVOption.
Definition opt.h:428
This structure stores compressed data.
Definition packet.h:580
This structure contains the data a format has to probe a file.
Definition avformat.h:471
Rational number (pair of numerator and denominator).
Definition rational.h:58
Stream structure.
Definition avformat.h:766
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition avformat.h:789
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition avformat.h:825
int id
Format-specific stream ID.
Definition avformat.h:778
int index
stream index in AVFormatContext
Definition avformat.h:772
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Definition avformat.h:805
int probe_packets
Number of packets to buffer for codec probing.
Definition internal.h:318
int64_t cur_dts
Definition internal.h:360
int request_probe
stream probing state -1 -> probing finished 0 -> no probing requested rest -> perform probing with re...
Definition internal.h:205
enum AVStreamParseType need_parsing
Definition internal.h:321
int ignore_length
Definition wavdec.c:63
int smv_block_size
Definition wavdec.c:57
int smv_frames_per_jpeg
Definition wavdec.c:58
int smv_given_first
Definition wavdec.c:66
int64_t data_end
Definition wavdec.c:53
AVStream * vst
Definition wavdec.c:55
int64_t smv_data_ofs
Definition wavdec.c:56
int smv_last_stream
Definition wavdec.c:60
#define av_free(p)
#define av_log(a,...)
int size
else temp
Definition vf_mcdeint.c:275
int len
const uint8_t ff_w64_guid_wave[16]
Definition w64.c:28
const uint8_t ff_w64_guid_summarylist[16]
Definition w64.c:47
const uint8_t ff_w64_guid_riff[16]
Definition w64.c:23
const uint8_t ff_w64_guid_data[16]
Definition w64.c:42
const uint8_t ff_w64_guid_fact[16]
Definition w64.c:38
const uint8_t ff_w64_guid_fmt[16]
Definition w64.c:33
static void set_spdif(AVFormatContext *s, WAVDemuxContext *wav)
Definition wavdec.c:90
static const AVOption demux_options[]
Definition wavdec.c:73
#define W64_DEMUXER_OPTIONS_OFFSET
static void set_max_size(AVStream *st, WAVDemuxContext *wav)
Definition wavdec.c:82
#define OFFSET(x)
Definition wavdec.c:71