Changeset 268506 in webkit
- Timestamp:
- Oct 14, 2020 7:29:30 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r268505 r268506 1 2020-10-14 Chris Dumez <cdumez@apple.com> 2 3 Rename VectorMath::multiplyThenAddScalar() for clarity 4 https://bugs.webkit.org/show_bug.cgi?id=217744 5 6 Reviewed by Darin Adler. 7 8 Rename VectorMath::multiplyThenAddScalar() to VectorMath::multiplyByScalarThenAddToOutput() 9 for clarity. The previous name was a bit confusing and hopefully the new name makes it 10 clearer what the function actually does. If not, I also improved the comment next to the 11 function. 12 13 * platform/audio/AudioBus.cpp: 14 (WebCore::AudioBus::speakersSumFromByDownMixing): 15 * platform/audio/VectorMath.cpp: 16 (WebCore::VectorMath::multiplyByScalarThenAddToOutput): 17 * platform/audio/VectorMath.h: 18 1 19 2020-10-14 Chris Dumez <cdumez@apple.com> 2 20 -
trunk/Source/WebCore/platform/audio/AudioBus.cpp
r268505 r268506 318 318 319 319 float* destination = channelByType(ChannelLeft)->mutableData(); 320 VectorMath::multiply ThenAddScalar(sourceL, 0.5, destination, length());321 VectorMath::multiply ThenAddScalar(sourceR, 0.5, destination, length());320 VectorMath::multiplyByScalarThenAddToOutput(sourceL, 0.5, destination, length()); 321 VectorMath::multiplyByScalarThenAddToOutput(sourceR, 0.5, destination, length()); 322 322 } else if (numberOfSourceChannels == 4 && numberOfDestinationChannels == 1) { 323 323 // Down-mixing: 4 -> 1 … … 330 330 auto* destination = channelByType(ChannelLeft)->mutableData(); 331 331 332 VectorMath::multiply ThenAddScalar(sourceL, 0.25, destination, length());333 VectorMath::multiply ThenAddScalar(sourceR, 0.25, destination, length());334 VectorMath::multiply ThenAddScalar(sourceSL, 0.25, destination, length());335 VectorMath::multiply ThenAddScalar(sourceSR, 0.25, destination, length());332 VectorMath::multiplyByScalarThenAddToOutput(sourceL, 0.25, destination, length()); 333 VectorMath::multiplyByScalarThenAddToOutput(sourceR, 0.25, destination, length()); 334 VectorMath::multiplyByScalarThenAddToOutput(sourceSL, 0.25, destination, length()); 335 VectorMath::multiplyByScalarThenAddToOutput(sourceSR, 0.25, destination, length()); 336 336 } else if (numberOfSourceChannels == 6 && numberOfDestinationChannels == 1) { 337 337 // Down-mixing: 5.1 -> 1 … … 346 346 float scaleSqrtHalf = sqrtf(0.5); 347 347 348 VectorMath::multiply ThenAddScalar(sourceL, scaleSqrtHalf, destination, length());349 VectorMath::multiply ThenAddScalar(sourceR, scaleSqrtHalf, destination, length());348 VectorMath::multiplyByScalarThenAddToOutput(sourceL, scaleSqrtHalf, destination, length()); 349 VectorMath::multiplyByScalarThenAddToOutput(sourceR, scaleSqrtHalf, destination, length()); 350 350 VectorMath::add(sourceC, destination, destination, length()); 351 VectorMath::multiply ThenAddScalar(sourceSL, 0.5, destination, length());352 VectorMath::multiply ThenAddScalar(sourceSR, 0.5, destination, length());351 VectorMath::multiplyByScalarThenAddToOutput(sourceSL, 0.5, destination, length()); 352 VectorMath::multiplyByScalarThenAddToOutput(sourceSR, 0.5, destination, length()); 353 353 } else if (numberOfSourceChannels == 4 && numberOfDestinationChannels == 2) { 354 354 // Down-mixing: 4 -> 2 … … 363 363 auto* destinationR = channelByType(ChannelRight)->mutableData(); 364 364 365 VectorMath::multiply ThenAddScalar(sourceL, 0.5, destinationL, length());366 VectorMath::multiply ThenAddScalar(sourceSL, 0.5, destinationL, length());367 VectorMath::multiply ThenAddScalar(sourceR, 0.5, destinationR, length());368 VectorMath::multiply ThenAddScalar(sourceSR, 0.5, destinationR, length());365 VectorMath::multiplyByScalarThenAddToOutput(sourceL, 0.5, destinationL, length()); 366 VectorMath::multiplyByScalarThenAddToOutput(sourceSL, 0.5, destinationL, length()); 367 VectorMath::multiplyByScalarThenAddToOutput(sourceR, 0.5, destinationR, length()); 368 VectorMath::multiplyByScalarThenAddToOutput(sourceSR, 0.5, destinationR, length()); 369 369 } else if (numberOfSourceChannels == 6 && numberOfDestinationChannels == 2) { 370 370 // Down-mixing: 5.1 -> 2 … … 382 382 383 383 VectorMath::add(sourceL, destinationL, destinationL, length()); 384 VectorMath::multiply ThenAddScalar(sourceC, scaleSqrtHalf, destinationL, length());385 VectorMath::multiply ThenAddScalar(sourceSL, scaleSqrtHalf, destinationL, length());384 VectorMath::multiplyByScalarThenAddToOutput(sourceC, scaleSqrtHalf, destinationL, length()); 385 VectorMath::multiplyByScalarThenAddToOutput(sourceSL, scaleSqrtHalf, destinationL, length()); 386 386 VectorMath::add(sourceR, destinationR, destinationR, length()); 387 VectorMath::multiply ThenAddScalar(sourceC, scaleSqrtHalf, destinationR, length());388 VectorMath::multiply ThenAddScalar(sourceSR, scaleSqrtHalf, destinationR, length());387 VectorMath::multiplyByScalarThenAddToOutput(sourceC, scaleSqrtHalf, destinationR, length()); 388 VectorMath::multiplyByScalarThenAddToOutput(sourceSR, scaleSqrtHalf, destinationR, length()); 389 389 } else if (numberOfSourceChannels == 6 && numberOfDestinationChannels == 4) { 390 390 // Down-mixing: 5.1 -> 4 … … 402 402 403 403 VectorMath::add(sourceL, destinationL, destinationL, length()); 404 VectorMath::multiply ThenAddScalar(sourceC, scaleSqrtHalf, destinationL, length());404 VectorMath::multiplyByScalarThenAddToOutput(sourceC, scaleSqrtHalf, destinationL, length()); 405 405 VectorMath::add(sourceR, destinationR, destinationR, length()); 406 VectorMath::multiply ThenAddScalar(sourceC, scaleSqrtHalf, destinationR, length());406 VectorMath::multiplyByScalarThenAddToOutput(sourceC, scaleSqrtHalf, destinationR, length()); 407 407 channel(2)->sumFrom(sourceBus.channel(4)); 408 408 channel(3)->sumFrom(sourceBus.channel(5)); -
trunk/Source/WebCore/platform/audio/VectorMath.cpp
r268505 r268506 87 87 } 88 88 89 void multiply ThenAddScalar(const float* inputVector, float scale, float* outputVector, size_t numberOfElementsToProcess)89 void multiplyByScalarThenAddToOutput(const float* inputVector, float scale, float* outputVector, size_t numberOfElementsToProcess) 90 90 { 91 91 vDSP_vsma(inputVector, 1, &scale, outputVector, 1, outputVector, 1, numberOfElementsToProcess); … … 129 129 } 130 130 131 void multiply ThenAddScalar(const float* inputVector, float scale, float* outputVector, size_t numberOfElementsToProcess)131 void multiplyByScalarThenAddToOutput(const float* inputVector, float scale, float* outputVector, size_t numberOfElementsToProcess) 132 132 { 133 133 size_t n = numberOfElementsToProcess; -
trunk/Source/WebCore/platform/audio/VectorMath.h
r268505 r268506 32 32 namespace VectorMath { 33 33 34 // Vector scalar multiply and then add (vsma). 35 void multiplyThenAddScalar(const float* inputVector, float scale, float* outputVector, size_t numberOfElementsToProcess); 34 // Multiples inputVector by scalar then adds the result to outputVector (vsma). 35 // for (n = 0; n < numberOfElementsToProcess; ++n) 36 // outputVector[n] += inputVector[n] * scale; 37 void multiplyByScalarThenAddToOutput(const float* inputVector, float scale, float* outputVector, size_t numberOfElementsToProcess); 36 38 37 39 // Multiplies the sum of two vectors by a scalar value (vasm).
Note: See TracChangeset
for help on using the changeset viewer.