Commit a9ff7ee
committed
math: auditory: guard mod_psy_get_mel_filterbank() against zero divisors
The mel-bin loop in mod_psy_get_mel_filterbank() divides by delta_cl and
delta_rc on every FFT bin, and by (right_hz - left_hz) when slaney
normalization is enabled. With unusual configurations these denominators
can become zero or negative — for example when start_freq >= end_freq,
when the requested mel_bins is large enough that integer division
truncates the mel step to zero, or at extreme inputs where psy_mel_to_hz
saturates and right_hz no longer exceeds left_hz.
Reject such configurations explicitly. After computing mel_step, return
-EINVAL if it is not positive, which also covers both delta values
since they equal mel_step. In the slaney_normalize branch, also verify
right_hz > left_hz before computing the scale factor.
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>1 parent 462cfb5 commit a9ff7ee
1 file changed
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| 20 | + | |
| 21 | + | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
| |||
148 | 151 | | |
149 | 152 | | |
150 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
151 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
152 | 176 | | |
153 | 177 | | |
154 | 178 | | |
| |||
160 | 184 | | |
161 | 185 | | |
162 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
163 | 192 | | |
164 | 193 | | |
165 | 194 | | |
| |||
0 commit comments