]> git.sesse.net Git - ffmpeg/commitdiff
qdm2: make sure channels is not <= 0 and set channel layout
authorJustin Ruggles <justin.ruggles@gmail.com>
Mon, 22 Oct 2012 22:53:19 +0000 (18:53 -0400)
committerJustin Ruggles <justin.ruggles@gmail.com>
Thu, 1 Nov 2012 15:29:18 +0000 (11:29 -0400)
libavcodec/qdm2.c

index 4d3b3915fbd2a3157d0b86b7515a14cd02492980..8e93886f1c7651e28ada1cea72da061c9ba698de 100644 (file)
@@ -36,6 +36,7 @@
 #include <stdio.h>
 
 #define BITSTREAM_READER_LE
+#include "libavutil/audioconvert.h"
 #include "avcodec.h"
 #include "get_bits.h"
 #include "dsputil.h"
@@ -1768,8 +1769,10 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx)
 
     avctx->channels = s->nb_channels = s->channels = AV_RB32(extradata);
     extradata += 4;
-    if (s->channels > MPA_MAX_CHANNELS)
+    if (s->channels <= 0 || s->channels > MPA_MAX_CHANNELS)
         return AVERROR_INVALIDDATA;
+    avctx->channel_layout = avctx->channels == 2 ? AV_CH_LAYOUT_STEREO :
+                                                   AV_CH_LAYOUT_MONO;
 
     avctx->sample_rate = AV_RB32(extradata);
     extradata += 4;