diff mbox series

[FFmpeg-devel] avcodec/libspeexdec: initialize channels

Message ID 20220716060826.69979-1-heng.hu.1989@gmail.com
State New
Headers show
Series [FFmpeg-devel] avcodec/libspeexdec: initialize channels | expand


Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

hu heng July 16, 2022, 6:08 a.m. UTC
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@gmail.com>
 libavcodec/libspeexdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


Paul B Mahol July 16, 2022, 7:27 a.m. UTC | #1
use native decoder
hu heng July 16, 2022, 10:33 a.m. UTC | #2
Thanks for your advice.
But native speex decoder also has its own issue when decoding speex packet
which contains multiple frames.

ffmpeg -i someaudio -ac 1 -ar 16000 -c:a libspeex  -frames_per_packets 3 -f
flv xx.flv
ffplay xx.flv

native speed decoder only get the first frame of every packet as speex in
flv has no header.

so I prefer use  libspeexdec as an alternative before the native speex
decoder issue is fixed and send this patch for libspeexdec.

Paul B Mahol <onemda@gmail.com> 于2022年7月16日周六 15:24写道:

> use native decoder
Paul B Mahol July 16, 2022, 10:50 a.m. UTC | #3
Please fix native decoder instead.
Timo Rothenpieler July 16, 2022, 10:54 a.m. UTC | #4
On 16.07.2022 12:50, Paul B Mahol wrote:
> Please fix native decoder instead.

Both decoders should be fixed if they have issues decoding valid files.
diff mbox series


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,