57 #if CONFIG_WAV_DEMUXER
68 return avio_seek(s, offset + (offset & 1), whence);
72 static int64_t find_tag(
AVIOContext *pb, uint32_t tag1)
80 size = next_tag(pb, &tag);
83 wav_seek_tag(pb, size, SEEK_CUR);
93 if (!memcmp(p->
buf + 8,
"WAVE", 4)) {
94 if (!memcmp(p->
buf,
"RIFF", 4))
101 else if (!memcmp(p->
buf,
"RF64", 4) &&
102 !memcmp(p->
buf + 12,
"ds64", 4))
108 static void handle_stream_probing(
AVStream *st)
129 handle_stream_probing(*st);
138 static inline int wav_parse_bext_string(
AVFormatContext *s,
const char *key,
158 char temp[131], *coding_history;
160 uint64_t time_reference;
161 int64_t umid_parts[8], umid_mask = 0;
163 if ((ret = wav_parse_bext_string(s,
"description", 256)) < 0 ||
164 (ret = wav_parse_bext_string(s,
"originator", 32)) < 0 ||
165 (ret = wav_parse_bext_string(s,
"originator_reference", 32)) < 0 ||
166 (ret = wav_parse_bext_string(s,
"origination_date", 10)) < 0 ||
167 (ret = wav_parse_bext_string(s,
"origination_time", 8)) < 0)
171 snprintf(temp,
sizeof(temp),
"%"PRIu64, time_reference);
177 for (x = 0; x < 8; x++)
182 if (umid_parts[4] == 0 && umid_parts[5] == 0 && umid_parts[6] == 0 && umid_parts[7] == 0) {
184 snprintf(temp,
sizeof(temp),
"0x%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64,
185 umid_parts[0], umid_parts[1], umid_parts[2], umid_parts[3]);
188 snprintf(temp,
sizeof(temp),
"0x%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64
189 "%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64,
190 umid_parts[0], umid_parts[1], umid_parts[2], umid_parts[3],
191 umid_parts[4], umid_parts[5], umid_parts[6], umid_parts[7]);
206 if (!(coding_history =
av_malloc(size+1)))
209 if ((ret =
avio_read(s->
pb, coding_history, size)) < 0)
212 coding_history[
size] = 0;
222 {
"description",
"comment" },
223 {
"originator",
"encoded_by" },
224 {
"origination_date",
"date" },
225 {
"origination_time",
"creation_time"},
233 int64_t sample_count=0;
239 int ret, got_fmt = 0;
240 int64_t next_tag_ofs, data_ofs = -1;
247 rf64 = tag ==
MKTAG(
'R',
'F',
'6',
'4');
248 if (!rf64 && tag !=
MKTAG(
'R',
'I',
'F',
'F'))
252 if (tag !=
MKTAG(
'W',
'A',
'V',
'E'))
264 if (data_size < 0 || sample_count < 0) {
266 "ds64: data_size = %"PRId64
", sample_count = %"PRId64
"\n",
267 data_size, sample_count);
276 size = next_tag(pb, &tag);
283 case MKTAG(
'f',
'm',
't',
' '):
285 if (!got_fmt && (ret = wav_parse_fmt_tag(s, size, &st)) < 0) {
292 case MKTAG(
'd',
'a',
't',
'a'):
302 next_tag_ofs = wav->
data_end = size ? next_tag_ofs : INT64_MAX;
310 if (!pb->
seekable || (!rf64 && !size))
313 case MKTAG(
'f',
'a',
'c',
't'):
317 case MKTAG(
'b',
'e',
'x',
't'):
318 if ((ret = wav_parse_bext_tag(s, size)) < 0)
321 case MKTAG(
'S',
'M',
'V',
'0'):
327 if (size !=
MKTAG(
'0',
'2',
'0',
'0')) {
351 case MKTAG(
'L',
'I',
'S',
'T'):
357 case MKTAG(
'I',
'N',
'F',
'O'):
365 wav_seek_tag(pb, next_tag_ofs, SEEK_SET) < 0) {
401 if (!memcmp(guid, guid1, 16))
408 #define MAX_SIZE 4096
418 if (CONFIG_SPDIF_DEMUXER && wav->
spdif == 0 &&
430 if (CONFIG_SPDIF_DEMUXER && wav->
spdif == 1)
434 int64_t audio_dts, video_dts;
478 if (CONFIG_W64_DEMUXER && wav->
w64)
481 left = find_tag(s->
pb,
MKTAG(
'd',
'a',
't',
'a'));
493 if (size < st->codec->block_align)
497 size =
FFMIN(size, left);
507 int stream_index, int64_t timestamp,
int flags)
514 int64_t smv_timestamp = timestamp;
515 if (stream_index == 0)
536 #define OFFSET(x) offsetof(WAVDemuxContext, x)
537 #define DEC AV_OPT_FLAG_DECODING_PARAM
538 static const AVOption demux_options[] = {
543 static const AVClass wav_demuxer_class = {
546 .option = demux_options,
559 .priv_class = &wav_demuxer_class,
564 #if CONFIG_W64_DEMUXER
578 int64_t
size, data_ofs = 0;
589 if (
avio_rl64(pb) < 16 + 8 + 16 + 8 + 16 + 8)
608 if (size <= 24 || INT64_MAX - size <
avio_tell(pb))
628 int64_t start,
end, cur;
629 uint32_t count, chunk_size, i;
635 for (i = 0; i < count; i++) {
636 char chunk_key[5], *
value;
668 handle_stream_probing(st);