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