OSDN Git Service

ffv1: Fixed size given to init_get_bits() in decoder.
[coroid/libav_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 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 "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 (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 = 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 < 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         }
471
472         /* seek to next tag unless we know that we'll run into EOF */
473         if ((avio_size(pb) > 0 && next_tag_ofs >= avio_size(pb)) ||
474             avio_seek(pb, next_tag_ofs, SEEK_SET) < 0) {
475             break;
476         }
477     }
478 break_loop:
479     if (data_ofs < 0) {
480         av_log(s, AV_LOG_ERROR, "no 'data' tag found\n");
481         return AVERROR_INVALIDDATA;
482     }
483
484     avio_seek(pb, data_ofs, SEEK_SET);
485
486     if (!sample_count && st->codec->channels && av_get_bits_per_sample(st->codec->codec_id))
487         sample_count = (data_size<<3) / (st->codec->channels * (uint64_t)av_get_bits_per_sample(st->codec->codec_id));
488     if (sample_count)
489         st->duration = sample_count;
490
491     ff_metadata_conv_ctx(s, NULL, wav_metadata_conv);
492
493     return 0;
494 }
495
496 /** Find chunk with w64 GUID by skipping over other chunks
497  * @return the size of the found chunk
498  */
499 static int64_t find_guid(AVIOContext *pb, const uint8_t guid1[16])
500 {
501     uint8_t guid[16];
502     int64_t size;
503
504     while (!pb->eof_reached) {
505         avio_read(pb, guid, 16);
506         size = avio_rl64(pb);
507         if (size <= 24)
508             return -1;
509         if (!memcmp(guid, guid1, 16))
510             return size;
511         avio_skip(pb, FFALIGN(size, INT64_C(8)) - 24);
512     }
513     return -1;
514 }
515
516 static const uint8_t guid_data[16] = { 'd', 'a', 't', 'a',
517     0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A };
518
519 #define MAX_SIZE 4096
520
521 static int wav_read_packet(AVFormatContext *s,
522                            AVPacket *pkt)
523 {
524     int ret, size;
525     int64_t left;
526     AVStream *st;
527     WAVContext *wav = s->priv_data;
528
529     st = s->streams[0];
530
531     left = wav->data_end - avio_tell(s->pb);
532     if (left <= 0){
533         if (CONFIG_W64_DEMUXER && wav->w64)
534             left = find_guid(s->pb, guid_data) - 24;
535         else
536             left = find_tag(s->pb, MKTAG('d', 'a', 't', 'a'));
537         if (left < 0)
538             return AVERROR_EOF;
539         wav->data_end= avio_tell(s->pb) + left;
540     }
541
542     size = MAX_SIZE;
543     if (st->codec->block_align > 1) {
544         if (size < st->codec->block_align)
545             size = st->codec->block_align;
546         size = (size / st->codec->block_align) * st->codec->block_align;
547     }
548     size = FFMIN(size, left);
549     ret  = av_get_packet(s->pb, pkt, size);
550     if (ret < 0)
551         return ret;
552     pkt->stream_index = 0;
553
554     return ret;
555 }
556
557 static int wav_read_seek(AVFormatContext *s,
558                          int stream_index, int64_t timestamp, int flags)
559 {
560     AVStream *st;
561
562     st = s->streams[0];
563     switch (st->codec->codec_id) {
564     case CODEC_ID_MP2:
565     case CODEC_ID_MP3:
566     case CODEC_ID_AC3:
567     case CODEC_ID_DTS:
568         /* use generic seeking with dynamically generated indexes */
569         return -1;
570     default:
571         break;
572     }
573     return pcm_read_seek(s, stream_index, timestamp, flags);
574 }
575
576 AVInputFormat ff_wav_demuxer = {
577     .name           = "wav",
578     .long_name      = NULL_IF_CONFIG_SMALL("WAV format"),
579     .priv_data_size = sizeof(WAVContext),
580     .read_probe     = wav_probe,
581     .read_header    = wav_read_header,
582     .read_packet    = wav_read_packet,
583     .read_seek      = wav_read_seek,
584     .flags= AVFMT_GENERIC_INDEX,
585     .codec_tag= (const AVCodecTag* const []){ff_codec_wav_tags, 0},
586 };
587 #endif /* CONFIG_WAV_DEMUXER */
588
589
590 #if CONFIG_W64_DEMUXER
591 static const uint8_t guid_riff[16] = { 'r', 'i', 'f', 'f',
592     0x2E, 0x91, 0xCF, 0x11, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00 };
593
594 static const uint8_t guid_wave[16] = { 'w', 'a', 'v', 'e',
595     0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A };
596
597 static const uint8_t guid_fmt [16] = { 'f', 'm', 't', ' ',
598     0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A };
599
600 static int w64_probe(AVProbeData *p)
601 {
602     if (p->buf_size <= 40)
603         return 0;
604     if (!memcmp(p->buf,      guid_riff, 16) &&
605         !memcmp(p->buf + 24, guid_wave, 16))
606         return AVPROBE_SCORE_MAX;
607     else
608         return 0;
609 }
610
611 static int w64_read_header(AVFormatContext *s, AVFormatParameters *ap)
612 {
613     int64_t size;
614     AVIOContext *pb  = s->pb;
615     WAVContext    *wav = s->priv_data;
616     AVStream *st;
617     uint8_t guid[16];
618     int ret;
619
620     avio_read(pb, guid, 16);
621     if (memcmp(guid, guid_riff, 16))
622         return -1;
623
624     if (avio_rl64(pb) < 16 + 8 + 16 + 8 + 16 + 8) /* riff + wave + fmt + sizes */
625         return -1;
626
627     avio_read(pb, guid, 16);
628     if (memcmp(guid, guid_wave, 16)) {
629         av_log(s, AV_LOG_ERROR, "could not find wave guid\n");
630         return -1;
631     }
632
633     size = find_guid(pb, guid_fmt);
634     if (size < 0) {
635         av_log(s, AV_LOG_ERROR, "could not find fmt guid\n");
636         return -1;
637     }
638
639     st = av_new_stream(s, 0);
640     if (!st)
641         return AVERROR(ENOMEM);
642
643     /* subtract chunk header size - normal wav file doesn't count it */
644     ret = ff_get_wav_header(pb, st->codec, size - 24);
645     if (ret < 0)
646         return ret;
647     avio_skip(pb, FFALIGN(size, INT64_C(8)) - size);
648
649     st->need_parsing = AVSTREAM_PARSE_FULL;
650
651     av_set_pts_info(st, 64, 1, st->codec->sample_rate);
652
653     size = find_guid(pb, guid_data);
654     if (size < 0) {
655         av_log(s, AV_LOG_ERROR, "could not find data guid\n");
656         return -1;
657     }
658     wav->data_end = avio_tell(pb) + size - 24;
659     wav->w64      = 1;
660
661     return 0;
662 }
663
664 AVInputFormat ff_w64_demuxer = {
665     .name           = "w64",
666     .long_name      = NULL_IF_CONFIG_SMALL("Sony Wave64 format"),
667     .priv_data_size = sizeof(WAVContext),
668     .read_probe     = w64_probe,
669     .read_header    = w64_read_header,
670     .read_packet    = wav_read_packet,
671     .read_seek      = wav_read_seek,
672     .flags = AVFMT_GENERIC_INDEX,
673     .codec_tag = (const AVCodecTag* const []){ff_codec_wav_tags, 0},
674 };
675 #endif /* CONFIG_W64_DEMUXER */