Closed Bug 956604 Opened 11 years ago Closed 11 years ago

Optimize inverse FFT scaling during convolution

Categories

(Core :: Web Audio, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla29

People

(Reporter: karlt, Assigned: karlt)

References

Details

(Keywords: perf)

Attachments

(4 files)

Conventions for forward and inverse FFTs usually scale by the reciprocal of the size (1/N) when performing the inverse. When convolving, the forward FFT of the impulse response buffer is performed only once but used for each block in the audio stream. By moving the 1/N scaling to the DFT from the impulse response, the scaling need only be performed once, instead of for each inverse FFT.
Attached patch patchSplinter Review
This reduces MSG CPU usage by 2% on Demo 4 of http://webaudiodemos.appspot.com/MIDIDrums/index.html
Attachment #8355931 - Flags: review?(paul)
Keywords: perf
Comment on attachment 8355931 [details] [diff] [review] patch Review of attachment 8355931 [details] [diff] [review]: ----------------------------------------------------------------- Makes sense, thanks. ::: content/media/webaudio/FFTBlock.cpp @@ +49,5 @@ > + newBlock->GetInverseWithoutScaling(buffer.Elements()); > + const float scale = 1.0f / fftSize; > + for (int i = 0; i < fftSize / 2; ++i) { > + buffer[i] *= scale; > + } AudioBufferInPlaceScale (it has a variant with an arbitrary size array), please, so we can be faster on ARM, and on x86 when I finally land the SSE patches. ::: content/media/webaudio/FFTBlock.h @@ +52,5 @@ > + GetInverseWithoutScaling(aDataOut); > + const float scale = 1.0f / mFFTSize; > + for (uint32_t i = 0; i < mFFTSize; ++i) { > + aDataOut[i] *= scale; > + } Same remark.
Attachment #8355931 - Flags: review?(paul) → review+
(In reply to Paul Adenot (:padenot) from comment #2) > AudioBufferInPlaceScale (it has a variant with an arbitrary size array), > please, so we can be faster on ARM, and on x86 when I finally land the SSE > patches. Ah, yes. I looked for that but somehow looked over it. Perhaps I got confused by the naming. There is almost a convention in the naming of block and arbitrary size methods.
Attachment #8356269 - Flags: review?(paul)
Makes the interface more consistent with other AudioBuffer functions.
Attachment #8356271 - Flags: review?(paul)
Attachment #8356269 - Flags: review?(paul) → review+
Comment on attachment 8356271 [details] [diff] [review] Remove unnecessary channel count parameter from AudioBufferInPlaceScale Review of attachment 8356271 [details] [diff] [review]: ----------------------------------------------------------------- ::: content/media/AudioNodeEngineNEON.cpp @@ +135,5 @@ > float32x4_t vin0, vin1, vin2, vin3; > float32x4_t vout0, vout1, vout2, vout3; > float32x4_t vscale = vmovq_n_f32(aScale); > > + uint32_t totalSize = aSize; Could you just use aSize below instead of copying it to another variable?
Attachment #8356271 - Flags: review?(paul) → review+
(In reply to Paul Adenot (:padenot) from comment #5) > Could you just use aSize below instead of copying it to another variable? It would work, but the a- prefix on the variable suggests that it is the value passed to the function, so I would prefer not to modify aSize. How about this?
Attachment #8356499 - Flags: review?(paul)
Attachment #8356499 - Flags: review?(paul) → review+
Flags: in-testsuite-
(In reply to Wes Kocher (:KWierso) from comment #10) Those are not likely the patches in this bug, which change values rather than lengths, but there have been other webaudio and MediaStreamGraph changes that may be involved. I'll see if I can do some retriggers tomorrow if we don't have more info then.
Flags: needinfo?(karlt)
Bug 957691 doesn't involve web audio and is likely the same bug as the assertions in comments 9 and 10.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: