FFmpeg
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
wavdec.c
Go to the documentation of this file.
1 /*
2  * WAV 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 FFmpeg.
10  *
11  * FFmpeg 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  * FFmpeg 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 FFmpeg; 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 "w64.h"
37 #include "avio.h"
38 #include "metadata.h"
39 #include "spdif.h"
40 
41 typedef struct WAVDemuxContext {
42  const AVClass *class;
43  int64_t data_end;
44  int w64;
45  int64_t smv_data_ofs;
48  int smv_block;
50  int smv_eof;
51  int audio_eof;
53  int spdif;
55 
56 
57 #if CONFIG_WAV_DEMUXER
58 
59 static int64_t next_tag(AVIOContext *pb, uint32_t *tag)
60 {
61  *tag = avio_rl32(pb);
62  return avio_rl32(pb);
63 }
64 
65 /* RIFF chunks are always on a even offset. */
66 static int64_t wav_seek_tag(AVIOContext *s, int64_t offset, int whence)
67 {
68  return avio_seek(s, offset + (offset & 1), whence);
69 }
70 
71 /* return the size of the found tag */
72 static int64_t find_tag(AVIOContext *pb, uint32_t tag1)
73 {
74  unsigned int tag;
75  int64_t size;
76 
77  for (;;) {
78  if (url_feof(pb))
79  return -1;
80  size = next_tag(pb, &tag);
81  if (tag == tag1)
82  break;
83  wav_seek_tag(pb, size, SEEK_CUR);
84  }
85  return size;
86 }
87 
88 static int wav_probe(AVProbeData *p)
89 {
90  /* check file header */
91  if (p->buf_size <= 32)
92  return 0;
93  if (!memcmp(p->buf + 8, "WAVE", 4)) {
94  if (!memcmp(p->buf, "RIFF", 4))
95  /*
96  Since ACT demuxer has standard WAV header at top of it's own,
97  returning score is decreased to avoid probe conflict
98  between ACT and WAV.
99  */
100  return AVPROBE_SCORE_MAX - 1;
101  else if (!memcmp(p->buf, "RF64", 4) &&
102  !memcmp(p->buf + 12, "ds64", 4))
103  return AVPROBE_SCORE_MAX;
104  }
105  return 0;
106 }
107 
108 static void handle_stream_probing(AVStream *st)
109 {
110  if (st->codec->codec_id == AV_CODEC_ID_PCM_S16LE) {
112  st->probe_packets = FFMIN(st->probe_packets, 4);
113  }
114 }
115 
116 static int wav_parse_fmt_tag(AVFormatContext *s, int64_t size, AVStream **st)
117 {
118  AVIOContext *pb = s->pb;
119  int ret;
120 
121  /* parse fmt header */
122  *st = avformat_new_stream(s, NULL);
123  if (!*st)
124  return AVERROR(ENOMEM);
125 
126  ret = ff_get_wav_header(pb, (*st)->codec, size);
127  if (ret < 0)
128  return ret;
129  handle_stream_probing(*st);
130 
131  (*st)->need_parsing = AVSTREAM_PARSE_FULL_RAW;
132 
133  avpriv_set_pts_info(*st, 64, 1, (*st)->codec->sample_rate);
134 
135  return 0;
136 }
137 
138 static inline int wav_parse_bext_string(AVFormatContext *s, const char *key,
139  int length)
140 {
141  char temp[257];
142  int ret;
143 
144  av_assert0(length <= sizeof(temp));
145  if ((ret = avio_read(s->pb, temp, length)) < 0)
146  return ret;
147 
148  temp[length] = 0;
149 
150  if (strlen(temp))
151  return av_dict_set(&s->metadata, key, temp, 0);
152 
153  return 0;
154 }
155 
156 static int wav_parse_bext_tag(AVFormatContext *s, int64_t size)
157 {
158  char temp[131], *coding_history;
159  int ret, x;
160  uint64_t time_reference;
161  int64_t umid_parts[8], umid_mask = 0;
162 
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)
168  return ret;
169 
170  time_reference = avio_rl64(s->pb);
171  snprintf(temp, sizeof(temp), "%"PRIu64, time_reference);
172  if ((ret = av_dict_set(&s->metadata, "time_reference", temp, 0)) < 0)
173  return ret;
174 
175  /* check if version is >= 1, in which case an UMID may be present */
176  if (avio_rl16(s->pb) >= 1) {
177  for (x = 0; x < 8; x++)
178  umid_mask |= umid_parts[x] = avio_rb64(s->pb);
179 
180  if (umid_mask) {
181  /* the string formatting below is per SMPTE 330M-2004 Annex C */
182  if (umid_parts[4] == 0 && umid_parts[5] == 0 && umid_parts[6] == 0 && umid_parts[7] == 0) {
183  /* basic UMID */
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]);
186  } else {
187  /* extended UMID */
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]);
192  }
193 
194  if ((ret = av_dict_set(&s->metadata, "umid", temp, 0)) < 0)
195  return ret;
196  }
197 
198  avio_skip(s->pb, 190);
199  } else
200  avio_skip(s->pb, 254);
201 
202  if (size > 602) {
203  /* CodingHistory present */
204  size -= 602;
205 
206  if (!(coding_history = av_malloc(size+1)))
207  return AVERROR(ENOMEM);
208 
209  if ((ret = avio_read(s->pb, coding_history, size)) < 0)
210  return ret;
211 
212  coding_history[size] = 0;
213  if ((ret = av_dict_set(&s->metadata, "coding_history", coding_history,
215  return ret;
216  }
217 
218  return 0;
219 }
220 
221 static const AVMetadataConv wav_metadata_conv[] = {
222  {"description", "comment" },
223  {"originator", "encoded_by" },
224  {"origination_date", "date" },
225  {"origination_time", "creation_time"},
226  {0},
227 };
228 
229 /* wav input */
230 static int wav_read_header(AVFormatContext *s)
231 {
232  int64_t size, av_uninit(data_size);
233  int64_t sample_count=0;
234  int rf64;
235  uint32_t tag;
236  AVIOContext *pb = s->pb;
237  AVStream *st = NULL;
238  WAVDemuxContext *wav = s->priv_data;
239  int ret, got_fmt = 0;
240  int64_t next_tag_ofs, data_ofs = -1;
241 
242  wav->smv_data_ofs = -1;
243 
244  /* check RIFF header */
245  tag = avio_rl32(pb);
246 
247  rf64 = tag == MKTAG('R', 'F', '6', '4');
248  if (!rf64 && tag != MKTAG('R', 'I', 'F', 'F'))
249  return -1;
250  avio_rl32(pb); /* file size */
251  tag = avio_rl32(pb);
252  if (tag != MKTAG('W', 'A', 'V', 'E'))
253  return -1;
254 
255  if (rf64) {
256  if (avio_rl32(pb) != MKTAG('d', 's', '6', '4'))
257  return -1;
258  size = avio_rl32(pb);
259  if (size < 24)
260  return -1;
261  avio_rl64(pb); /* RIFF size */
262  data_size = avio_rl64(pb);
263  sample_count = avio_rl64(pb);
264  if (data_size < 0 || sample_count < 0) {
265  av_log(s, AV_LOG_ERROR, "negative data_size and/or sample_count in "
266  "ds64: data_size = %"PRId64", sample_count = %"PRId64"\n",
267  data_size, sample_count);
268  return AVERROR_INVALIDDATA;
269  }
270  avio_skip(pb, size - 24); /* skip rest of ds64 chunk */
271 
272  }
273 
274  for (;;) {
275  AVStream *vst;
276  size = next_tag(pb, &tag);
277  next_tag_ofs = avio_tell(pb) + size;
278 
279  if (url_feof(pb))
280  break;
281 
282  switch (tag) {
283  case MKTAG('f', 'm', 't', ' '):
284  /* only parse the first 'fmt ' tag found */
285  if (!got_fmt && (ret = wav_parse_fmt_tag(s, size, &st)) < 0) {
286  return ret;
287  } else if (got_fmt)
288  av_log(s, AV_LOG_WARNING, "found more than one 'fmt ' tag\n");
289 
290  got_fmt = 1;
291  break;
292  case MKTAG('d', 'a', 't', 'a'):
293  if (!got_fmt) {
294  av_log(s, AV_LOG_ERROR, "found no 'fmt ' tag before the 'data' tag\n");
295  return AVERROR_INVALIDDATA;
296  }
297 
298  if (rf64) {
299  next_tag_ofs = wav->data_end = avio_tell(pb) + data_size;
300  } else {
301  data_size = size;
302  next_tag_ofs = wav->data_end = size ? next_tag_ofs : INT64_MAX;
303  }
304 
305  data_ofs = avio_tell(pb);
306 
307  /* don't look for footer metadata if we can't seek or if we don't
308  * know where the data tag ends
309  */
310  if (!pb->seekable || (!rf64 && !size))
311  goto break_loop;
312  break;
313  case MKTAG('f','a','c','t'):
314  if (!sample_count)
315  sample_count = avio_rl32(pb);
316  break;
317  case MKTAG('b','e','x','t'):
318  if ((ret = wav_parse_bext_tag(s, size)) < 0)
319  return ret;
320  break;
321  case MKTAG('S','M','V','0'):
322  if (!got_fmt) {
323  av_log(s, AV_LOG_ERROR, "found no 'fmt ' tag before the 'SMV0' tag\n");
324  return AVERROR_INVALIDDATA;
325  }
326  // SMV file, a wav file with video appended.
327  if (size != MKTAG('0','2','0','0')) {
328  av_log(s, AV_LOG_ERROR, "Unknown SMV version found\n");
329  goto break_loop;
330  }
331  av_log(s, AV_LOG_DEBUG, "Found SMV data\n");
332  vst = avformat_new_stream(s, NULL);
333  if (!vst)
334  return AVERROR(ENOMEM);
335  avio_r8(pb);
336  vst->id = 1;
339  vst->codec->width = avio_rl24(pb);
340  vst->codec->height = avio_rl24(pb);
341  size = avio_rl24(pb);
342  wav->smv_data_ofs = avio_tell(pb) + (size - 5) * 3;
343  avio_rl24(pb);
344  wav->smv_block_size = avio_rl24(pb);
345  avpriv_set_pts_info(vst, 32, 1, avio_rl24(pb));
346  vst->duration = avio_rl24(pb);
347  avio_rl24(pb);
348  avio_rl24(pb);
349  wav->smv_frames_per_jpeg = avio_rl24(pb);
350  goto break_loop;
351  case MKTAG('L', 'I', 'S', 'T'):
352  if (size < 4) {
353  av_log(s, AV_LOG_ERROR, "too short LIST tag\n");
354  return AVERROR_INVALIDDATA;
355  }
356  switch (avio_rl32(pb)) {
357  case MKTAG('I', 'N', 'F', 'O'):
358  ff_read_riff_info(s, size - 4);
359  }
360  break;
361  }
362 
363  /* seek to next tag unless we know that we'll run into EOF */
364  if ((avio_size(pb) > 0 && next_tag_ofs >= avio_size(pb)) ||
365  wav_seek_tag(pb, next_tag_ofs, SEEK_SET) < 0) {
366  break;
367  }
368  }
369 break_loop:
370  if (data_ofs < 0) {
371  av_log(s, AV_LOG_ERROR, "no 'data' tag found\n");
372  return AVERROR_INVALIDDATA;
373  }
374 
375  avio_seek(pb, data_ofs, SEEK_SET);
376 
377  if (!sample_count && st->codec->channels && av_get_bits_per_sample(st->codec->codec_id) && wav->data_end <= avio_size(pb))
378  sample_count = (data_size<<3) / (st->codec->channels * (uint64_t)av_get_bits_per_sample(st->codec->codec_id));
379  if (sample_count)
380  st->duration = sample_count;
381 
382  ff_metadata_conv_ctx(s, NULL, wav_metadata_conv);
384 
385  return 0;
386 }
387 
388 /** Find chunk with w64 GUID by skipping over other chunks
389  * @return the size of the found chunk
390  */
391 static int64_t find_guid(AVIOContext *pb, const uint8_t guid1[16])
392 {
393  uint8_t guid[16];
394  int64_t size;
395 
396  while (!url_feof(pb)) {
397  avio_read(pb, guid, 16);
398  size = avio_rl64(pb);
399  if (size <= 24)
400  return -1;
401  if (!memcmp(guid, guid1, 16))
402  return size;
403  avio_skip(pb, FFALIGN(size, INT64_C(8)) - 24);
404  }
405  return -1;
406 }
407 
408 #define MAX_SIZE 4096
409 
410 static int wav_read_packet(AVFormatContext *s,
411  AVPacket *pkt)
412 {
413  int ret, size;
414  int64_t left;
415  AVStream *st;
416  WAVDemuxContext *wav = s->priv_data;
417 
418  if (CONFIG_SPDIF_DEMUXER && wav->spdif == 0 &&
419  s->streams[0]->codec->codec_tag == 1) {
420  enum AVCodecID codec;
421  ret = ff_spdif_probe(s->pb->buffer, s->pb->buf_end - s->pb->buffer,
422  &codec);
423  if (ret > AVPROBE_SCORE_MAX / 2) {
424  s->streams[0]->codec->codec_id = codec;
425  wav->spdif = 1;
426  } else {
427  wav->spdif = -1;
428  }
429  }
430  if (CONFIG_SPDIF_DEMUXER && wav->spdif == 1)
431  return ff_spdif_read_packet(s, pkt);
432 
433  if (wav->smv_data_ofs > 0) {
434  int64_t audio_dts, video_dts;
435 smv_retry:
436  audio_dts = s->streams[0]->cur_dts;
437  video_dts = s->streams[1]->cur_dts;
438  if (audio_dts != AV_NOPTS_VALUE && video_dts != AV_NOPTS_VALUE) {
439  audio_dts = av_rescale_q(audio_dts, s->streams[0]->time_base, AV_TIME_BASE_Q);
440  video_dts = av_rescale_q(video_dts, s->streams[1]->time_base, AV_TIME_BASE_Q);
441  wav->smv_last_stream = video_dts >= audio_dts;
442  }
443  wav->smv_last_stream = !wav->smv_last_stream;
444  wav->smv_last_stream |= wav->audio_eof;
445  wav->smv_last_stream &= !wav->smv_eof;
446  if (wav->smv_last_stream) {
447  uint64_t old_pos = avio_tell(s->pb);
448  uint64_t new_pos = wav->smv_data_ofs +
449  wav->smv_block * wav->smv_block_size;
450  if (avio_seek(s->pb, new_pos, SEEK_SET) < 0) {
451  ret = AVERROR_EOF;
452  goto smv_out;
453  }
454  size = avio_rl24(s->pb);
455  ret = av_get_packet(s->pb, pkt, size);
456  if (ret < 0)
457  goto smv_out;
458  pkt->pos -= 3;
459  pkt->pts = wav->smv_block * wav->smv_frames_per_jpeg;
460  wav->smv_block++;
461  pkt->stream_index = 1;
462 smv_out:
463  avio_seek(s->pb, old_pos, SEEK_SET);
464  if (ret == AVERROR_EOF) {
465  wav->smv_eof = 1;
466  goto smv_retry;
467  }
468  return ret;
469  }
470  }
471 
472  st = s->streams[0];
473 
474  left = wav->data_end - avio_tell(s->pb);
475  if (wav->ignore_length)
476  left= INT_MAX;
477  if (left <= 0){
478  if (CONFIG_W64_DEMUXER && wav->w64)
479  left = find_guid(s->pb, ff_w64_guid_data) - 24;
480  else
481  left = find_tag(s->pb, MKTAG('d', 'a', 't', 'a'));
482  if (left < 0) {
483  wav->audio_eof = 1;
484  if (wav->smv_data_ofs > 0 && !wav->smv_eof)
485  goto smv_retry;
486  return AVERROR_EOF;
487  }
488  wav->data_end= avio_tell(s->pb) + left;
489  }
490 
491  size = MAX_SIZE;
492  if (st->codec->block_align > 1) {
493  if (size < st->codec->block_align)
494  size = st->codec->block_align;
495  size = (size / st->codec->block_align) * st->codec->block_align;
496  }
497  size = FFMIN(size, left);
498  ret = av_get_packet(s->pb, pkt, size);
499  if (ret < 0)
500  return ret;
501  pkt->stream_index = 0;
502 
503  return ret;
504 }
505 
506 static int wav_read_seek(AVFormatContext *s,
507  int stream_index, int64_t timestamp, int flags)
508 {
509  WAVDemuxContext *wav = s->priv_data;
510  AVStream *st;
511  wav->smv_eof = 0;
512  wav->audio_eof = 0;
513  if (wav->smv_data_ofs > 0) {
514  int64_t smv_timestamp = timestamp;
515  if (stream_index == 0)
516  smv_timestamp = av_rescale_q(timestamp, s->streams[0]->time_base, s->streams[1]->time_base);
517  else
518  timestamp = av_rescale_q(smv_timestamp, s->streams[1]->time_base, s->streams[0]->time_base);
519  wav->smv_block = smv_timestamp / wav->smv_frames_per_jpeg;
520  }
521 
522  st = s->streams[0];
523  switch (st->codec->codec_id) {
524  case AV_CODEC_ID_MP2:
525  case AV_CODEC_ID_MP3:
526  case AV_CODEC_ID_AC3:
527  case AV_CODEC_ID_DTS:
528  /* use generic seeking with dynamically generated indexes */
529  return -1;
530  default:
531  break;
532  }
533  return ff_pcm_read_seek(s, stream_index, timestamp, flags);
534 }
535 
536 #define OFFSET(x) offsetof(WAVDemuxContext, x)
537 #define DEC AV_OPT_FLAG_DECODING_PARAM
538 static const AVOption demux_options[] = {
539  { "ignore_length", "Ignore length", OFFSET(ignore_length), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, DEC },
540  { NULL },
541 };
542 
543 static const AVClass wav_demuxer_class = {
544  .class_name = "WAV demuxer",
545  .item_name = av_default_item_name,
546  .option = demux_options,
547  .version = LIBAVUTIL_VERSION_INT,
548 };
549 AVInputFormat ff_wav_demuxer = {
550  .name = "wav",
551  .long_name = NULL_IF_CONFIG_SMALL("WAV / WAVE (Waveform Audio)"),
552  .priv_data_size = sizeof(WAVDemuxContext),
553  .read_probe = wav_probe,
554  .read_header = wav_read_header,
555  .read_packet = wav_read_packet,
556  .read_seek = wav_read_seek,
557  .flags = AVFMT_GENERIC_INDEX,
558  .codec_tag = (const AVCodecTag* const []){ ff_codec_wav_tags, 0 },
559  .priv_class = &wav_demuxer_class,
560 };
561 #endif /* CONFIG_WAV_DEMUXER */
562 
563 
564 #if CONFIG_W64_DEMUXER
565 static int w64_probe(AVProbeData *p)
566 {
567  if (p->buf_size <= 40)
568  return 0;
569  if (!memcmp(p->buf, ff_w64_guid_riff, 16) &&
570  !memcmp(p->buf + 24, ff_w64_guid_wave, 16))
571  return AVPROBE_SCORE_MAX;
572  else
573  return 0;
574 }
575 
576 static int w64_read_header(AVFormatContext *s)
577 {
578  int64_t size, data_ofs = 0;
579  AVIOContext *pb = s->pb;
580  WAVDemuxContext *wav = s->priv_data;
581  AVStream *st;
582  uint8_t guid[16];
583  int ret;
584 
585  avio_read(pb, guid, 16);
586  if (memcmp(guid, ff_w64_guid_riff, 16))
587  return -1;
588 
589  if (avio_rl64(pb) < 16 + 8 + 16 + 8 + 16 + 8) /* riff + wave + fmt + sizes */
590  return -1;
591 
592  avio_read(pb, guid, 16);
593  if (memcmp(guid, ff_w64_guid_wave, 16)) {
594  av_log(s, AV_LOG_ERROR, "could not find wave guid\n");
595  return -1;
596  }
597 
598  wav->w64 = 1;
599 
600  st = avformat_new_stream(s, NULL);
601  if (!st)
602  return AVERROR(ENOMEM);
603 
604  while (!url_feof(pb)) {
605  if (avio_read(pb, guid, 16) != 16)
606  break;
607  size = avio_rl64(pb);
608  if (size <= 24 || INT64_MAX - size < avio_tell(pb))
609  return AVERROR_INVALIDDATA;
610 
611  if (!memcmp(guid, ff_w64_guid_fmt, 16)) {
612  /* subtract chunk header size - normal wav file doesn't count it */
613  ret = ff_get_wav_header(pb, st->codec, size - 24);
614  if (ret < 0)
615  return ret;
616  avio_skip(pb, FFALIGN(size, INT64_C(8)) - size);
617 
618  avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
619  } else if (!memcmp(guid, ff_w64_guid_data, 16)) {
620  wav->data_end = avio_tell(pb) + size - 24;
621 
622  data_ofs = avio_tell(pb);
623  if (!pb->seekable)
624  break;
625 
626  avio_skip(pb, size - 24);
627  } else if (!memcmp(guid, ff_w64_guid_summarylist, 16)) {
628  int64_t start, end, cur;
629  uint32_t count, chunk_size, i;
630 
631  start = avio_tell(pb);
632  end = start + size;
633  count = avio_rl32(pb);
634 
635  for (i = 0; i < count; i++) {
636  char chunk_key[5], *value;
637 
638  if (url_feof(pb) || (cur = avio_tell(pb)) < 0 || cur > end - 8 /* = tag + size */)
639  break;
640 
641  chunk_key[4] = 0;
642  avio_read(pb, chunk_key, 4);
643  chunk_size = avio_rl32(pb);
644 
645  value = av_mallocz(chunk_size + 1);
646  if (!value)
647  return AVERROR(ENOMEM);
648 
649  ret = avio_get_str16le(pb, chunk_size, value, chunk_size);
650  avio_skip(pb, chunk_size - ret);
651 
652  av_dict_set(&s->metadata, chunk_key, value, AV_DICT_DONT_STRDUP_VAL);
653  }
654 
655  avio_skip(pb, end - avio_tell(pb));
656  } else {
657  av_log(s, AV_LOG_DEBUG, "unknown guid: "FF_PRI_GUID"\n", FF_ARG_GUID(guid));
658  avio_skip(pb, size - 24);
659  }
660  }
661 
662  if (!data_ofs)
663  return AVERROR_EOF;
664 
665  ff_metadata_conv_ctx(s, NULL, wav_metadata_conv);
667 
668  handle_stream_probing(st);
670 
671  avio_seek(pb, data_ofs, SEEK_SET);
672 
673  return 0;
674 }
675 
676 AVInputFormat ff_w64_demuxer = {
677  .name = "w64",
678  .long_name = NULL_IF_CONFIG_SMALL("Sony Wave64"),
679  .priv_data_size = sizeof(WAVDemuxContext),
680  .read_probe = w64_probe,
681  .read_header = w64_read_header,
682  .read_packet = wav_read_packet,
683  .read_seek = wav_read_seek,
684  .flags = AVFMT_GENERIC_INDEX,
685  .codec_tag = (const AVCodecTag* const []){ ff_codec_wav_tags, 0 },
686 };
687 #endif /* CONFIG_W64_DEMUXER */