[FFmpeg-cvslog] qdm2: make sure channels is not <= 0 and set channel layout

Justin Ruggles git at videolan.org
Fri Nov 2 14:32:41 CET 2012


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Mon Oct 22 18:53:19 2012 -0400| [be2ab8b75a634a686a5ced1544c0c9a4ebeab0dc] | committer: Justin Ruggles

qdm2: make sure channels is not <= 0 and set channel layout

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=be2ab8b75a634a686a5ced1544c0c9a4ebeab0dc
---

 libavcodec/qdm2.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
index 4d3b391..8e93886 100644
--- a/libavcodec/qdm2.c
+++ b/libavcodec/qdm2.c
@@ -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;



More information about the ffmpeg-cvslog mailing list