63 #if CONFIG_WAV_DEMUXER
65 static int64_t next_tag(
AVIOContext *pb, uint32_t *
tag,
int big_endian)
78 offset += offset < INT64_MAX && offset + wav->
unaligned & 1;
92 size = next_tag(pb, &tag, wav->
rifx);
95 wav_seek_tag(wav, pb, size, SEEK_CUR);
105 if (!memcmp(p->
buf + 8,
"WAVE", 4)) {
106 if (!memcmp(p->
buf,
"RIFF", 4) || !memcmp(p->
buf,
"RIFX", 4))
111 else if (!memcmp(p->
buf,
"RF64", 4) &&
112 !memcmp(p->
buf + 12,
"ds64", 4))
118 static void handle_stream_probing(
AVStream *st)
140 handle_stream_probing(*st);
149 static inline int wav_parse_bext_string(
AVFormatContext *s,
const char *key,
169 char temp[131], *coding_history;
171 uint64_t time_reference;
172 int64_t umid_parts[8], umid_mask = 0;
174 if ((ret = wav_parse_bext_string(s,
"description", 256)) < 0 ||
175 (ret = wav_parse_bext_string(s,
"originator", 32)) < 0 ||
176 (ret = wav_parse_bext_string(s,
"originator_reference", 32)) < 0 ||
177 (ret = wav_parse_bext_string(s,
"origination_date", 10)) < 0 ||
178 (ret = wav_parse_bext_string(s,
"origination_time", 8)) < 0)
182 snprintf(temp,
sizeof(temp),
"%"PRIu64, time_reference);
188 for (x = 0; x < 8; x++)
193 if (umid_parts[4] == 0 && umid_parts[5] == 0 &&
194 umid_parts[6] == 0 && umid_parts[7] == 0) {
197 "0x%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64,
198 umid_parts[0], umid_parts[1],
199 umid_parts[2], umid_parts[3]);
203 "0x%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64
204 "%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64,
205 umid_parts[0], umid_parts[1],
206 umid_parts[2], umid_parts[3],
207 umid_parts[4], umid_parts[5],
208 umid_parts[6], umid_parts[7]);
223 if (!(coding_history =
av_malloc(size + 1)))
226 if ((ret =
avio_read(s->
pb, coding_history, size)) < 0)
229 coding_history[
size] = 0;
239 {
"description",
"comment" },
240 {
"originator",
"encoded_by" },
241 {
"origination_date",
"date" },
242 {
"origination_time",
"creation_time" },
250 int64_t sample_count = 0;
257 int ret, got_fmt = 0;
258 int64_t next_tag_ofs, data_ofs = -1;
267 case MKTAG(
'R',
'I',
'F',
'F'):
269 case MKTAG(
'R',
'I',
'F',
'X'):
272 case MKTAG(
'R',
'F',
'6',
'4'):
301 if (data_size < 0 || sample_count < 0) {
303 "ds64: data_size = %"PRId64
", sample_count = %"PRId64
"\n",
304 data_size, sample_count);
313 size = next_tag(pb, &tag, wav->
rifx);
320 case MKTAG(
'f',
'm',
't',
' '):
322 if (!got_fmt && (ret = wav_parse_fmt_tag(s, size, &st)) < 0) {
329 case MKTAG(
'd',
'a',
't',
'a'):
332 "found no 'fmt ' tag before the 'data' tag\n");
340 next_tag_ofs = wav->
data_end = size ? next_tag_ofs : INT64_MAX;
348 if (!pb->
seekable || (!rf64 && !size))
351 case MKTAG(
'f',
'a',
'c',
't'):
355 case MKTAG(
'b',
'e',
'x',
't'):
356 if ((ret = wav_parse_bext_tag(s, size)) < 0)
359 case MKTAG(
'S',
'M',
'V',
'0'):
365 if (size !=
MKTAG(
'0',
'2',
'0',
'0')) {
400 case MKTAG(
'L',
'I',
'S',
'T'):
406 case MKTAG(
'I',
'N',
'F',
'O'):
414 wav_seek_tag(wav, pb, next_tag_ofs, SEEK_SET) < 0) {
438 sample_count = (data_size << 3)
465 if (!memcmp(guid, guid1, 16))
472 #define MAX_SIZE 4096
481 if (CONFIG_SPDIF_DEMUXER && wav->
spdif == 0 &&
493 if (CONFIG_SPDIF_DEMUXER && wav->
spdif == 1)
497 int64_t audio_dts, video_dts;
549 if (CONFIG_W64_DEMUXER && wav->
w64)
552 left = find_tag(wav, s->
pb,
MKTAG(
'd',
'a',
't',
'a'));
568 size =
FFMIN(size, left);
578 int stream_index, int64_t timestamp,
int flags)
585 int64_t smv_timestamp = timestamp;
586 if (stream_index == 0)
610 #define OFFSET(x) offsetof(WAVDemuxContext, x)
611 #define DEC AV_OPT_FLAG_DECODING_PARAM
612 static const AVOption demux_options[] = {
617 static const AVClass wav_demuxer_class = {
620 .option = demux_options,
633 .priv_class = &wav_demuxer_class,
637 #if CONFIG_W64_DEMUXER
651 int64_t
size, data_ofs = 0;
663 if (
avio_rl64(pb) < 16 + 8 + 16 + 8 + 16 + 8)
682 if (size <= 24 || INT64_MAX - size <
avio_tell(pb))
709 uint32_t
count, chunk_size, i;
712 end = start +
FFALIGN(size, INT64_C(8)) - 24;
715 for (i = 0; i <
count; i++) {
716 char chunk_key[5], *
value;
748 handle_stream_probing(st);