Changeset 268506 in webkit


Ignore:
Timestamp:
Oct 14, 2020 7:29:30 PM (4 years ago)
Author:
Chris Dumez
Message:

Rename VectorMath::multiplyThenAddScalar() for clarity
https://bugs.webkit.org/show_bug.cgi?id=217744

Reviewed by Darin Adler.

Rename VectorMath::multiplyThenAddScalar() to VectorMath::multiplyByScalarThenAddToOutput()
for clarity. The previous name was a bit confusing and hopefully the new name makes it
clearer what the function actually does. If not, I also improved the comment next to the
function.

  • platform/audio/AudioBus.cpp:

(WebCore::AudioBus::speakersSumFromByDownMixing):

  • platform/audio/VectorMath.cpp:

(WebCore::VectorMath::multiplyByScalarThenAddToOutput):

  • platform/audio/VectorMath.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r268505 r268506  
     12020-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
    1192020-10-14  Chris Dumez  <cdumez@apple.com>
    220
  • trunk/Source/WebCore/platform/audio/AudioBus.cpp

    r268505 r268506  
    318318
    319319        float* destination = channelByType(ChannelLeft)->mutableData();
    320         VectorMath::multiplyThenAddScalar(sourceL, 0.5, destination, length());
    321         VectorMath::multiplyThenAddScalar(sourceR, 0.5, destination, length());
     320        VectorMath::multiplyByScalarThenAddToOutput(sourceL, 0.5, destination, length());
     321        VectorMath::multiplyByScalarThenAddToOutput(sourceR, 0.5, destination, length());
    322322    } else if (numberOfSourceChannels == 4 && numberOfDestinationChannels == 1) {
    323323        // Down-mixing: 4 -> 1
     
    330330        auto* destination = channelByType(ChannelLeft)->mutableData();
    331331
    332         VectorMath::multiplyThenAddScalar(sourceL, 0.25, destination, length());
    333         VectorMath::multiplyThenAddScalar(sourceR, 0.25, destination, length());
    334         VectorMath::multiplyThenAddScalar(sourceSL, 0.25, destination, length());
    335         VectorMath::multiplyThenAddScalar(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());
    336336    } else if (numberOfSourceChannels == 6 && numberOfDestinationChannels == 1) {
    337337        // Down-mixing: 5.1 -> 1
     
    346346        float scaleSqrtHalf = sqrtf(0.5);
    347347
    348         VectorMath::multiplyThenAddScalar(sourceL, scaleSqrtHalf, destination, length());
    349         VectorMath::multiplyThenAddScalar(sourceR, scaleSqrtHalf, destination, length());
     348        VectorMath::multiplyByScalarThenAddToOutput(sourceL, scaleSqrtHalf, destination, length());
     349        VectorMath::multiplyByScalarThenAddToOutput(sourceR, scaleSqrtHalf, destination, length());
    350350        VectorMath::add(sourceC, destination, destination, length());
    351         VectorMath::multiplyThenAddScalar(sourceSL, 0.5, destination, length());
    352         VectorMath::multiplyThenAddScalar(sourceSR, 0.5, destination, length());
     351        VectorMath::multiplyByScalarThenAddToOutput(sourceSL, 0.5, destination, length());
     352        VectorMath::multiplyByScalarThenAddToOutput(sourceSR, 0.5, destination, length());
    353353    } else if (numberOfSourceChannels == 4 && numberOfDestinationChannels == 2) {
    354354        // Down-mixing: 4 -> 2
     
    363363        auto* destinationR = channelByType(ChannelRight)->mutableData();
    364364
    365         VectorMath::multiplyThenAddScalar(sourceL, 0.5, destinationL, length());
    366         VectorMath::multiplyThenAddScalar(sourceSL, 0.5, destinationL, length());
    367         VectorMath::multiplyThenAddScalar(sourceR, 0.5, destinationR, length());
    368         VectorMath::multiplyThenAddScalar(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());
    369369    } else if (numberOfSourceChannels == 6 && numberOfDestinationChannels == 2) {
    370370        // Down-mixing: 5.1 -> 2
     
    382382
    383383        VectorMath::add(sourceL, destinationL, destinationL, length());
    384         VectorMath::multiplyThenAddScalar(sourceC, scaleSqrtHalf, destinationL, length());
    385         VectorMath::multiplyThenAddScalar(sourceSL, scaleSqrtHalf, destinationL, length());
     384        VectorMath::multiplyByScalarThenAddToOutput(sourceC, scaleSqrtHalf, destinationL, length());
     385        VectorMath::multiplyByScalarThenAddToOutput(sourceSL, scaleSqrtHalf, destinationL, length());
    386386        VectorMath::add(sourceR, destinationR, destinationR, length());
    387         VectorMath::multiplyThenAddScalar(sourceC, scaleSqrtHalf, destinationR, length());
    388         VectorMath::multiplyThenAddScalar(sourceSR, scaleSqrtHalf, destinationR, length());
     387        VectorMath::multiplyByScalarThenAddToOutput(sourceC, scaleSqrtHalf, destinationR, length());
     388        VectorMath::multiplyByScalarThenAddToOutput(sourceSR, scaleSqrtHalf, destinationR, length());
    389389    } else if (numberOfSourceChannels == 6 && numberOfDestinationChannels == 4) {
    390390        // Down-mixing: 5.1 -> 4
     
    402402
    403403        VectorMath::add(sourceL, destinationL, destinationL, length());
    404         VectorMath::multiplyThenAddScalar(sourceC, scaleSqrtHalf, destinationL, length());
     404        VectorMath::multiplyByScalarThenAddToOutput(sourceC, scaleSqrtHalf, destinationL, length());
    405405        VectorMath::add(sourceR, destinationR, destinationR, length());
    406         VectorMath::multiplyThenAddScalar(sourceC, scaleSqrtHalf, destinationR, length());
     406        VectorMath::multiplyByScalarThenAddToOutput(sourceC, scaleSqrtHalf, destinationR, length());
    407407        channel(2)->sumFrom(sourceBus.channel(4));
    408408        channel(3)->sumFrom(sourceBus.channel(5));
  • trunk/Source/WebCore/platform/audio/VectorMath.cpp

    r268505 r268506  
    8787}
    8888
    89 void multiplyThenAddScalar(const float* inputVector, float scale, float* outputVector, size_t numberOfElementsToProcess)
     89void multiplyByScalarThenAddToOutput(const float* inputVector, float scale, float* outputVector, size_t numberOfElementsToProcess)
    9090{
    9191    vDSP_vsma(inputVector, 1, &scale, outputVector, 1, outputVector, 1, numberOfElementsToProcess);
     
    129129}
    130130
    131 void multiplyThenAddScalar(const float* inputVector, float scale, float* outputVector, size_t numberOfElementsToProcess)
     131void multiplyByScalarThenAddToOutput(const float* inputVector, float scale, float* outputVector, size_t numberOfElementsToProcess)
    132132{
    133133    size_t n = numberOfElementsToProcess;
  • trunk/Source/WebCore/platform/audio/VectorMath.h

    r268505 r268506  
    3232namespace VectorMath {
    3333
    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;
     37void multiplyByScalarThenAddToOutput(const float* inputVector, float scale, float* outputVector, size_t numberOfElementsToProcess);
    3638
    3739// Multiplies the sum of two vectors by a scalar value (vasm).
Note: See TracChangeset for help on using the changeset viewer.