RESOLVED FIXED 217322
[Cocoa] Vectorize linear to decibels conversion in RealtimeAnalyser
https://bugs.webkit.org/show_bug.cgi?id=217322
Summary [Cocoa] Vectorize linear to decibels conversion in RealtimeAnalyser
Chris Dumez
Reported 2020-10-05 10:47:38 PDT
Vectorize linear to decibels conversion in RealtimeAnalyser.
Attachments
Patch (14.08 KB, patch)
2020-10-05 10:50 PDT, Chris Dumez
no flags
Patch (14.80 KB, patch)
2020-10-05 11:56 PDT, Chris Dumez
no flags
Patch (56.89 KB, patch)
2020-10-05 14:10 PDT, Chris Dumez
no flags
Patch (57.15 KB, patch)
2020-10-05 14:17 PDT, Chris Dumez
no flags
Chris Dumez
Comment 1 2020-10-05 10:50:29 PDT
Chris Dumez
Comment 2 2020-10-05 11:56:07 PDT
Darin Adler
Comment 3 2020-10-05 13:43:22 PDT
Comment on attachment 410536 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=410536&action=review > Source/WebCore/Modules/webaudio/RealtimeAnalyser.cpp:190 > + if (length > 0) Is this if statement an important optimization? I would have done all of this in one line. > Source/WebCore/platform/audio/VectorMath.cpp:755 > + int n = framesToProcess; Not OK to just put a size_t into an int, especially when there is no reason to. Also not sure why the loop is written this way. Could use a for loop instead, I guess? > Source/WebCore/platform/audio/VectorMath.h:56 > +void linearToDecibels(const float* sourceP, int sourceStride, float* destP, int destStride, size_t framesToProcess); Can we do better on these argument names? Not sure sourceP is better than inputVector, for example. Looking at vDSP_vdbcon they seem to refer to these as input and output vector. Also they use the terminology "number of elements to process". I don’t think the argument should be named "frames to process" since it’s not frames, it’s a number. Do we need to pass the stride values in? I understand that the underlying vector function takes a stride algorithm, but I am not sure we need that flexibility in our vector math wrapper interface.
Chris Dumez
Comment 4 2020-10-05 13:46:16 PDT
Comment on attachment 410536 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=410536&action=review >> Source/WebCore/platform/audio/VectorMath.cpp:755 >> + int n = framesToProcess; > > Not OK to just put a size_t into an int, especially when there is no reason to. > > Also not sure why the loop is written this way. Could use a for loop instead, I guess? Ok. I was merely following the pattern in this file. I will fix all of them. >> Source/WebCore/platform/audio/VectorMath.h:56 >> +void linearToDecibels(const float* sourceP, int sourceStride, float* destP, int destStride, size_t framesToProcess); > > Can we do better on these argument names? Not sure sourceP is better than inputVector, for example. Looking at vDSP_vdbcon they seem to refer to these as input and output vector. Also they use the terminology "number of elements to process". I don’t think the argument should be named "frames to process" since it’s not frames, it’s a number. > > Do we need to pass the stride values in? I understand that the underlying vector function takes a stride algorithm, but I am not sure we need that flexibility in our vector math wrapper interface. Ok. I will look into improving our VectorMath API in a follow-up since your comments apply to all functions, not just the one I am adding.
Chris Dumez
Comment 5 2020-10-05 14:10:42 PDT
Chris Dumez
Comment 6 2020-10-05 14:17:50 PDT
EWS
Comment 7 2020-10-05 15:03:07 PDT
Committed r268006: <https://trac.webkit.org/changeset/268006> All reviewed patches have been landed. Closing bug and clearing flags on attachment 410558 [details].
Radar WebKit Bug Importer
Comment 8 2020-10-05 15:04:21 PDT
Note You need to log in before you can comment on or make changes to this bug.