[FFmpeg-devel] [PATCH] avcodec/libspeexdec: initialize channels

huheng heng.hu.1989 at gmail.com
Sat Jul 16 09:08:26 EEST 2022


speex has no header in flv container, libspeexdec reports 'Invalid channel count'
when decoding a flv file as the channels is not initialized. Reproduce this issue with:
1) ffmpeg -f lavfi -i anullsrc -ac 1 -ar 16000 -acodec libspeex test.flv
2) ffplay -acodec libspeex test.flv

Signed-off-by: huheng <heng.hu.1989 at gmail.com>
---
 libavcodec/libspeexdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/libspeexdec.c b/libavcodec/libspeexdec.c
index 8c9e05e51d..bb8e1a7db9 100644
--- a/libavcodec/libspeexdec.c
+++ b/libavcodec/libspeexdec.c
@@ -43,7 +43,7 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx)
     LibSpeexContext *s = avctx->priv_data;
     const SpeexMode *mode;
     SpeexHeader *header = NULL;
-    int spx_mode, channels;
+    int spx_mode, channels = avctx->ch_layout.nb_channels;
 
     if (avctx->extradata && avctx->extradata_size >= 80) {
         header = speex_packet_to_header(avctx->extradata,
-- 
2.36.1



More information about the ffmpeg-devel mailing list