void fftUpdate(Fft *fft, float complex *inbuf, int count, FftOutputFunc *func, void *context) { float complex *in = inbuf; fftw_complex *fftwin = fft->in; int N = fft->N; int inPtr = fft->inPtr; while (count--) { if ((fft->skipCounter++) < fft->threshold) continue; fftwin[inPtr++] = *in++; if (inPtr >= N) { inPtr = 0; fftw_execute(fft->plan); unsigned int *ps = fft->spectrum; int half = N>>1; fftw_complex *lower = fft->out; fftw_complex *upper = fft->out + half; int count = half; while (count--) { *ps++ = (unsigned int)(20.0 * fasterlog2(1.0 + cabsf(*upper++))); } count = half; while (count--) { *ps++ = (unsigned int)(20.0 * fasterlog2(1.0 + cabsf(*lower++))); } func(fft->spectrum, N, context); fft->skipCounter = 0; } }
size_t Bilinear::subdiv_estimate(float width) const { // Since we want to end up with the log-base-2 of // the division anyway, we just do the log first and // subtract. Using a very approximate log2, but in // practice it works fine. const float rate = log_widest - fasterlog2(width * Config::dice_rate) + 1.0f; return std::max(rate, 0.0f); }