60 #if CONFIG_WAV_DEMUXER
71 offset += offset < INT64_MAX && offset + wav->
unaligned & 1;
85 size = next_tag(pb, &tag);
88 wav_seek_tag(wav, pb, size, SEEK_CUR);
98 if (!memcmp(p->
buf + 8,
"WAVE", 4)) {
99 if (!memcmp(p->
buf,
"RIFF", 4))
104 else if (!memcmp(p->
buf,
"RF64", 4) &&
105 !memcmp(p->
buf + 12,
"ds64", 4))
111 static void handle_stream_probing(
AVStream *st)
132 handle_stream_probing(*st);
141 static inline int wav_parse_bext_string(
AVFormatContext *s,
const char *key,
161 char temp[131], *coding_history;
163 uint64_t time_reference;
164 int64_t umid_parts[8], umid_mask = 0;
166 if ((ret = wav_parse_bext_string(s,
"description", 256)) < 0 ||
167 (ret = wav_parse_bext_string(s,
"originator", 32)) < 0 ||
168 (ret = wav_parse_bext_string(s,
"originator_reference", 32)) < 0 ||
169 (ret = wav_parse_bext_string(s,
"origination_date", 10)) < 0 ||
170 (ret = wav_parse_bext_string(s,
"origination_time", 8)) < 0)
174 snprintf(temp,
sizeof(temp),
"%"PRIu64, time_reference);
180 for (x = 0; x < 8; x++)
185 if (umid_parts[4] == 0 && umid_parts[5] == 0 &&
186 umid_parts[6] == 0 && umid_parts[7] == 0) {
189 "0x%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64,
190 umid_parts[0], umid_parts[1],
191 umid_parts[2], umid_parts[3]);
195 "0x%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64
196 "%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64,
197 umid_parts[0], umid_parts[1],
198 umid_parts[2], umid_parts[3],
199 umid_parts[4], umid_parts[5],
200 umid_parts[6], umid_parts[7]);
215 if (!(coding_history =
av_malloc(size + 1)))
218 if ((ret =
avio_read(s->
pb, coding_history, size)) < 0)
221 coding_history[
size] = 0;
231 {
"description",
"comment" },
232 {
"originator",
"encoded_by" },
233 {
"origination_date",
"date" },
234 {
"origination_time",
"creation_time" },
242 int64_t sample_count = 0;
248 int ret, got_fmt = 0;
249 int64_t next_tag_ofs, data_ofs = -1;
258 rf64 = tag ==
MKTAG(
'R',
'F',
'6',
'4');
259 if (!rf64 && tag !=
MKTAG(
'R',
'I',
'F',
'F'))
263 if (tag !=
MKTAG(
'W',
'A',
'V',
'E'))
277 if (data_size < 0 || sample_count < 0) {
279 "ds64: data_size = %"PRId64
", sample_count = %"PRId64
"\n",
280 data_size, sample_count);
289 size = next_tag(pb, &tag);
296 case MKTAG(
'f',
'm',
't',
' '):
298 if (!got_fmt && (ret = wav_parse_fmt_tag(s, size, &st)) < 0) {
305 case MKTAG(
'd',
'a',
't',
'a'):
308 "found no 'fmt ' tag before the 'data' tag\n");
316 next_tag_ofs = wav->
data_end = size ? next_tag_ofs : INT64_MAX;
324 if (!pb->
seekable || (!rf64 && !size))
327 case MKTAG(
'f',
'a',
'c',
't'):
331 case MKTAG(
'b',
'e',
'x',
't'):
332 if ((ret = wav_parse_bext_tag(s, size)) < 0)
335 case MKTAG(
'S',
'M',
'V',
'0'):
341 if (size !=
MKTAG(
'0',
'2',
'0',
'0')) {
376 case MKTAG(
'L',
'I',
'S',
'T'):
382 case MKTAG(
'I',
'N',
'F',
'O'):
390 wav_seek_tag(wav, pb, next_tag_ofs, SEEK_SET) < 0) {
408 sample_count = (data_size << 3)
435 if (!memcmp(guid, guid1, 16))
442 #define MAX_SIZE 4096
451 if (CONFIG_SPDIF_DEMUXER && wav->
spdif == 0 &&
463 if (CONFIG_SPDIF_DEMUXER && wav->
spdif == 1)
467 int64_t audio_dts, video_dts;
519 if (CONFIG_W64_DEMUXER && wav->
w64)
522 left = find_tag(wav, s->
pb,
MKTAG(
'd',
'a',
't',
'a'));
534 if (size < st->codec->block_align)
538 size =
FFMIN(size, left);
548 int stream_index, int64_t timestamp,
int flags)
555 int64_t smv_timestamp = timestamp;
556 if (stream_index == 0)
580 #define OFFSET(x) offsetof(WAVDemuxContext, x)
581 #define DEC AV_OPT_FLAG_DECODING_PARAM
582 static const AVOption demux_options[] = {
587 static const AVClass wav_demuxer_class = {
590 .option = demux_options,
603 .priv_class = &wav_demuxer_class,
607 #if CONFIG_W64_DEMUXER
621 int64_t
size, data_ofs = 0;
633 if (
avio_rl64(pb) < 16 + 8 + 16 + 8 + 16 + 8)
652 if (size <= 24 || INT64_MAX - size <
avio_tell(pb))
679 uint32_t
count, chunk_size, i;
682 end = start +
FFALIGN(size, INT64_C(8)) - 24;
685 for (i = 0; i <
count; i++) {
686 char chunk_key[5], *
value;
718 handle_stream_probing(st);