[FFmpeg-devel] [PATCH] avcodec/speexdec: fix decoding regressions
shenleban tongying
shenlebantongying at gmail.com
Fri Nov 8 01:56:52 EET 2024
* fix ticket #11054 and #11078
* reduce false decoding errors
* fix wrong frame_size
Co-authored-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: shenleban tongying <shenlebantongying at gmail.com>
---
libavcodec/speexdec.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/libavcodec/speexdec.c b/libavcodec/speexdec.c
index d25823ef6e..d48bfca803 100644
--- a/libavcodec/speexdec.c
+++ b/libavcodec/speexdec.c
@@ -1425,7 +1425,8 @@ static int parse_speex_extradata(AVCodecContext *avctx,
if (s->frame_size < NB_FRAME_SIZE << (s->mode > 0) ||
s->frame_size > INT32_MAX >> (s->mode > 0))
return AVERROR_INVALIDDATA;
- s->frame_size <<= (s->mode > 0);
+ s->frame_size <<= (s->mode > 1);
+ s->frame_size = FFMIN(640, s->frame_size);
s->vbr = bytestream_get_le32(&buf);
s->frames_per_packet = bytestream_get_le32(&buf);
if (s->frames_per_packet <= 0 ||
@@ -1563,10 +1564,11 @@ static int speex_decode_frame(AVCodecContext *avctx, AVFrame *frame,
return ret;
if (avctx->ch_layout.nb_channels == 2)
speex_decode_stereo(dst + i * s->frame_size, s->frame_size, &s->stereo);
- if (get_bits_left(&s->gb) < 5 ||
- show_bits(&s->gb, 5) == 15) {
- frames_per_packet = i + 1;
+ if (get_bits_left(&s->gb) < 5)
break;
+ if (show_bits(&s->gb, 5) == 15) {
+ frames_per_packet = i + 1;
+ skip_bits(&s->gb, 5);
}
}
--
2.47.0
More information about the ffmpeg-devel
mailing list