OSDN Git Service

Merge remote-tracking branch 'qatar/master'
[coroid/ffmpeg_saccubus.git] / libavformat / wav.c
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 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 "avio_internal.h"
33 #include "pcm.h"
34 #include "riff.h"
35 #include "avio.h"
36 #include "avio_internal.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;
45     int last_duration;
46     int w64;
47     int write_bext;
48 } WAVContext;
49
50 #if CONFIG_WAV_MUXER
51 static inline void bwf_write_bext_string(AVFormatContext *s, const char *key, int maxlen)
52 {
53     AVDictionaryEntry *tag;
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     av_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), FF_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, unsigned int *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 (url_feof(pb))
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 = av_new_stream(s, 0);
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     av_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,
366                                AV_DICT_DONT_STRDUP_VAL)) < 0)
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     unsigned int tag;
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 < 24)
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 - 24); /* skip rest of ds64 chunk */
422
423     }
424
425     for (;;) {
426         size = next_tag(pb, &tag);
427         next_tag_ofs = avio_tell(pb) + size;
428
429         if (url_feof(pb))
430             break;
431
432         switch (tag) {
433         case MKTAG('f', 'm', 't', ' '):
434             /* only parse the first 'fmt ' tag found */
435             if (!got_fmt && (ret = wav_parse_fmt_tag(s, size, &st) < 0)) {
436                 return ret;
437             } else if (got_fmt)
438                 av_log(s, AV_LOG_WARNING, "found more than one 'fmt ' tag\n");
439
440             got_fmt = 1;
441             break;
442         case MKTAG('d', 'a', 't', 'a'):
443             if (!got_fmt) {
444                 av_log(s, AV_LOG_ERROR, "found no 'fmt ' tag before the 'data' tag\n");
445                 return AVERROR_INVALIDDATA;
446             }
447
448             if (rf64) {
449                 next_tag_ofs = wav->data_end = avio_tell(pb) + data_size;
450             } else {
451                 data_size = size;
452                 next_tag_ofs = wav->data_end = size ? next_tag_ofs : INT64_MAX;
453             }
454
455             data_ofs = avio_tell(pb);
456
457             /* don't look for footer metadata if we can't seek or if we don't
458              * know where the data tag ends
459              */
460             if (!pb->seekable || (!rf64 && !size))
461                 goto break_loop;
462             break;
463         case MKTAG('f','a','c','t'):
464             if (!sample_count)
465                 sample_count = avio_rl32(pb);
466             break;
467         case MKTAG('b','e','x','t'):
468             if ((ret = wav_parse_bext_tag(s, size)) < 0)
469                 return ret;
470             break;
471         }
472
473         /* seek to next tag unless we know that we'll run into EOF */
474         if ((avio_size(pb) > 0 && next_tag_ofs >= avio_size(pb)) ||
475             avio_seek(pb, next_tag_ofs, SEEK_SET) < 0) {
476             break;
477         }
478     }
479 break_loop:
480     if (data_ofs < 0) {
481         av_log(s, AV_LOG_ERROR, "no 'data' tag found\n");
482         return AVERROR_INVALIDDATA;
483     }
484
485     avio_seek(pb, data_ofs, SEEK_SET);
486
487     if (!sample_count && st->codec->channels && av_get_bits_per_sample(st->codec->codec_id))
488         sample_count = (data_size<<3) / (st->codec->channels * (uint64_t)av_get_bits_per_sample(st->codec->codec_id));
489     if (sample_count)
490         st->duration = sample_count;
491
492     ff_metadata_conv_ctx(s, NULL, wav_metadata_conv);
493
494     return 0;
495 }
496
497 /** Find chunk with w64 GUID by skipping over other chunks
498  * @return the size of the found chunk
499  */
500 static int64_t find_guid(AVIOContext *pb, const uint8_t guid1[16])
501 {
502     uint8_t guid[16];
503     int64_t size;
504
505     while (!url_feof(pb)) {
506         avio_read(pb, guid, 16);
507         size = avio_rl64(pb);
508         if (size <= 24)
509             return -1;
510         if (!memcmp(guid, guid1, 16))
511             return size;
512         avio_skip(pb, FFALIGN(size, INT64_C(8)) - 24);
513     }
514     return -1;
515 }
516
517 static const uint8_t guid_data[16] = { 'd', 'a', 't', 'a',
518     0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A };
519
520 #define MAX_SIZE 4096
521
522 static int wav_read_packet(AVFormatContext *s,
523                            AVPacket *pkt)
524 {
525     int ret, size;
526     int64_t left;
527     AVStream *st;
528     WAVContext *wav = s->priv_data;
529
530     st = s->streams[0];
531
532     left = wav->data_end - avio_tell(s->pb);
533     if (left <= 0){
534         if (CONFIG_W64_DEMUXER && wav->w64)
535             left = find_guid(s->pb, guid_data) - 24;
536         else
537             left = find_tag(s->pb, MKTAG('d', 'a', 't', 'a'));
538         if (left < 0)
539             return AVERROR_EOF;
540         wav->data_end= avio_tell(s->pb) + left;
541     }
542
543     size = MAX_SIZE;
544     if (st->codec->block_align > 1) {
545         if (size < st->codec->block_align)
546             size = st->codec->block_align;
547         size = (size / st->codec->block_align) * st->codec->block_align;
548     }
549     size = FFMIN(size, left);
550     ret  = av_get_packet(s->pb, pkt, size);
551     if (ret < 0)
552         return ret;
553     pkt->stream_index = 0;
554
555     return ret;
556 }
557
558 static int wav_read_seek(AVFormatContext *s,
559                          int stream_index, int64_t timestamp, int flags)
560 {
561     AVStream *st;
562
563     st = s->streams[0];
564     switch (st->codec->codec_id) {
565     case CODEC_ID_MP2:
566     case CODEC_ID_MP3:
567     case CODEC_ID_AC3:
568     case CODEC_ID_DTS:
569         /* use generic seeking with dynamically generated indexes */
570         return -1;
571     default:
572         break;
573     }
574     return pcm_read_seek(s, stream_index, timestamp, flags);
575 }
576
577 AVInputFormat ff_wav_demuxer = {
578     .name           = "wav",
579     .long_name      = NULL_IF_CONFIG_SMALL("WAV format"),
580     .priv_data_size = sizeof(WAVContext),
581     .read_probe     = wav_probe,
582     .read_header    = wav_read_header,
583     .read_packet    = wav_read_packet,
584     .read_seek      = wav_read_seek,
585     .flags= AVFMT_GENERIC_INDEX,
586     .codec_tag= (const AVCodecTag* const []){ff_codec_wav_tags, 0},
587 };
588 #endif /* CONFIG_WAV_DEMUXER */
589
590
591 #if CONFIG_W64_DEMUXER
592 static const uint8_t guid_riff[16] = { 'r', 'i', 'f', 'f',
593     0x2E, 0x91, 0xCF, 0x11, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00 };
594
595 static const uint8_t guid_wave[16] = { 'w', 'a', 'v', 'e',
596     0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A };
597
598 static const uint8_t guid_fmt [16] = { 'f', 'm', 't', ' ',
599     0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A };
600
601 static int w64_probe(AVProbeData *p)
602 {
603     if (p->buf_size <= 40)
604         return 0;
605     if (!memcmp(p->buf,      guid_riff, 16) &&
606         !memcmp(p->buf + 24, guid_wave, 16))
607         return AVPROBE_SCORE_MAX;
608     else
609         return 0;
610 }
611
612 static int w64_read_header(AVFormatContext *s, AVFormatParameters *ap)
613 {
614     int64_t size;
615     AVIOContext *pb  = s->pb;
616     WAVContext    *wav = s->priv_data;
617     AVStream *st;
618     uint8_t guid[16];
619     int ret;
620
621     avio_read(pb, guid, 16);
622     if (memcmp(guid, guid_riff, 16))
623         return -1;
624
625     if (avio_rl64(pb) < 16 + 8 + 16 + 8 + 16 + 8) /* riff + wave + fmt + sizes */
626         return -1;
627
628     avio_read(pb, guid, 16);
629     if (memcmp(guid, guid_wave, 16)) {
630         av_log(s, AV_LOG_ERROR, "could not find wave guid\n");
631         return -1;
632     }
633
634     size = find_guid(pb, guid_fmt);
635     if (size < 0) {
636         av_log(s, AV_LOG_ERROR, "could not find fmt guid\n");
637         return -1;
638     }
639
640     st = av_new_stream(s, 0);
641     if (!st)
642         return AVERROR(ENOMEM);
643
644     /* subtract chunk header size - normal wav file doesn't count it */
645     ret = ff_get_wav_header(pb, st->codec, size - 24);
646     if (ret < 0)
647         return ret;
648     avio_skip(pb, FFALIGN(size, INT64_C(8)) - size);
649
650     st->need_parsing = AVSTREAM_PARSE_FULL;
651
652     av_set_pts_info(st, 64, 1, st->codec->sample_rate);
653
654     size = find_guid(pb, guid_data);
655     if (size < 0) {
656         av_log(s, AV_LOG_ERROR, "could not find data guid\n");
657         return -1;
658     }
659     wav->data_end = avio_tell(pb) + size - 24;
660     wav->w64      = 1;
661
662     return 0;
663 }
664
665 AVInputFormat ff_w64_demuxer = {
666     .name           = "w64",
667     .long_name      = NULL_IF_CONFIG_SMALL("Sony Wave64 format"),
668     .priv_data_size = sizeof(WAVContext),
669     .read_probe     = w64_probe,
670     .read_header    = w64_read_header,
671     .read_packet    = wav_read_packet,
672     .read_seek      = wav_read_seek,
673     .flags = AVFMT_GENERIC_INDEX,
674     .codec_tag = (const AVCodecTag* const []){ff_codec_wav_tags, 0},
675 };
676 #endif /* CONFIG_W64_DEMUXER */