]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/wav.c
lavf: use conditional notation for default codec in muxer declarations.
[ffmpeg] / libavformat / wav.c
index d80945157cfe76db5ec255992b05a8bf55bc740e..c01121f9dbd9d3a01dedd15d6126cf71b85facfb 100644 (file)
 #include "libavutil/mathematics.h"
 #include "libavutil/opt.h"
 #include "avformat.h"
+#include "internal.h"
 #include "avio_internal.h"
 #include "pcm.h"
 #include "riff.h"
 #include "avio.h"
-#include "avio_internal.h"
 #include "metadata.h"
 
 typedef struct {
@@ -131,7 +131,7 @@ static int wav_write_header(AVFormatContext *s)
     if (wav->write_bext)
         bwf_write_bext_chunk(s);
 
-    av_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate);
+    avpriv_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate);
     wav->maxpts = wav->last_duration = 0;
     wav->minpts = INT64_MAX;
 
@@ -216,15 +216,16 @@ AVOutputFormat ff_wav_muxer = {
     .write_header      = wav_write_header,
     .write_packet      = wav_write_packet,
     .write_trailer     = wav_write_trailer,
-    .codec_tag= (const AVCodecTag* const []){ff_codec_wav_tags, 0},
-    .priv_class = &wav_muxer_class,
+    .flags             = AVFMT_TS_NONSTRICT,
+    .codec_tag         = (const AVCodecTag* const []){ ff_codec_wav_tags, 0 },
+    .priv_class        = &wav_muxer_class,
 };
 #endif /* CONFIG_WAV_MUXER */
 
 
 #if CONFIG_WAV_DEMUXER
 
-static int64_t next_tag(AVIOContext *pb, unsigned int *tag)
+static int64_t next_tag(AVIOContext *pb, uint32_t *tag)
 {
     *tag = avio_rl32(pb);
     return avio_rl32(pb);
@@ -273,7 +274,7 @@ static int wav_parse_fmt_tag(AVFormatContext *s, int64_t size, AVStream **st)
     int ret;
 
     /* parse fmt header */
-    *st = av_new_stream(s, 0);
+    *st = avformat_new_stream(s, NULL);
     if (!*st)
         return AVERROR(ENOMEM);
 
@@ -282,7 +283,7 @@ static int wav_parse_fmt_tag(AVFormatContext *s, int64_t size, AVStream **st)
         return ret;
     (*st)->need_parsing = AVSTREAM_PARSE_FULL;
 
-    av_set_pts_info(*st, 64, 1, (*st)->codec->sample_rate);
+    avpriv_set_pts_info(*st, 64, 1, (*st)->codec->sample_rate);
 
     return 0;
 }
@@ -379,13 +380,12 @@ static const AVMetadataConv wav_metadata_conv[] = {
 };
 
 /* wav input */
-static int wav_read_header(AVFormatContext *s,
-                           AVFormatParameters *ap)
+static int wav_read_header(AVFormatContext *s)
 {
     int64_t size, av_uninit(data_size);
     int64_t sample_count=0;
     int rf64;
-    unsigned int tag;
+    uint32_t tag, list_type;
     AVIOContext *pb = s->pb;
     AVStream *st;
     WAVContext *wav = s->priv_data;
@@ -467,6 +467,18 @@ static int wav_read_header(AVFormatContext *s,
             if ((ret = wav_parse_bext_tag(s, size)) < 0)
                 return ret;
             break;
+        case MKTAG('L', 'I', 'S', 'T'):
+            list_type = avio_rl32(pb);
+            if (size <= 4) {
+                av_log(s, AV_LOG_ERROR, "too short LIST");
+                return AVERROR_INVALIDDATA;
+            }
+            switch (list_type) {
+            case MKTAG('I', 'N', 'F', 'O'):
+                if ((ret = ff_read_riff_info(s, size - 4)) < 0)
+                    return ret;
+            }
+            break;
         }
 
         /* seek to next tag unless we know that we'll run into EOF */
@@ -489,6 +501,7 @@ break_loop:
         st->duration = sample_count;
 
     ff_metadata_conv_ctx(s, NULL, wav_metadata_conv);
+    ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv);
 
     return 0;
 }
@@ -570,7 +583,7 @@ static int wav_read_seek(AVFormatContext *s,
     default:
         break;
     }
-    return pcm_read_seek(s, stream_index, timestamp, flags);
+    return ff_pcm_read_seek(s, stream_index, timestamp, flags);
 }
 
 AVInputFormat ff_wav_demuxer = {
@@ -581,8 +594,8 @@ AVInputFormat ff_wav_demuxer = {
     .read_header    = wav_read_header,
     .read_packet    = wav_read_packet,
     .read_seek      = wav_read_seek,
-    .flags= AVFMT_GENERIC_INDEX,
-    .codec_tag= (const AVCodecTag* const []){ff_codec_wav_tags, 0},
+    .flags          = AVFMT_GENERIC_INDEX,
+    .codec_tag      = (const AVCodecTag* const []){ ff_codec_wav_tags, 0 },
 };
 #endif /* CONFIG_WAV_DEMUXER */
 
@@ -608,7 +621,7 @@ static int w64_probe(AVProbeData *p)
         return 0;
 }
 
-static int w64_read_header(AVFormatContext *s, AVFormatParameters *ap)
+static int w64_read_header(AVFormatContext *s)
 {
     int64_t size;
     AVIOContext *pb  = s->pb;
@@ -636,7 +649,7 @@ static int w64_read_header(AVFormatContext *s, AVFormatParameters *ap)
         return -1;
     }
 
-    st = av_new_stream(s, 0);
+    st = avformat_new_stream(s, NULL);
     if (!st)
         return AVERROR(ENOMEM);
 
@@ -648,7 +661,7 @@ static int w64_read_header(AVFormatContext *s, AVFormatParameters *ap)
 
     st->need_parsing = AVSTREAM_PARSE_FULL;
 
-    av_set_pts_info(st, 64, 1, st->codec->sample_rate);
+    avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
 
     size = find_guid(pb, guid_data);
     if (size < 0) {
@@ -669,7 +682,7 @@ AVInputFormat ff_w64_demuxer = {
     .read_header    = w64_read_header,
     .read_packet    = wav_read_packet,
     .read_seek      = wav_read_seek,
-    .flags = AVFMT_GENERIC_INDEX,
-    .codec_tag = (const AVCodecTag* const []){ff_codec_wav_tags, 0},
+    .flags          = AVFMT_GENERIC_INDEX,
+    .codec_tag      = (const AVCodecTag* const []){ ff_codec_wav_tags, 0 },
 };
 #endif /* CONFIG_W64_DEMUXER */