]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/wv.c
pcmdec: change default of channels parameter to 1
[ffmpeg] / libavformat / wv.c
index 3fd1abcb87d80b74a1cf7fd3a4f324aa2871ae39..a2ae5a4dba7cc5c7f274c8d5eb0a167861844c90 100644 (file)
@@ -64,6 +64,8 @@ typedef struct {
     int block_parsed;
     uint8_t extra[WV_EXTRA_SIZE];
     int64_t pos;
+
+    int64_t apetag_start;
 } WVContext;
 
 static int wv_probe(AVProbeData *p)
@@ -88,6 +90,11 @@ static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb,
     uint32_t chmask;
 
     wc->pos = avio_tell(pb);
+
+    /* don't return bogus packets with the ape tag data */
+    if (wc->apetag_start && wc->pos >= wc->apetag_start)
+        return AVERROR_EOF;
+
     if (!append) {
         tag = avio_rl32(pb);
         if (tag != MKTAG('w', 'v', 'p', 'k'))
@@ -241,7 +248,7 @@ static int wv_read_header(AVFormatContext *s)
     if (!st)
         return AVERROR(ENOMEM);
     st->codec->codec_type            = AVMEDIA_TYPE_AUDIO;
-    st->codec->codec_id              = CODEC_ID_WAVPACK;
+    st->codec->codec_id              = AV_CODEC_ID_WAVPACK;
     st->codec->channels              = wc->chan;
     st->codec->channel_layout        = wc->chmask;
     st->codec->sample_rate           = wc->rate;
@@ -252,7 +259,7 @@ static int wv_read_header(AVFormatContext *s)
 
     if (s->pb->seekable) {
         int64_t cur = avio_tell(s->pb);
-        ff_ape_parse_tag(s);
+        wc->apetag_start = ff_ape_parse_tag(s);
         if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
             ff_id3v1_read(s);
         avio_seek(s->pb, cur, SEEK_SET);