PR #25884 opened by sylvestre URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25884 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25884.patch
Introduced in 0b67c83b2e (USAC SBR support) and copied into mpeg4audio.c by 0c29837dac. Found by Coverity (Firefox CID 1701842, DEADCODE). I could not find a place to add tests >From 58a7b31c0d7e512261c9b2ae41d84f39ff368464 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru <[email protected]> Date: Mon, 9 Nov 2026 14:56:17 +0100 Subject: [PATCH 1/2] avcodec/mpeg4audio: fix frame length for USAC 4:1 SBR coreSbrFrameLengthIndex 4 (ISO/IEC 23003-3, Table 70) is a 1024 sample core with 4:1 SBR, giving 4096 output samples per frame. It is mapped to sbrRatioIndex 1, as in the spec, but the 4:1 branch tested sbr_ratio == 4, a value that is never produced, so frame_length was reported as 1024. Test for sbr_ratio == 1 instead. The branch was copied from the USAC decoder in 0c29837dac ("avcodec/mpeg4audio: add a frame_length field to MPEG4AudioConfig"). Found by Coverity (Firefox CID 1701842): Logically dead code (DEADCODE) dead_error_begin: Execution cannot reach this statement: ratio_mult = 4;. --- libavcodec/mpeg4audio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mpeg4audio.c b/libavcodec/mpeg4audio.c index 0430568b631..feb1847153d 100644 --- a/libavcodec/mpeg4audio.c +++ b/libavcodec/mpeg4audio.c @@ -167,7 +167,7 @@ int ff_mpeg4audio_get_config_gb(MPEG4AudioConfig *c, GetBitContext *gb, } else if (sbr_ratio == 3) { ratio_mult = 2; ratio_dec = 1; - } else if (sbr_ratio == 4) { + } else if (sbr_ratio == 1) { ratio_mult = 4; ratio_dec = 1; } else { -- 2.54.0 >From 55df5bd5bbc46fbe6df90d8a46caadd5fb4c4d88 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru <[email protected]> Date: Mon, 9 Nov 2026 14:56:17 +0100 Subject: [PATCH 2/2] avcodec/aac/aacdec_usac: fix 4:1 SBR ratio check coreSbrFrameLengthIndex 4 (ISO/IEC 23003-3, Table 70) is a 1024 sample core with 4:1 SBR, and is mapped to sbrRatioIndex 1 as in the spec. Both places computing ratio_mult/ratio_dec tested sbr_ratio == 4 for 4:1, which is never produced, so the branches were dead code. This has no effect today, since index 4 is rejected with AVERROR_PATCHWELCOME, but it would give a wrong core sample rate once 4:1 SBR is supported. Regression since 0b67c83b2e ("aacdec_usac, aacsbr: implement SBR support for USAC"). Same issue as Coverity (Firefox CID 1701842), which was reported in ff_mpeg4audio_get_config_gb(). --- libavcodec/aac/aacdec_usac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c index e29457a1bd7..f6722697e31 100644 --- a/libavcodec/aac/aacdec_usac.c +++ b/libavcodec/aac/aacdec_usac.c @@ -609,7 +609,7 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, } else if (sbr_ratio == 3) { ratio_mult = 2; ratio_dec = 1; - } else if (sbr_ratio == 4) { + } else if (sbr_ratio == 1) { ratio_mult = 4; ratio_dec = 1; } else { @@ -2096,7 +2096,7 @@ int ff_aac_usac_decode_frame(AVCodecContext *avctx, AACDecContext *ac, } else if (sbr_ratio == 3) { ratio_mult = 2; ratio_dec = 1; - } else if (sbr_ratio == 4) { + } else if (sbr_ratio == 1) { ratio_mult = 4; ratio_dec = 1; } else { -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
