RESOLVED FIXED 74693
Optimize with memcpy instead of copying frame by frame in Realtimeanalyser::doFFTAnalysis
https://bugs.webkit.org/show_bug.cgi?id=74693
Summary Optimize with memcpy instead of copying frame by frame in Realtimeanalyser::d...
Wei James (wistoch)
Reported 2011-12-16 00:29:17 PST
Optimize with memcpy instead of copying frame by frame in Realtimeanalyser::doFFTAnalysis
Attachments
Patch (1.86 KB, patch)
2011-12-16 00:31 PST, Wei James (wistoch)
no flags
Patch (1.87 KB, patch)
2011-12-17 00:18 PST, Wei James (wistoch)
no flags
Patch (1.84 KB, patch)
2012-01-05 17:07 PST, Wei James (wistoch)
no flags
Wei James (wistoch)
Comment 1 2011-12-16 00:31:59 PST
Raymond Toy
Comment 2 2011-12-16 09:15:41 PST
Comment on attachment 119579 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=119579&action=review > Source/WebCore/webaudio/RealtimeAnalyser.cpp:162 > + memcpy(tempP, inputBuffer + writeIndex - fftSize + InputBufferSize, sizeof(float) * (fftSize - writeIndex)); I think sizeof(*tempP) is better than sizeof(float).
Wei James (wistoch)
Comment 3 2011-12-17 00:18:15 PST
Wei James (wistoch)
Comment 4 2011-12-17 00:41:41 PST
(In reply to comment #2) > (From update of attachment 119579 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=119579&action=review > > > Source/WebCore/webaudio/RealtimeAnalyser.cpp:162 > > + memcpy(tempP, inputBuffer + writeIndex - fftSize + InputBufferSize, sizeof(float) * (fftSize - writeIndex)); > > I think sizeof(*tempP) is better than sizeof(float). thanks for the review. patch updated.
Raymond Toy
Comment 5 2011-12-19 08:58:43 PST
Comment on attachment 119717 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=119717&action=review > Source/WebCore/webaudio/RealtimeAnalyser.cpp:162 > + memcpy(tempP, inputBuffer + writeIndex - fftSize + InputBufferSize, sizeof(*tempP) * (fftSize - writeIndex)); Does this handle wrapping the index as the original code did? It seems to me that writeIndex (m_writeIndex) could be as large as InputBufferSize - 1, so the memcpy might be reading past the end of the inputBuffer.
Wei James (wistoch)
Comment 6 2011-12-19 16:52:38 PST
Comment on attachment 119717 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=119717&action=review >> Source/WebCore/webaudio/RealtimeAnalyser.cpp:162 >> + memcpy(tempP, inputBuffer + writeIndex - fftSize + InputBufferSize, sizeof(*tempP) * (fftSize - writeIndex)); > > Does this handle wrapping the index as the original code did? It seems to me that writeIndex (m_writeIndex) could be as large as InputBufferSize - 1, so the memcpy might be reading past the end of the inputBuffer. this memcpy is under the if(writeIndex < fftSize) statement. the case you mentioned is under else statement. thanks
Wei James (wistoch)
Comment 7 2011-12-20 17:31:41 PST
(In reply to comment #6) > (From update of attachment 119717 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=119717&action=review > > >> Source/WebCore/webaudio/RealtimeAnalyser.cpp:162 > >> + memcpy(tempP, inputBuffer + writeIndex - fftSize + InputBufferSize, sizeof(*tempP) * (fftSize - writeIndex)); > > > > Does this handle wrapping the index as the original code did? It seems to me that writeIndex (m_writeIndex) could be as large as InputBufferSize - 1, so the memcpy might be reading past the end of the inputBuffer. > > this memcpy is under the if(writeIndex < fftSize) statement. the case you mentioned is under else statement. thanks raymond, does it answer your question? or do you think the patch still need revise? thanks
Raymond Toy
Comment 8 2011-12-21 09:32:52 PST
(In reply to comment #7) > (In reply to comment #6) > > (From update of attachment 119717 [details] [details]) > > View in context: https://bugs.webkit.org/attachment.cgi?id=119717&action=review > > > > >> Source/WebCore/webaudio/RealtimeAnalyser.cpp:162 > > >> + memcpy(tempP, inputBuffer + writeIndex - fftSize + InputBufferSize, sizeof(*tempP) * (fftSize - writeIndex)); > > > > > > Does this handle wrapping the index as the original code did? It seems to me that writeIndex (m_writeIndex) could be as large as InputBufferSize - 1, so the memcpy might be reading past the end of the inputBuffer. > > > > this memcpy is under the if(writeIndex < fftSize) statement. the case you mentioned is under else statement. thanks > > raymond, does it answer your question? or do you think the patch still need revise? thanks Sorry. It seems that my reply from yesterday got lost some how. Yes, you've answered my question. Wrapping is handled. (I had convinced myself in the first patch that it was correct, but promptly forgot in the second patch review.)
Wei James (wistoch)
Comment 9 2011-12-21 16:42:21 PST
(In reply to comment #8) > (In reply to comment #7) > > (In reply to comment #6) > > > (From update of attachment 119717 [details] [details] [details]) > > > View in context: https://bugs.webkit.org/attachment.cgi?id=119717&action=review > > > > > > >> Source/WebCore/webaudio/RealtimeAnalyser.cpp:162 > > > >> + memcpy(tempP, inputBuffer + writeIndex - fftSize + InputBufferSize, sizeof(*tempP) * (fftSize - writeIndex)); > > > > > > > > Does this handle wrapping the index as the original code did? It seems to me that writeIndex (m_writeIndex) could be as large as InputBufferSize - 1, so the memcpy might be reading past the end of the inputBuffer. > > > > > > this memcpy is under the if(writeIndex < fftSize) statement. the case you mentioned is under else statement. thanks > > > > raymond, does it answer your question? or do you think the patch still need revise? thanks > > Sorry. It seems that my reply from yesterday got lost some how. Yes, you've answered my question. Wrapping is handled. (I had convinced myself in the first patch that it was correct, but promptly forgot in the second patch review.) thanks. :)
Kenneth Russell
Comment 10 2012-01-03 13:21:48 PST
If Chris Rogers gives an unofficial LGTM on this I'd be happy to r+ it.
Chris Rogers
Comment 11 2012-01-05 17:01:23 PST
Comment on attachment 119717 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=119717&action=review Looks good if you fix the ChangeLog > Source/WebCore/ChangeLog:8 > + No new tests. (OOPS!) This line should be taken out.
Wei James (wistoch)
Comment 12 2012-01-05 17:07:34 PST
Wei James (wistoch)
Comment 13 2012-01-05 17:08:21 PST
(In reply to comment #11) > (From update of attachment 119717 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=119717&action=review > > Looks good if you fix the ChangeLog > > > Source/WebCore/ChangeLog:8 > > + No new tests. (OOPS!) > > This line should be taken out. thanks, patch updated to remove this line. thanks
Kenneth Russell
Comment 14 2012-01-05 18:15:21 PST
Comment on attachment 121371 [details] Patch rs=me
WebKit Review Bot
Comment 15 2012-01-05 20:01:36 PST
Comment on attachment 121371 [details] Patch Clearing flags on attachment: 121371 Committed r104265: <http://trac.webkit.org/changeset/104265>
WebKit Review Bot
Comment 16 2012-01-05 20:01:41 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.