adxdec: set avctx->channels in adx_read_header
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Thu, 26 Feb 2015 00:06:57 +0000 (01:06 +0100)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Sun, 8 Mar 2015 19:34:38 +0000 (19:34 +0000)
It is used in adx_read_packet, which currently depends on the
decoder/parser setting this value between reading the file header and
demuxing the first packet.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
libavformat/adxdec.c

index fc83ff2..9d3ebe3 100644 (file)
@@ -89,8 +89,14 @@ static int adx_read_header(AVFormatContext *s)
         av_log(s, AV_LOG_ERROR, "Invalid extradata size.\n");
         return AVERROR_INVALIDDATA;
     }
+    avctx->channels    = AV_RB8(avctx->extradata + 7);
     avctx->sample_rate = AV_RB32(avctx->extradata + 8);
 
+    if (avctx->channels <= 0) {
+        av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", avctx->channels);
+        return AVERROR_INVALIDDATA;
+    }
+
     st->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
     st->codec->codec_id    = s->iformat->raw_codec_id;