Revert "lavd: add new API for iterating input and output devices"
[ffmpeg.git] / libavformat / boadec.c
index 45f6b39..730e957 100644 (file)
@@ -20,7 +20,9 @@
  */
 
 #include "libavutil/intreadwrite.h"
+#include "libavcodec/internal.h"
 #include "avformat.h"
+#include "internal.h"
 
 static int probe(AVProbeData *p)
 {
@@ -45,18 +47,23 @@ static int read_header(AVFormatContext *s)
     if (!st)
         return AVERROR(ENOMEM);
 
-    st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-    st->codec->codec_id = AV_CODEC_ID_ADPCM_MS;
+    st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->codec_id = AV_CODEC_ID_ADPCM_MS;
 
     avio_rl32(s->pb);
     avio_rl32(s->pb);
-    st->codec->sample_rate = avio_rl32(s->pb);
-    st->codec->channels    = avio_rl32(s->pb);
-    s->data_offset         = avio_rl32(s->pb);
+    st->codecpar->sample_rate = avio_rl32(s->pb);
+    st->codecpar->channels    = avio_rl32(s->pb);
+    if (st->codecpar->channels > FF_SANE_NB_CHANNELS)
+        return AVERROR(ENOSYS);
+    s->internal->data_offset = avio_rl32(s->pb);
     avio_r8(s->pb);
-    st->codec->block_align = st->codec->channels * avio_rl32(s->pb);
+    st->codecpar->block_align = avio_rl32(s->pb);
+    if (st->codecpar->block_align > INT_MAX / FF_SANE_NB_CHANNELS)
+        return AVERROR_INVALIDDATA;
+    st->codecpar->block_align *= st->codecpar->channels;
 
-    avio_seek(s->pb, s->data_offset, SEEK_SET);
+    avio_seek(s->pb, s->internal->data_offset, SEEK_SET);
 
     return 0;
 }
@@ -65,7 +72,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
 {
     AVStream *st = s->streams[0];
 
-    return av_get_packet(s->pb, pkt, st->codec->block_align);
+    return av_get_packet(s->pb, pkt, st->codecpar->block_align);
 }
 
 AVInputFormat ff_boa_demuxer = {