[FFmpeg-cvslog] libspeexdec: If the channel count is not valid, decode as stereo.

Justin Ruggles git at videolan.org
Thu Oct 4 12:37:07 CEST 2012


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Sun Sep 30 21:59:03 2012 -0400| [29abb04e73b0580ebe38703cadb988d26df6a76a] | committer: Justin Ruggles

libspeexdec: If the channel count is not valid, decode as stereo.

When initialized as stereo, libspeex can decode either mono or stereo packets
and will output stereo.

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

 libavcodec/libspeexdec.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavcodec/libspeexdec.c b/libavcodec/libspeexdec.c
index 390d4de..b9d9149 100644
--- a/libavcodec/libspeexdec.c
+++ b/libavcodec/libspeexdec.c
@@ -70,9 +70,11 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx)
     }
     avctx->sample_rate = 8000 << spx_mode;
 
-    if (avctx->channels > 2) {
-        av_log(avctx, AV_LOG_ERROR, "Only stereo and mono are supported.\n");
-        return AVERROR(EINVAL);
+    if (avctx->channels < 1 || avctx->channels > 2) {
+        /* libspeex can handle mono or stereo if initialized as stereo */
+        av_log(avctx, AV_LOG_ERROR, "Invalid channel count: %d.\n"
+                                    "Decoding as stereo.\n", avctx->channels);
+        avctx->channels = 2;
     }
 
     speex_bits_init(&s->bits);



More information about the ffmpeg-cvslog mailing list