Commit 8c284ab5a9 for ffmpeg
commit 8c284ab5a90773d1ea60fcc150c0ff1bb799eb57
Author: Marvin Scholz <epirat07@gmail.com>
Date: Thu Oct 29 22:10:07 2026 +0000
avcodec/wmavoice: prevent float-cast-overflow on zero energy
Fix float cast overflow in wiener_denoise() / calc_input_response() due to a
cast of -NaN to integer.
Add boundary guards against zero or uniformly flat spectrum energies
in calc_input_response():
- In the log_range macro calculation, clamp the minimum energy input to
1e-31f before passing it to log10f().
- In the irange calculation, guard against zero range.
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
index c3cd053ba9..130dba7224 100644
--- a/libavcodec/wmavoice.c
+++ b/libavcodec/wmavoice.c
@@ -622,7 +622,7 @@ static void calc_input_response(WMAVoiceContext *s, float *lpcs_src,
/* Create frequency power spectrum of speech input (i.e. RDFT of LPCs) */
s->rdft_fn(s->rdft, lpcs, lpcs_src, sizeof(float));
#define log_range(var, assign) do { \
- float tmp = log10f(assign); var = tmp; \
+ float tmp = log10f(FFMAX(1e-31f, assign)); var = tmp; \
max = FFMAX(max, tmp); min = FFMIN(min, tmp); \
} while (0)
log_range(last_coeff, lpcs[64] * lpcs[64]);
@@ -639,7 +639,7 @@ static void calc_input_response(WMAVoiceContext *s, float *lpcs_src,
* and set up a table (still in lpc[]) of (relative) gains per frequency.
* These frequencies will be maintained, while others ("noise") will be
* decreased in the filter output. */
- irange = 64.0 / range; // so irange*(max-value) is in the range [0, 63]
+ irange = range > 0.0 ? 64.0 / range : 0.0; // so irange*(max-value) is in the range [0, 63]
gain_mul = range * (fcb_type == FCB_TYPE_HARDCODED ? (5.0 / 13.0) :
(5.0 / 14.7));
angle_mul = gain_mul * (8.0 * M_LN10 / M_PI);