46 #if CONFIG_WAV_DEMUXER
55 static int64_t wav_seek_tag(
AVIOContext *s, int64_t offset,
int whence)
57 return avio_seek(s, offset + (offset & 1), whence);
61 static int64_t find_tag(
AVIOContext *pb, uint32_t tag1)
69 size = next_tag(pb, &tag);
72 wav_seek_tag(pb, size, SEEK_CUR);
82 if (!memcmp(p->
buf + 8,
"WAVE", 4)) {
83 if (!memcmp(p->
buf,
"RIFF", 4))
88 else if (!memcmp(p->
buf,
"RF64", 4) &&
89 !memcmp(p->
buf + 12,
"ds64", 4))
115 static inline int wav_parse_bext_string(
AVFormatContext *s,
const char *key,
135 char temp[131], *coding_history;
137 uint64_t time_reference;
138 int64_t umid_parts[8], umid_mask = 0;
140 if ((ret = wav_parse_bext_string(s,
"description", 256)) < 0 ||
141 (ret = wav_parse_bext_string(s,
"originator", 32)) < 0 ||
142 (ret = wav_parse_bext_string(s,
"originator_reference", 32)) < 0 ||
143 (ret = wav_parse_bext_string(s,
"origination_date", 10)) < 0 ||
144 (ret = wav_parse_bext_string(s,
"origination_time", 8)) < 0)
148 snprintf(temp,
sizeof(temp),
"%"PRIu64, time_reference);
154 for (x = 0; x < 8; x++)
159 if (umid_parts[4] == 0 && umid_parts[5] == 0 &&
160 umid_parts[6] == 0 && umid_parts[7] == 0) {
162 snprintf(temp,
sizeof(temp),
163 "0x%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64,
164 umid_parts[0], umid_parts[1],
165 umid_parts[2], umid_parts[3]);
168 snprintf(temp,
sizeof(temp),
169 "0x%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64
170 "0x%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64,
171 umid_parts[0], umid_parts[1],
172 umid_parts[2], umid_parts[3],
173 umid_parts[4], umid_parts[5],
174 umid_parts[6], umid_parts[7]);
189 if (!(coding_history =
av_malloc(size + 1)))
192 if ((ret =
avio_read(s->
pb, coding_history, size)) < 0)
195 coding_history[
size] = 0;
205 {
"description",
"comment" },
206 {
"originator",
"encoded_by" },
207 {
"origination_date",
"date" },
208 {
"origination_time",
"creation_time" },
216 int64_t sample_count = 0;
222 int ret, got_fmt = 0;
223 int64_t next_tag_ofs, data_ofs = -1;
228 rf64 = tag ==
MKTAG(
'R',
'F',
'6',
'4');
229 if (!rf64 && tag !=
MKTAG(
'R',
'I',
'F',
'F'))
233 if (tag !=
MKTAG(
'W',
'A',
'V',
'E'))
247 if (data_size < 0 || sample_count < 0) {
249 "ds64: data_size = %"PRId64
", sample_count = %"PRId64
"\n",
250 data_size, sample_count);
257 size = next_tag(pb, &tag);
264 case MKTAG(
'f',
'm',
't',
' '):
266 if (!got_fmt && (ret = wav_parse_fmt_tag(s, size, &st) < 0)) {
273 case MKTAG(
'd',
'a',
't',
'a'):
276 "found no 'fmt ' tag before the 'data' tag\n");
284 next_tag_ofs = wav->
data_end = size ? next_tag_ofs : INT64_MAX;
292 if (!pb->
seekable || (!rf64 && !size))
295 case MKTAG(
'f',
'a',
'c',
't'):
299 case MKTAG(
'b',
'e',
'x',
't'):
300 if ((ret = wav_parse_bext_tag(s, size)) < 0)
303 case MKTAG(
'L',
'I',
'S',
'T'):
309 case MKTAG(
'I',
'N',
'F',
'O'):
318 wav_seek_tag(pb, next_tag_ofs, SEEK_SET) < 0) {
333 sample_count = (data_size << 3) /
359 if (!memcmp(guid, guid1, 16))
366 static const uint8_t guid_data[16] = {
368 0xF3, 0xAC, 0xD3, 0x11,0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A
371 #define MAX_SIZE 4096
385 left = find_guid(s->
pb, guid_data) - 24;
387 left = find_tag(s->
pb,
MKTAG(
'd',
'a',
't',
'a'));
395 if (size < st->codec->block_align)
399 size =
FFMIN(size, left);
409 int stream_index, int64_t timestamp,
int flags)
440 #if CONFIG_W64_DEMUXER
441 static const uint8_t guid_riff[16] = {
443 0x2E, 0x91, 0xCF, 0x11,0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
446 static const uint8_t guid_wave[16] = {
448 0xF3, 0xAC, 0xD3, 0x11,0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A
451 static const uint8_t guid_fmt[16] = {
453 0xF3, 0xAC, 0xD3, 0x11,0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A
460 if (!memcmp(p->
buf, guid_riff, 16) &&
461 !memcmp(p->
buf + 24, guid_wave, 16))
477 if (memcmp(guid, guid_riff, 16))
481 if (
avio_rl64(pb) < 16 + 8 + 16 + 8 + 16 + 8)
485 if (memcmp(guid, guid_wave, 16)) {
490 size = find_guid(pb, guid_fmt);
510 size = find_guid(pb, guid_data);