wav.c
Go to the documentation of this file.
1 /*
2  * WAV muxer and demuxer
3  * Copyright (c) 2001, 2002 Fabrice Bellard
4  *
5  * Sony Wave64 demuxer
6  * RF64 demuxer
7  * Copyright (c) 2009 Daniel Verkamp
8  *
9  * This file is part of Libav.
10  *
11  * Libav is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * Libav is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with Libav; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24  */
25 
26 #include "libavutil/avassert.h"
27 #include "libavutil/dict.h"
28 #include "libavutil/log.h"
29 #include "libavutil/mathematics.h"
30 #include "libavutil/opt.h"
31 #include "avformat.h"
32 #include "internal.h"
33 #include "avio_internal.h"
34 #include "pcm.h"
35 #include "riff.h"
36 #include "avio.h"
37 #include "metadata.h"
38 
39 typedef struct {
40  const AVClass *class;
41  int64_t data;
42  int64_t data_end;
43  int64_t minpts;
44  int64_t maxpts;
46  int w64;
48 } WAVContext;
49 
50 #if CONFIG_WAV_MUXER
51 static inline void bwf_write_bext_string(AVFormatContext *s, const char *key, int maxlen)
52 {
54  int len = 0;
55 
56  if (tag = av_dict_get(s->metadata, key, NULL, 0)) {
57  len = strlen(tag->value);
58  len = FFMIN(len, maxlen);
59  avio_write(s->pb, tag->value, len);
60  }
61 
62  ffio_fill(s->pb, 0, maxlen - len);
63 }
64 
65 static void bwf_write_bext_chunk(AVFormatContext *s)
66 {
67  AVDictionaryEntry *tmp_tag;
68  uint64_t time_reference = 0;
69  int64_t bext = ff_start_tag(s->pb, "bext");
70 
71  bwf_write_bext_string(s, "description", 256);
72  bwf_write_bext_string(s, "originator", 32);
73  bwf_write_bext_string(s, "originator_reference", 32);
74  bwf_write_bext_string(s, "origination_date", 10);
75  bwf_write_bext_string(s, "origination_time", 8);
76 
77  if (tmp_tag = av_dict_get(s->metadata, "time_reference", NULL, 0))
78  time_reference = strtoll(tmp_tag->value, NULL, 10);
79  avio_wl64(s->pb, time_reference);
80  avio_wl16(s->pb, 1); // set version to 1
81 
82  if (tmp_tag = av_dict_get(s->metadata, "umid", NULL, 0)) {
83  unsigned char umidpart_str[17] = {0};
84  int i;
85  uint64_t umidpart;
86  int len = strlen(tmp_tag->value+2);
87 
88  for (i = 0; i < len/16; i++) {
89  memcpy(umidpart_str, tmp_tag->value + 2 + (i*16), 16);
90  umidpart = strtoll(umidpart_str, NULL, 16);
91  avio_wb64(s->pb, umidpart);
92  }
93  ffio_fill(s->pb, 0, 64 - i*8);
94  } else
95  ffio_fill(s->pb, 0, 64); // zero UMID
96 
97  ffio_fill(s->pb, 0, 190); // Reserved
98 
99  if (tmp_tag = av_dict_get(s->metadata, "coding_history", NULL, 0))
100  avio_put_str(s->pb, tmp_tag->value);
101 
102  ff_end_tag(s->pb, bext);
103 }
104 
105 static int wav_write_header(AVFormatContext *s)
106 {
107  WAVContext *wav = s->priv_data;
108  AVIOContext *pb = s->pb;
109  int64_t fmt, fact;
110 
111  ffio_wfourcc(pb, "RIFF");
112  avio_wl32(pb, 0); /* file length */
113  ffio_wfourcc(pb, "WAVE");
114 
115  /* format header */
116  fmt = ff_start_tag(pb, "fmt ");
117  if (ff_put_wav_header(pb, s->streams[0]->codec) < 0) {
118  av_log(s, AV_LOG_ERROR, "%s codec not supported in WAVE format\n",
119  s->streams[0]->codec->codec ? s->streams[0]->codec->codec->name : "NONE");
120  return -1;
121  }
122  ff_end_tag(pb, fmt);
123 
124  if (s->streams[0]->codec->codec_tag != 0x01 /* hence for all other than PCM */
125  && s->pb->seekable) {
126  fact = ff_start_tag(pb, "fact");
127  avio_wl32(pb, 0);
128  ff_end_tag(pb, fact);
129  }
130 
131  if (wav->write_bext)
132  bwf_write_bext_chunk(s);
133 
134  avpriv_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate);
135  wav->maxpts = wav->last_duration = 0;
136  wav->minpts = INT64_MAX;
137 
138  /* data header */
139  wav->data = ff_start_tag(pb, "data");
140 
141  avio_flush(pb);
142 
143  return 0;
144 }
145 
146 static int wav_write_packet(AVFormatContext *s, AVPacket *pkt)
147 {
148  AVIOContext *pb = s->pb;
149  WAVContext *wav = s->priv_data;
150  avio_write(pb, pkt->data, pkt->size);
151  if(pkt->pts != AV_NOPTS_VALUE) {
152  wav->minpts = FFMIN(wav->minpts, pkt->pts);
153  wav->maxpts = FFMAX(wav->maxpts, pkt->pts);
154  wav->last_duration = pkt->duration;
155  } else
156  av_log(s, AV_LOG_ERROR, "wav_write_packet: NOPTS\n");
157  return 0;
158 }
159 
160 static int wav_write_trailer(AVFormatContext *s)
161 {
162  AVIOContext *pb = s->pb;
163  WAVContext *wav = s->priv_data;
164  int64_t file_size;
165 
166  avio_flush(pb);
167 
168  if (s->pb->seekable) {
169  ff_end_tag(pb, wav->data);
170 
171  /* update file size */
172  file_size = avio_tell(pb);
173  avio_seek(pb, 4, SEEK_SET);
174  avio_wl32(pb, (uint32_t)(file_size - 8));
175  avio_seek(pb, file_size, SEEK_SET);
176 
177  avio_flush(pb);
178 
179  if(s->streams[0]->codec->codec_tag != 0x01) {
180  /* Update num_samps in fact chunk */
181  int number_of_samples;
182  number_of_samples = av_rescale(wav->maxpts - wav->minpts + wav->last_duration,
183  s->streams[0]->codec->sample_rate * (int64_t)s->streams[0]->time_base.num,
184  s->streams[0]->time_base.den);
185  avio_seek(pb, wav->data-12, SEEK_SET);
186  avio_wl32(pb, number_of_samples);
187  avio_seek(pb, file_size, SEEK_SET);
188  avio_flush(pb);
189  }
190  }
191  return 0;
192 }
193 
194 #define OFFSET(x) offsetof(WAVContext, x)
195 #define ENC AV_OPT_FLAG_ENCODING_PARAM
196 static const AVOption options[] = {
197  { "write_bext", "Write BEXT chunk.", OFFSET(write_bext), AV_OPT_TYPE_INT, { 0 }, 0, 1, ENC },
198  { NULL },
199 };
200 
201 static const AVClass wav_muxer_class = {
202  .class_name = "WAV muxer",
203  .item_name = av_default_item_name,
204  .option = options,
205  .version = LIBAVUTIL_VERSION_INT,
206 };
207 
208 AVOutputFormat ff_wav_muxer = {
209  .name = "wav",
210  .long_name = NULL_IF_CONFIG_SMALL("WAV format"),
211  .mime_type = "audio/x-wav",
212  .extensions = "wav",
213  .priv_data_size = sizeof(WAVContext),
214  .audio_codec = CODEC_ID_PCM_S16LE,
215  .video_codec = CODEC_ID_NONE,
216  .write_header = wav_write_header,
217  .write_packet = wav_write_packet,
218  .write_trailer = wav_write_trailer,
219  .codec_tag= (const AVCodecTag* const []){ff_codec_wav_tags, 0},
220  .priv_class = &wav_muxer_class,
221 };
222 #endif /* CONFIG_WAV_MUXER */
223 
224 
225 #if CONFIG_WAV_DEMUXER
226 
227 static int64_t next_tag(AVIOContext *pb, uint32_t *tag)
228 {
229  *tag = avio_rl32(pb);
230  return avio_rl32(pb);
231 }
232 
233 /* return the size of the found tag */
234 static int64_t find_tag(AVIOContext *pb, uint32_t tag1)
235 {
236  unsigned int tag;
237  int64_t size;
238 
239  for (;;) {
240  if (pb->eof_reached)
241  return -1;
242  size = next_tag(pb, &tag);
243  if (tag == tag1)
244  break;
245  avio_skip(pb, size);
246  }
247  return size;
248 }
249 
250 static int wav_probe(AVProbeData *p)
251 {
252  /* check file header */
253  if (p->buf_size <= 32)
254  return 0;
255  if (!memcmp(p->buf + 8, "WAVE", 4)) {
256  if (!memcmp(p->buf, "RIFF", 4))
257  /*
258  Since ACT demuxer has standard WAV header at top of it's own,
259  returning score is decreased to avoid probe conflict
260  between ACT and WAV.
261  */
262  return AVPROBE_SCORE_MAX - 1;
263  else if (!memcmp(p->buf, "RF64", 4) &&
264  !memcmp(p->buf + 12, "ds64", 4))
265  return AVPROBE_SCORE_MAX;
266  }
267  return 0;
268 }
269 
270 static int wav_parse_fmt_tag(AVFormatContext *s, int64_t size, AVStream **st)
271 {
272  AVIOContext *pb = s->pb;
273  int ret;
274 
275  /* parse fmt header */
276  *st = avformat_new_stream(s, NULL);
277  if (!*st)
278  return AVERROR(ENOMEM);
279 
280  ret = ff_get_wav_header(pb, (*st)->codec, size);
281  if (ret < 0)
282  return ret;
283  (*st)->need_parsing = AVSTREAM_PARSE_FULL;
284 
285  avpriv_set_pts_info(*st, 64, 1, (*st)->codec->sample_rate);
286 
287  return 0;
288 }
289 
290 static inline int wav_parse_bext_string(AVFormatContext *s, const char *key,
291  int length)
292 {
293  char temp[257];
294  int ret;
295 
296  av_assert0(length <= sizeof(temp));
297  if ((ret = avio_read(s->pb, temp, length)) < 0)
298  return ret;
299 
300  temp[length] = 0;
301 
302  if (strlen(temp))
303  return av_dict_set(&s->metadata, key, temp, 0);
304 
305  return 0;
306 }
307 
308 static int wav_parse_bext_tag(AVFormatContext *s, int64_t size)
309 {
310  char temp[131], *coding_history;
311  int ret, x;
312  uint64_t time_reference;
313  int64_t umid_parts[8], umid_mask = 0;
314 
315  if ((ret = wav_parse_bext_string(s, "description", 256)) < 0 ||
316  (ret = wav_parse_bext_string(s, "originator", 32)) < 0 ||
317  (ret = wav_parse_bext_string(s, "originator_reference", 32)) < 0 ||
318  (ret = wav_parse_bext_string(s, "origination_date", 10)) < 0 ||
319  (ret = wav_parse_bext_string(s, "origination_time", 8)) < 0)
320  return ret;
321 
322  time_reference = avio_rl64(s->pb);
323  snprintf(temp, sizeof(temp), "%"PRIu64, time_reference);
324  if ((ret = av_dict_set(&s->metadata, "time_reference", temp, 0)) < 0)
325  return ret;
326 
327  /* check if version is >= 1, in which case an UMID may be present */
328  if (avio_rl16(s->pb) >= 1) {
329  for (x = 0; x < 8; x++)
330  umid_mask |= umid_parts[x] = avio_rb64(s->pb);
331 
332  if (umid_mask) {
333  /* the string formatting below is per SMPTE 330M-2004 Annex C */
334  if (umid_parts[4] == 0 && umid_parts[5] == 0 && umid_parts[6] == 0 && umid_parts[7] == 0) {
335  /* basic UMID */
336  snprintf(temp, sizeof(temp), "0x%016"PRIX64"%016"PRIX64"%016"PRIX64"%016"PRIX64,
337  umid_parts[0], umid_parts[1], umid_parts[2], umid_parts[3]);
338  } else {
339  /* extended UMID */
340  snprintf(temp, sizeof(temp), "0x%016"PRIX64"%016"PRIX64"%016"PRIX64"%016"PRIX64
341  "0x%016"PRIX64"%016"PRIX64"%016"PRIX64"%016"PRIX64,
342  umid_parts[0], umid_parts[1], umid_parts[2], umid_parts[3],
343  umid_parts[4], umid_parts[5], umid_parts[6], umid_parts[7]);
344  }
345 
346  if ((ret = av_dict_set(&s->metadata, "umid", temp, 0)) < 0)
347  return ret;
348  }
349 
350  avio_skip(s->pb, 190);
351  } else
352  avio_skip(s->pb, 254);
353 
354  if (size > 602) {
355  /* CodingHistory present */
356  size -= 602;
357 
358  if (!(coding_history = av_malloc(size+1)))
359  return AVERROR(ENOMEM);
360 
361  if ((ret = avio_read(s->pb, coding_history, size)) < 0)
362  return ret;
363 
364  coding_history[size] = 0;
365  if ((ret = av_dict_set(&s->metadata, "coding_history", coding_history,
367  return ret;
368  }
369 
370  return 0;
371 }
372 
373 static const AVMetadataConv wav_metadata_conv[] = {
374  {"description", "comment" },
375  {"originator", "encoded_by" },
376  {"origination_date", "date" },
377  {"origination_time", "creation_time"},
378  {0},
379 };
380 
381 /* wav input */
382 static int wav_read_header(AVFormatContext *s,
383  AVFormatParameters *ap)
384 {
385  int64_t size, av_uninit(data_size);
386  int64_t sample_count=0;
387  int rf64;
388  uint32_t tag, list_type;
389  AVIOContext *pb = s->pb;
390  AVStream *st;
391  WAVContext *wav = s->priv_data;
392  int ret, got_fmt = 0;
393  int64_t next_tag_ofs, data_ofs = -1;
394 
395  /* check RIFF header */
396  tag = avio_rl32(pb);
397 
398  rf64 = tag == MKTAG('R', 'F', '6', '4');
399  if (!rf64 && tag != MKTAG('R', 'I', 'F', 'F'))
400  return -1;
401  avio_rl32(pb); /* file size */
402  tag = avio_rl32(pb);
403  if (tag != MKTAG('W', 'A', 'V', 'E'))
404  return -1;
405 
406  if (rf64) {
407  if (avio_rl32(pb) != MKTAG('d', 's', '6', '4'))
408  return -1;
409  size = avio_rl32(pb);
410  if (size < 16)
411  return -1;
412  avio_rl64(pb); /* RIFF size */
413  data_size = avio_rl64(pb);
414  sample_count = avio_rl64(pb);
415  if (data_size < 0 || sample_count < 0) {
416  av_log(s, AV_LOG_ERROR, "negative data_size and/or sample_count in "
417  "ds64: data_size = %"PRId64", sample_count = %"PRId64"\n",
418  data_size, sample_count);
419  return AVERROR_INVALIDDATA;
420  }
421  avio_skip(pb, size - 16); /* skip rest of ds64 chunk */
422  }
423 
424  for (;;) {
425  size = next_tag(pb, &tag);
426  next_tag_ofs = avio_tell(pb) + size;
427 
428  if (pb->eof_reached)
429  break;
430 
431  switch (tag) {
432  case MKTAG('f', 'm', 't', ' '):
433  /* only parse the first 'fmt ' tag found */
434  if (!got_fmt && (ret = wav_parse_fmt_tag(s, size, &st) < 0)) {
435  return ret;
436  } else if (got_fmt)
437  av_log(s, AV_LOG_WARNING, "found more than one 'fmt ' tag\n");
438 
439  got_fmt = 1;
440  break;
441  case MKTAG('d', 'a', 't', 'a'):
442  if (!got_fmt) {
443  av_log(s, AV_LOG_ERROR, "found no 'fmt ' tag before the 'data' tag\n");
444  return AVERROR_INVALIDDATA;
445  }
446 
447  if (rf64) {
448  next_tag_ofs = wav->data_end = avio_tell(pb) + data_size;
449  } else {
450  data_size = size;
451  next_tag_ofs = wav->data_end = size ? next_tag_ofs : INT64_MAX;
452  }
453 
454  data_ofs = avio_tell(pb);
455 
456  /* don't look for footer metadata if we can't seek or if we don't
457  * know where the data tag ends
458  */
459  if (!pb->seekable || (!rf64 && !size))
460  goto break_loop;
461  break;
462  case MKTAG('f','a','c','t'):
463  if (!sample_count)
464  sample_count = avio_rl32(pb);
465  break;
466  case MKTAG('b','e','x','t'):
467  if ((ret = wav_parse_bext_tag(s, size)) < 0)
468  return ret;
469  break;
470  case MKTAG('L', 'I', 'S', 'T'):
471  list_type = avio_rl32(pb);
472  if (size <= 4) {
473  av_log(s, AV_LOG_ERROR, "too short LIST");
474  return AVERROR_INVALIDDATA;
475  }
476  switch (list_type) {
477  case MKTAG('I', 'N', 'F', 'O'):
478  if ((ret = ff_read_riff_info(s, size - 4)) < 0)
479  return ret;
480  }
481  break;
482  }
483 
484  /* seek to next tag unless we know that we'll run into EOF */
485  if ((avio_size(pb) > 0 && next_tag_ofs >= avio_size(pb)) ||
486  avio_seek(pb, next_tag_ofs, SEEK_SET) < 0) {
487  break;
488  }
489  }
490 break_loop:
491  if (data_ofs < 0) {
492  av_log(s, AV_LOG_ERROR, "no 'data' tag found\n");
493  return AVERROR_INVALIDDATA;
494  }
495 
496  avio_seek(pb, data_ofs, SEEK_SET);
497 
498  if (!sample_count && st->codec->channels && av_get_bits_per_sample(st->codec->codec_id))
499  sample_count = (data_size<<3) / (st->codec->channels * (uint64_t)av_get_bits_per_sample(st->codec->codec_id));
500  if (sample_count)
501  st->duration = sample_count;
502 
503  ff_metadata_conv_ctx(s, NULL, wav_metadata_conv);
505 
506  return 0;
507 }
508 
512 static int64_t find_guid(AVIOContext *pb, const uint8_t guid1[16])
513 {
514  uint8_t guid[16];
515  int64_t size;
516 
517  while (!pb->eof_reached) {
518  avio_read(pb, guid, 16);
519  size = avio_rl64(pb);
520  if (size <= 24)
521  return -1;
522  if (!memcmp(guid, guid1, 16))
523  return size;
524  avio_skip(pb, FFALIGN(size, INT64_C(8)) - 24);
525  }
526  return -1;
527 }
528 
529 static const uint8_t guid_data[16] = { 'd', 'a', 't', 'a',
530  0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A };
531 
532 #define MAX_SIZE 4096
533 
534 static int wav_read_packet(AVFormatContext *s,
535  AVPacket *pkt)
536 {
537  int ret, size;
538  int64_t left;
539  AVStream *st;
540  WAVContext *wav = s->priv_data;
541 
542  st = s->streams[0];
543 
544  left = wav->data_end - avio_tell(s->pb);
545  if (left <= 0){
546  if (CONFIG_W64_DEMUXER && wav->w64)
547  left = find_guid(s->pb, guid_data) - 24;
548  else
549  left = find_tag(s->pb, MKTAG('d', 'a', 't', 'a'));
550  if (left < 0)
551  return AVERROR_EOF;
552  wav->data_end= avio_tell(s->pb) + left;
553  }
554 
555  size = MAX_SIZE;
556  if (st->codec->block_align > 1) {
557  if (size < st->codec->block_align)
558  size = st->codec->block_align;
559  size = (size / st->codec->block_align) * st->codec->block_align;
560  }
561  size = FFMIN(size, left);
562  ret = av_get_packet(s->pb, pkt, size);
563  if (ret < 0)
564  return ret;
565  pkt->stream_index = 0;
566 
567  return ret;
568 }
569 
570 static int wav_read_seek(AVFormatContext *s,
571  int stream_index, int64_t timestamp, int flags)
572 {
573  AVStream *st;
574 
575  st = s->streams[0];
576  switch (st->codec->codec_id) {
577  case CODEC_ID_MP2:
578  case CODEC_ID_MP3:
579  case CODEC_ID_AC3:
580  case CODEC_ID_DTS:
581  /* use generic seeking with dynamically generated indexes */
582  return -1;
583  default:
584  break;
585  }
586  return pcm_read_seek(s, stream_index, timestamp, flags);
587 }
588 
589 AVInputFormat ff_wav_demuxer = {
590  .name = "wav",
591  .long_name = NULL_IF_CONFIG_SMALL("WAV format"),
592  .priv_data_size = sizeof(WAVContext),
593  .read_probe = wav_probe,
594  .read_header = wav_read_header,
595  .read_packet = wav_read_packet,
596  .read_seek = wav_read_seek,
597  .flags= AVFMT_GENERIC_INDEX,
598  .codec_tag= (const AVCodecTag* const []){ff_codec_wav_tags, 0},
599 };
600 #endif /* CONFIG_WAV_DEMUXER */
601 
602 
603 #if CONFIG_W64_DEMUXER
604 static const uint8_t guid_riff[16] = { 'r', 'i', 'f', 'f',
605  0x2E, 0x91, 0xCF, 0x11, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00 };
606 
607 static const uint8_t guid_wave[16] = { 'w', 'a', 'v', 'e',
608  0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A };
609 
610 static const uint8_t guid_fmt [16] = { 'f', 'm', 't', ' ',
611  0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A };
612 
613 static int w64_probe(AVProbeData *p)
614 {
615  if (p->buf_size <= 40)
616  return 0;
617  if (!memcmp(p->buf, guid_riff, 16) &&
618  !memcmp(p->buf + 24, guid_wave, 16))
619  return AVPROBE_SCORE_MAX;
620  else
621  return 0;
622 }
623 
624 static int w64_read_header(AVFormatContext *s, AVFormatParameters *ap)
625 {
626  int64_t size;
627  AVIOContext *pb = s->pb;
628  WAVContext *wav = s->priv_data;
629  AVStream *st;
630  uint8_t guid[16];
631  int ret;
632 
633  avio_read(pb, guid, 16);
634  if (memcmp(guid, guid_riff, 16))
635  return -1;
636 
637  if (avio_rl64(pb) < 16 + 8 + 16 + 8 + 16 + 8) /* riff + wave + fmt + sizes */
638  return -1;
639 
640  avio_read(pb, guid, 16);
641  if (memcmp(guid, guid_wave, 16)) {
642  av_log(s, AV_LOG_ERROR, "could not find wave guid\n");
643  return -1;
644  }
645 
646  size = find_guid(pb, guid_fmt);
647  if (size < 0) {
648  av_log(s, AV_LOG_ERROR, "could not find fmt guid\n");
649  return -1;
650  }
651 
652  st = avformat_new_stream(s, NULL);
653  if (!st)
654  return AVERROR(ENOMEM);
655 
656  /* subtract chunk header size - normal wav file doesn't count it */
657  ret = ff_get_wav_header(pb, st->codec, size - 24);
658  if (ret < 0)
659  return ret;
660  avio_skip(pb, FFALIGN(size, INT64_C(8)) - size);
661 
663 
664  avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
665 
666  size = find_guid(pb, guid_data);
667  if (size < 0) {
668  av_log(s, AV_LOG_ERROR, "could not find data guid\n");
669  return -1;
670  }
671  wav->data_end = avio_tell(pb) + size - 24;
672  wav->w64 = 1;
673 
674  return 0;
675 }
676 
677 AVInputFormat ff_w64_demuxer = {
678  .name = "w64",
679  .long_name = NULL_IF_CONFIG_SMALL("Sony Wave64 format"),
680  .priv_data_size = sizeof(WAVContext),
681  .read_probe = w64_probe,
682  .read_header = w64_read_header,
683  .read_packet = wav_read_packet,
684  .read_seek = wav_read_seek,
685  .flags = AVFMT_GENERIC_INDEX,
686  .codec_tag = (const AVCodecTag* const []){ff_codec_wav_tags, 0},
687 };
688 #endif /* CONFIG_W64_DEMUXER */