History

avcodec/eac3dec: avoid float noise in fixed mode addition to overflow

Fixes: 2.28595e+09 is outside the range of representable values of type 'int' Fixes: 54644/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AC3_FIXED_fuzzer-4816961584627712

Michael Niedermayer committed 3 years ago

Commit 2f48d221 parent 9ea6d932 files · +5 −1Browse files

Unified · Split

2 files
  1. libavcodec/ac3.h +2 −0
  2. libavcodec/eac3dec.c +3 −1
libavcodec/ac3.h+2−0
@@ -53,6 +53,7 @@ · 52 unmodified lines
53#define AC3_DYNAMIC_RANGE1 053#define AC3_DYNAMIC_RANGE1 0
54 54
55typedef int INTFLOAT;55typedef int INTFLOAT;
56typedef unsigned int UINTFLOAT;
56typedef int16_t SHORTFLOAT;57typedef int16_t SHORTFLOAT;
57 58
58#else /* USE_FIXED */59#else /* USE_FIXED */
@@ -73,6 +74,7 @@ typedef int16_t SHORTFLOAT; · 14 unmodified lines
73#define AC3_DYNAMIC_RANGE1 1.0f74#define AC3_DYNAMIC_RANGE1 1.0f
74 75
75typedef float INTFLOAT;76typedef float INTFLOAT;
77typedef float UINTFLOAT;
76typedef float SHORTFLOAT;78typedef float SHORTFLOAT;
77 79
78#endif /* USE_FIXED */80#endif /* USE_FIXED */
libavcodec/eac3dec.c+3−1
@@ -138,9 +138,11 @@ static void ff_eac3_apply_spectral_extension(AC3DecodeContext *s) · 137 unmodified lines
138 // spx_noise_blend and spx_signal_blend are both FP.23138 // spx_noise_blend and spx_signal_blend are both FP.23
139 nscale *= 1.0 / (1<<23);139 nscale *= 1.0 / (1<<23);
140 sscale *= 1.0 / (1<<23);140 sscale *= 1.0 / (1<<23);
141 if (nscale < -1.0)
142 nscale = -1.0;
141#endif143#endif
142 for (i = 0; i < s->spx_band_sizes[bnd]; i++) {144 for (i = 0; i < s->spx_band_sizes[bnd]; i++) {
143 float noise = nscale * (int32_t)av_lfg_get(&s->dith_state);145 UINTFLOAT noise = (INTFLOAT)(nscale * (int32_t)av_lfg_get(&s->dith_state));
144 s->transform_coeffs[ch][bin] *= sscale;146 s->transform_coeffs[ch][bin] *= sscale;
145 s->transform_coeffs[ch][bin++] += noise;147 s->transform_coeffs[ch][bin++] += noise;
146 }148 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t