Old code needed about 6 times as long as new with defaults in afftfilt
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -59,19 +59,6 @@ enum WindowFunc { WFUNC_RECT, WFUNC_HANNING, WFUNC_HAMMING, WFUNC_BLACKMAN, · 58 unmodified lines | ||
| 59 | 59 | { "bohman", "Bohman", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BOHMAN}, 0, 0, flag, "win_func" }, \ |
| 60 | 60 | { "kaiser", "Kaiser", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_KAISER}, 0, 0, flag, "win_func" } |
| 61 | 61 | |
| 62 | −static inline double get_i0(double x) | |
| 63 | −{ | |
| 64 | − double y = 1.0, prev = 1.0, i = 1.0; | |
| 65 | − | |
| 66 | − while (fabs(prev) > 1e-20) { | |
| 67 | − double summand = prev * x * x / (4 * i * i); | |
| 68 | − y += summand; | |
| 69 | − prev = summand; | |
| 70 | − i++; | |
| 71 | − } | |
| 72 | − | |
| 73 | − return y; | |
| 74 | −} | |
| 75 | 62 | |
| 76 | 63 | static inline void generate_window_func(float *lut, int N, int win_func, |
| 77 | 64 | float *overlap) |
| @@ -232,13 +219,15 @@ static inline void generate_window_func(float *lut, int N, int win_func, · 154 unmodified lines | ||
| 232 | 219 | *overlap = 0.75; |
| 233 | 220 | break; |
| 234 | 221 | case WFUNC_KAISER: |
| 222 | + { | |
| 223 | + double scale = 1.0 / av_bessel_i0(12.); | |
| 235 | 224 | for (n = 0; n < N; n++) { |
| 236 | 225 | double x = 2.0 / (double)(N - 1); |
| 237 | − | |
| 238 | − lut[n] = get_i0(12. * sqrt(1. - SQR(n * x - 1.))) / get_i0(12.); | |
| 226 | + lut[n] = av_bessel_i0(12. * sqrt(1. - SQR(n * x - 1.))) * scale; | |
| 239 | 227 | } |
| 240 | 228 | *overlap = 0.75; |
| 241 | 229 | break; |
| 230 | + } | |
| 242 | 231 | default: |
| 243 | 232 | av_assert0(0); |
| 244 | 233 | } |