Changeset 202845 in webkit


Ignore:
Timestamp:
Jul 5, 2016 9:11:44 PM (8 years ago)
Author:
Brent Fulgham
Message:

Throw exceptions for invalid number of channels for ConvolverNode
<https://webkit.org/b/159238>

Patch by David Kilzer <ddkilzer@apple.com> on 2016-07-05
Reviewed by Brent Fulgham.

Source/WebCore:

Fix based on a Blink change (patch by <rtoy@chromium.org>):
<https://chromium.googlesource.com/chromium/src.git/+/0cc26bbb7175aec77910d0b47faf9f8c8a640fe5>

Also includes a related fix for ReverbConvolverStage (patch by <rtoy@chromium.org>):
<https://src.chromium.org/viewvc/blink?revision=157832&view=revision>

Test: webaudio/convolver-channels.html

  • Modules/webaudio/ConvolverNode.cpp:

(WebCore::ConvolverNode::setBuffer): Throw an exception for
anything but 1, 2 or 4 channels.

  • platform/audio/ReverbConvolverStage.cpp:

(WebCore::ReverbConvolverStage::ReverbConvolverStage): Don't read past the end of
the impulseResponse array.

LayoutTests:

Test based on a Blink change (patch by <rtoy@chromium.org>):
<https://chromium.googlesource.com/chromium/src.git/+/0cc26bbb7175aec77910d0b47faf9f8c8a640fe5>

compatibility.js based on a Blink change (patch by <Raymond Toy>):
<https://chromium.googlesource.com/chromium/src.git/+/f846f5a461d1fcdbe5152898576c125058079ed1>

  • webaudio/convolver-channels-expected.txt: Added.
  • webaudio/convolver-channels.html: Added.
  • webaudio/resources/compatibility.js: Added.
Location:
trunk
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202843 r202845  
     12016-07-05  David Kilzer  <ddkilzer@apple.com>
     2
     3        Throw exceptions for invalid number of channels for ConvolverNode
     4        <https://webkit.org/b/159238>
     5
     6        Reviewed by Brent Fulgham.
     7
     8        Test based on a Blink change (patch by <rtoy@chromium.org>):
     9        <https://chromium.googlesource.com/chromium/src.git/+/0cc26bbb7175aec77910d0b47faf9f8c8a640fe5>
     10
     11        compatibility.js based on a Blink change (patch by <rtoy@google.com>):
     12        <https://chromium.googlesource.com/chromium/src.git/+/f846f5a461d1fcdbe5152898576c125058079ed1>
     13
     14        * webaudio/convolver-channels-expected.txt: Added.
     15        * webaudio/convolver-channels.html: Added.
     16        * webaudio/resources/compatibility.js: Added.
     17
    1182016-07-05  Johan K. Jensen  <jj@johanjensen.dk>
    219
  • trunk/Source/WebCore/ChangeLog

    r202843 r202845  
     12016-07-05  David Kilzer  <ddkilzer@apple.com>
     2
     3        Throw exceptions for invalid number of channels for ConvolverNode
     4        <https://webkit.org/b/159238>
     5
     6        Reviewed by Brent Fulgham.
     7
     8        Fix based on a Blink change (patch by <rtoy@chromium.org>):
     9        <https://chromium.googlesource.com/chromium/src.git/+/0cc26bbb7175aec77910d0b47faf9f8c8a640fe5>
     10
     11        Also includes a related fix for ReverbConvolverStage (patch by <rtoy@chromium.org>):
     12        <https://src.chromium.org/viewvc/blink?revision=157832&view=revision>
     13
     14        Test: webaudio/convolver-channels.html
     15
     16        * Modules/webaudio/ConvolverNode.cpp:
     17        (WebCore::ConvolverNode::setBuffer): Throw an exception for
     18        anything but 1, 2 or 4 channels.
     19        * platform/audio/ReverbConvolverStage.cpp:
     20        (WebCore::ReverbConvolverStage::ReverbConvolverStage): Don't read past the end of
     21        the impulseResponse array.
     22
    1232016-07-05  Johan K. Jensen  <jj@johanjensen.dk>
    224
  • trunk/Source/WebCore/Modules/webaudio/ConvolverNode.cpp

    r202645 r202845  
    11/*
    22 * Copyright (C) 2010, Google Inc. All rights reserved.
     3 * Copyright (C) 2016, Apple Inc. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    132133    size_t bufferLength = buffer->length();
    133134
    134     // The current implementation supports up to four channel impulse responses, which are interpreted as true-stereo (see Reverb class).
    135     bool isBufferGood = numberOfChannels > 0 && numberOfChannels <= 4 && bufferLength;
    136     ASSERT(isBufferGood);
    137     if (!isBufferGood)
     135    // The current implementation supports only 1-, 2-, or 4-channel impulse responses, with the
     136    // 4-channel response being interpreted as true-stereo (see Reverb class).
     137    bool isChannelCountGood = (numberOfChannels == 1 || numberOfChannels == 2 || numberOfChannels == 4) && bufferLength;
     138
     139    if (!isChannelCountGood) {
     140        ec = NOT_SUPPORTED_ERR;
    138141        return;
     142    }
    139143
    140144    // Wrap the AudioBuffer by an AudioBus. It's an efficient pointer set and not a memcpy().
  • trunk/Source/WebCore/platform/audio/ReverbConvolverStage.cpp

    r165676 r202845  
    5858        m_fftConvolver = std::make_unique<FFTConvolver>(fftSize);
    5959    } else {
     60        ASSERT(!stageOffset);
     61        ASSERT(stageLength <= fftSize / 2);
     62
    6063        m_directKernel = std::make_unique<AudioFloatArray>(fftSize / 2);
    61         m_directKernel->copyToRange(impulseResponse + stageOffset, 0, fftSize / 2);
     64        m_directKernel->copyToRange(impulseResponse, 0, stageLength);
    6265        m_directConvolver = std::make_unique<DirectConvolver>(renderSliceSize);
    6366    }
Note: See TracChangeset for help on using the changeset viewer.