Commit b4f0f6a6 authored by hongchan's avatar hongchan Committed by Commit bot

Revert of Convert RELEASE_ASSERT()/ASSERT(...) to CHECK()/DCHECK_op(...) in...

Revert of Convert RELEASE_ASSERT()/ASSERT(...) to CHECK()/DCHECK_op(...) in platform/audio (patchset #3 id:40001 of https://codereview.chromium.org/2803073002/ )

Reason for revert:
Unexpected compilation error from buildbot Android Builder.

Original issue's description:
> Convert RELEASE_ASSERT()/ASSERT(...) to CHECK()/DCHECK_op(...) in platform/audio
>
> This CL is the second part of the conversion. It manually replaces:
>
>  - RELEASE_ASSERT() with CHECK().
>  - ASSERT(...args) with one or more DCHECK_op(arg).
>
> With this CL the following script returns 0 result.
>
> ```
> cd ${CHROME_SRC}/third_party/WebKit/Source/platform/audio
> grep -rnw . -e 'ASSERT('
> ```
>
> BUG=707655
>
> Review-Url: https://codereview.chromium.org/2803073002
> Cr-Commit-Position: refs/heads/master@{#462904}
> Committed: https://chromium.googlesource.com/chromium/src/+/f90cae07269c724f98ca3c196ea37ce7f6a801d5

TBR=rtoy@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=707655

Review-Url: https://codereview.chromium.org/2807593003
Cr-Commit-Position: refs/heads/master@{#462908}
parent 57176067
...@@ -58,7 +58,7 @@ class AudioArray { ...@@ -58,7 +58,7 @@ class AudioArray {
// Although n is a size_t, its true limit is max unsigned because we use // Although n is a size_t, its true limit is max unsigned because we use
// unsigned in zeroRange() and copyToRange(). Also check for integer // unsigned in zeroRange() and copyToRange(). Also check for integer
// overflow. // overflow.
CHECK_LE(n, std::numeric_limits<unsigned>::max() / sizeof(T)); RELEASE_ASSERT(n <= std::numeric_limits<unsigned>::max() / sizeof(T));
unsigned initialSize = sizeof(T) * n; unsigned initialSize = sizeof(T) * n;
...@@ -79,12 +79,12 @@ class AudioArray { ...@@ -79,12 +79,12 @@ class AudioArray {
static size_t extraAllocationBytes = 0; static size_t extraAllocationBytes = 0;
// Again, check for integer overflow. // Again, check for integer overflow.
CHECK_GE(initialSize + extraAllocationBytes, initialSize); RELEASE_ASSERT(initialSize + extraAllocationBytes >= initialSize);
T* allocation = static_cast<T*>(WTF::Partitions::fastMalloc( T* allocation = static_cast<T*>(WTF::Partitions::fastMalloc(
initialSize + extraAllocationBytes, initialSize + extraAllocationBytes,
WTF_HEAP_PROFILER_TYPE_NAME(AudioArray<T>))); WTF_HEAP_PROFILER_TYPE_NAME(AudioArray<T>)));
CHECK(allocation); RELEASE_ASSERT(allocation);
T* alignedData = alignedAddress(allocation, alignment); T* alignedData = alignedAddress(allocation, alignment);
......
...@@ -49,7 +49,7 @@ const unsigned MaxBusChannels = 32; ...@@ -49,7 +49,7 @@ const unsigned MaxBusChannels = 32;
PassRefPtr<AudioBus> AudioBus::create(unsigned numberOfChannels, PassRefPtr<AudioBus> AudioBus::create(unsigned numberOfChannels,
size_t length, size_t length,
bool allocate) { bool allocate) {
DCHECK_LE(numberOfChannels, MaxBusChannels); ASSERT(numberOfChannels <= MaxBusChannels);
if (numberOfChannels > MaxBusChannels) if (numberOfChannels > MaxBusChannels)
return nullptr; return nullptr;
...@@ -81,7 +81,7 @@ void AudioBus::setChannelMemory(unsigned channelIndex, ...@@ -81,7 +81,7 @@ void AudioBus::setChannelMemory(unsigned channelIndex,
} }
void AudioBus::resizeSmaller(size_t newLength) { void AudioBus::resizeSmaller(size_t newLength) {
DCHECK_LE(newLength, m_length); ASSERT(newLength <= m_length);
if (newLength <= m_length) if (newLength <= m_length)
m_length = newLength; m_length = newLength;
...@@ -479,7 +479,7 @@ void AudioBus::copyWithGainFrom(const AudioBus& sourceBus, ...@@ -479,7 +479,7 @@ void AudioBus::copyWithGainFrom(const AudioBus& sourceBus,
} }
unsigned numberOfChannels = this->numberOfChannels(); unsigned numberOfChannels = this->numberOfChannels();
DCHECK_LE(numberOfChannels, MaxBusChannels); ASSERT(numberOfChannels <= MaxBusChannels);
if (numberOfChannels > MaxBusChannels) if (numberOfChannels > MaxBusChannels)
return; return;
...@@ -615,8 +615,7 @@ PassRefPtr<AudioBus> AudioBus::createBySampleRateConverting( ...@@ -615,8 +615,7 @@ PassRefPtr<AudioBus> AudioBus::createBySampleRateConverting(
bool mixToMono, bool mixToMono,
double newSampleRate) { double newSampleRate) {
// sourceBus's sample-rate must be known. // sourceBus's sample-rate must be known.
DCHECK(sourceBus); ASSERT(sourceBus && sourceBus->sampleRate());
DCHECK(sourceBus->sampleRate());
if (!sourceBus || !sourceBus->sampleRate()) if (!sourceBus || !sourceBus->sampleRate())
return nullptr; return nullptr;
......
...@@ -36,7 +36,7 @@ namespace blink { ...@@ -36,7 +36,7 @@ namespace blink {
using namespace VectorMath; using namespace VectorMath;
void AudioChannel::resizeSmaller(size_t newLength) { void AudioChannel::resizeSmaller(size_t newLength) {
DCHECK_LE(newLength, m_length); ASSERT(newLength <= m_length);
if (newLength <= m_length) if (newLength <= m_length)
m_length = newLength; m_length = newLength;
} }
......
...@@ -67,8 +67,7 @@ void AudioDSPKernelProcessor::uninitialize() { ...@@ -67,8 +67,7 @@ void AudioDSPKernelProcessor::uninitialize() {
void AudioDSPKernelProcessor::process(const AudioBus* source, void AudioDSPKernelProcessor::process(const AudioBus* source,
AudioBus* destination, AudioBus* destination,
size_t framesToProcess) { size_t framesToProcess) {
DCHECK(source); ASSERT(source && destination);
DCHECK(destination);
if (!source || !destination) if (!source || !destination)
return; return;
......
...@@ -45,8 +45,7 @@ AudioDelayDSPKernel::AudioDelayDSPKernel(double maxDelayTime, float sampleRate) ...@@ -45,8 +45,7 @@ AudioDelayDSPKernel::AudioDelayDSPKernel(double maxDelayTime, float sampleRate)
m_maxDelayTime(maxDelayTime), m_maxDelayTime(maxDelayTime),
m_writeIndex(0), m_writeIndex(0),
m_firstTime(true) { m_firstTime(true) {
DCHECK_GT(maxDelayTime, 0.0); ASSERT(maxDelayTime > 0.0 && !std::isnan(maxDelayTime));
DCHECK(!std::isnan(maxDelayTime));
if (maxDelayTime <= 0.0 || std::isnan(maxDelayTime)) if (maxDelayTime <= 0.0 || std::isnan(maxDelayTime))
return; return;
...@@ -92,8 +91,7 @@ void AudioDelayDSPKernel::process(const float* source, ...@@ -92,8 +91,7 @@ void AudioDelayDSPKernel::process(const float* source,
if (!bufferLength) if (!bufferLength)
return; return;
DCHECK(source); ASSERT(source && destination);
DCHECK(destination);
if (!source || !destination) if (!source || !destination)
return; return;
......
...@@ -46,7 +46,7 @@ AudioResamplerKernel::AudioResamplerKernel(AudioResampler* resampler) ...@@ -46,7 +46,7 @@ AudioResamplerKernel::AudioResamplerKernel(AudioResampler* resampler)
float* AudioResamplerKernel::getSourcePointer( float* AudioResamplerKernel::getSourcePointer(
size_t framesToProcess, size_t framesToProcess,
size_t* numberOfSourceFramesNeededP) { size_t* numberOfSourceFramesNeededP) {
DCHECK_LE(framesToProcess, MaxFramesToProcess); ASSERT(framesToProcess <= MaxFramesToProcess);
// Calculate the next "virtual" index. After process() is called, // Calculate the next "virtual" index. After process() is called,
// m_virtualReadIndex will equal this value. // m_virtualReadIndex will equal this value.
...@@ -75,7 +75,7 @@ float* AudioResamplerKernel::getSourcePointer( ...@@ -75,7 +75,7 @@ float* AudioResamplerKernel::getSourcePointer(
} }
void AudioResamplerKernel::process(float* destination, size_t framesToProcess) { void AudioResamplerKernel::process(float* destination, size_t framesToProcess) {
DCHECK_LE(framesToProcess, MaxFramesToProcess); ASSERT(framesToProcess <= MaxFramesToProcess);
float* source = m_sourceBuffer.data(); float* source = m_sourceBuffer.data();
...@@ -92,11 +92,11 @@ void AudioResamplerKernel::process(float* destination, size_t framesToProcess) { ...@@ -92,11 +92,11 @@ void AudioResamplerKernel::process(float* destination, size_t framesToProcess) {
double virtualReadIndex = m_virtualReadIndex; double virtualReadIndex = m_virtualReadIndex;
// Sanity check source buffer access. // Sanity check source buffer access.
DCHECK_GT(framesToProcess, 0u); ASSERT(framesToProcess > 0);
DCHECK_GE(virtualReadIndex, 0); ASSERT(virtualReadIndex >= 0 &&
DCHECK_LT(1 + static_cast<unsigned>(virtualReadIndex + 1 + static_cast<unsigned>(virtualReadIndex +
(framesToProcess - 1) * rate), (framesToProcess - 1) * rate) <
m_sourceBuffer.size()); m_sourceBuffer.size());
// Do the linear interpolation. // Do the linear interpolation.
int n = framesToProcess; int n = framesToProcess;
......
...@@ -36,7 +36,7 @@ float decibelsToLinear(float decibels) { ...@@ -36,7 +36,7 @@ float decibelsToLinear(float decibels) {
} }
float linearToDecibels(float linear) { float linearToDecibels(float linear) {
DCHECK_GE(linear, 0); ASSERT(linear >= 0);
return 20 * log10f(linear); return 20 * log10f(linear);
} }
...@@ -47,7 +47,7 @@ double discreteTimeConstantForSampleRate(double timeConstant, ...@@ -47,7 +47,7 @@ double discreteTimeConstantForSampleRate(double timeConstant,
} }
size_t timeToSampleFrame(double time, double sampleRate) { size_t timeToSampleFrame(double time, double sampleRate) {
DCHECK_GE(time, 0); ASSERT(time >= 0);
double frame = round(time * sampleRate); double frame = round(time * sampleRate);
// Just return the largest possible size_t value if necessary. // Just return the largest possible size_t value if necessary.
......
...@@ -50,13 +50,13 @@ void DirectConvolver::process(AudioFloatArray* convolutionKernel, ...@@ -50,13 +50,13 @@ void DirectConvolver::process(AudioFloatArray* convolutionKernel,
const float* sourceP, const float* sourceP,
float* destP, float* destP,
size_t framesToProcess) { size_t framesToProcess) {
DCHECK_EQ(framesToProcess, m_inputBlockSize); ASSERT(framesToProcess == m_inputBlockSize);
if (framesToProcess != m_inputBlockSize) if (framesToProcess != m_inputBlockSize)
return; return;
// Only support kernelSize <= m_inputBlockSize // Only support kernelSize <= m_inputBlockSize
size_t kernelSize = convolutionKernel->size(); size_t kernelSize = convolutionKernel->size();
DCHECK_LE(kernelSize, m_inputBlockSize); ASSERT(kernelSize <= m_inputBlockSize);
if (kernelSize > m_inputBlockSize) if (kernelSize > m_inputBlockSize)
return; return;
......
...@@ -51,7 +51,7 @@ DynamicsCompressor::DynamicsCompressor(float sampleRate, ...@@ -51,7 +51,7 @@ DynamicsCompressor::DynamicsCompressor(float sampleRate,
} }
void DynamicsCompressor::setParameterValue(unsigned parameterID, float value) { void DynamicsCompressor::setParameterValue(unsigned parameterID, float value) {
DCHECK_LT(parameterID, static_cast<unsigned>(ParamLast)); ASSERT(parameterID < ParamLast);
if (parameterID < ParamLast) if (parameterID < ParamLast)
m_parameters[parameterID] = value; m_parameters[parameterID] = value;
} }
...@@ -84,7 +84,7 @@ void DynamicsCompressor::initializeParameters() { ...@@ -84,7 +84,7 @@ void DynamicsCompressor::initializeParameters() {
} }
float DynamicsCompressor::parameterValue(unsigned parameterID) { float DynamicsCompressor::parameterValue(unsigned parameterID) {
DCHECK_LT(parameterID, static_cast<unsigned>(ParamLast)); ASSERT(parameterID < ParamLast);
return m_parameters[parameterID]; return m_parameters[parameterID];
} }
...@@ -100,8 +100,7 @@ void DynamicsCompressor::process(const AudioBus* sourceBus, ...@@ -100,8 +100,7 @@ void DynamicsCompressor::process(const AudioBus* sourceBus,
unsigned numberOfChannels = destinationBus->numberOfChannels(); unsigned numberOfChannels = destinationBus->numberOfChannels();
unsigned numberOfSourceChannels = sourceBus->numberOfChannels(); unsigned numberOfSourceChannels = sourceBus->numberOfChannels();
DCHECK_EQ(numberOfChannels, m_numberOfChannels); ASSERT(numberOfChannels == m_numberOfChannels && numberOfSourceChannels);
DCHECK(numberOfSourceChannels);
if (numberOfChannels != m_numberOfChannels || !numberOfSourceChannels) { if (numberOfChannels != m_numberOfChannels || !numberOfSourceChannels) {
destinationBus->zero(); destinationBus->zero();
......
...@@ -216,7 +216,7 @@ void DynamicsCompressorKernel::process( ...@@ -216,7 +216,7 @@ void DynamicsCompressorKernel::process(
float releaseZone2, float releaseZone2,
float releaseZone3, float releaseZone3,
float releaseZone4) { float releaseZone4) {
DCHECK_EQ(m_preDelayBuffers.size(), numberOfChannels); ASSERT(m_preDelayBuffers.size() == numberOfChannels);
float sampleRate = this->sampleRate(); float sampleRate = this->sampleRate();
......
...@@ -76,7 +76,7 @@ HRTFDatabase::HRTFDatabase(float sampleRate) ...@@ -76,7 +76,7 @@ HRTFDatabase::HRTFDatabase(float sampleRate)
static_cast<float>(jj) / static_cast<float>(InterpolationFactor); static_cast<float>(jj) / static_cast<float>(InterpolationFactor);
m_elevations[i + jj] = HRTFElevation::createByInterpolatingSlices( m_elevations[i + jj] = HRTFElevation::createByInterpolatingSlices(
m_elevations[i].get(), m_elevations[j].get(), x, sampleRate); m_elevations[i].get(), m_elevations[j].get(), x, sampleRate);
DCHECK(m_elevations[i + jj].get()); ASSERT(m_elevations[i + jj].get());
} }
} }
} }
......
...@@ -52,7 +52,7 @@ HRTFDatabaseLoader::createAndLoadAsynchronouslyIfNecessary(float sampleRate) { ...@@ -52,7 +52,7 @@ HRTFDatabaseLoader::createAndLoadAsynchronouslyIfNecessary(float sampleRate) {
RefPtr<HRTFDatabaseLoader> loader = getLoaderMap().at(sampleRate); RefPtr<HRTFDatabaseLoader> loader = getLoaderMap().at(sampleRate);
if (loader) { if (loader) {
DCHECK_EQ(sampleRate, loader->databaseSampleRate()); ASSERT(sampleRate == loader->databaseSampleRate());
return loader.release(); return loader.release();
} }
......
...@@ -309,13 +309,11 @@ std::unique_ptr<HRTFElevation> HRTFElevation::createByInterpolatingSlices( ...@@ -309,13 +309,11 @@ std::unique_ptr<HRTFElevation> HRTFElevation::createByInterpolatingSlices(
HRTFElevation* hrtfElevation2, HRTFElevation* hrtfElevation2,
float x, float x,
float sampleRate) { float sampleRate) {
DCHECK(hrtfElevation1); ASSERT(hrtfElevation1 && hrtfElevation2);
DCHECK(hrtfElevation2);
if (!hrtfElevation1 || !hrtfElevation2) if (!hrtfElevation1 || !hrtfElevation2)
return nullptr; return nullptr;
DCHECK_GE(x, 0.0); ASSERT(x >= 0.0 && x < 1.0);
DCHECK_LT(x, 1.0);
std::unique_ptr<HRTFKernelList> kernelListL = std::unique_ptr<HRTFKernelList> kernelListL =
WTF::makeUnique<HRTFKernelList>(NumberOfTotalAzimuths); WTF::makeUnique<HRTFKernelList>(NumberOfTotalAzimuths);
......
...@@ -53,8 +53,8 @@ static float extractAverageGroupDelay(AudioChannel* channel, ...@@ -53,8 +53,8 @@ static float extractAverageGroupDelay(AudioChannel* channel,
return 0; return 0;
// Check for power-of-2. // Check for power-of-2.
DCHECK_EQ(1UL << static_cast<unsigned>(log2(analysisFFTSize)), ASSERT(1UL << static_cast<unsigned>(log2(analysisFFTSize)) ==
analysisFFTSize); analysisFFTSize);
FFTFrame estimationFrame(analysisFFTSize); FFTFrame estimationFrame(analysisFFTSize);
estimationFrame.doFFT(impulseP); estimationFrame.doFFT(impulseP);
...@@ -83,7 +83,7 @@ HRTFKernel::HRTFKernel(AudioChannel* channel, size_t fftSize, float sampleRate) ...@@ -83,7 +83,7 @@ HRTFKernel::HRTFKernel(AudioChannel* channel, size_t fftSize, float sampleRate)
// Quick fade-out (apply window) at truncation point // Quick fade-out (apply window) at truncation point
unsigned numberOfFadeOutFrames = static_cast<unsigned>( unsigned numberOfFadeOutFrames = static_cast<unsigned>(
sampleRate / 4410); // 10 sample-frames @44.1KHz sample-rate sampleRate / 4410); // 10 sample-frames @44.1KHz sample-rate
DCHECK_LT(numberOfFadeOutFrames, truncatedResponseLength); ASSERT(numberOfFadeOutFrames < truncatedResponseLength);
if (numberOfFadeOutFrames < truncatedResponseLength) { if (numberOfFadeOutFrames < truncatedResponseLength) {
for (unsigned i = truncatedResponseLength - numberOfFadeOutFrames; for (unsigned i = truncatedResponseLength - numberOfFadeOutFrames;
i < truncatedResponseLength; ++i) { i < truncatedResponseLength; ++i) {
...@@ -116,18 +116,16 @@ std::unique_ptr<HRTFKernel> HRTFKernel::createInterpolatedKernel( ...@@ -116,18 +116,16 @@ std::unique_ptr<HRTFKernel> HRTFKernel::createInterpolatedKernel(
HRTFKernel* kernel1, HRTFKernel* kernel1,
HRTFKernel* kernel2, HRTFKernel* kernel2,
float x) { float x) {
DCHECK(kernel1); ASSERT(kernel1 && kernel2);
DCHECK(kernel2);
if (!kernel1 || !kernel2) if (!kernel1 || !kernel2)
return nullptr; return nullptr;
DCHECK_GE(x, 0.0); ASSERT(x >= 0.0 && x < 1.0);
DCHECK_LT(x, 1.0);
x = clampTo(x, 0.0f, 1.0f); x = clampTo(x, 0.0f, 1.0f);
float sampleRate1 = kernel1->sampleRate(); float sampleRate1 = kernel1->sampleRate();
float sampleRate2 = kernel2->sampleRate(); float sampleRate2 = kernel2->sampleRate();
DCHECK_EQ(sampleRate1, sampleRate2); ASSERT(sampleRate1 == sampleRate2);
if (sampleRate1 != sampleRate2) if (sampleRate1 != sampleRate2)
return nullptr; return nullptr;
......
...@@ -210,7 +210,7 @@ void HRTFPanner::pan(double desiredAzimuth, ...@@ -210,7 +210,7 @@ void HRTFPanner::pan(double desiredAzimuth,
// This algorithm currently requires that we process in power-of-two size // This algorithm currently requires that we process in power-of-two size
// chunks at least AudioUtilities::kRenderQuantumFrames. // chunks at least AudioUtilities::kRenderQuantumFrames.
DCHECK_EQ(1UL << static_cast<int>(log2(framesToProcess)), framesToProcess); ASSERT(1UL << static_cast<int>(log2(framesToProcess)) == framesToProcess);
DCHECK_GE(framesToProcess, AudioUtilities::kRenderQuantumFrames); DCHECK_GE(framesToProcess, AudioUtilities::kRenderQuantumFrames);
const unsigned framesPerSegment = AudioUtilities::kRenderQuantumFrames; const unsigned framesPerSegment = AudioUtilities::kRenderQuantumFrames;
...@@ -240,10 +240,10 @@ void HRTFPanner::pan(double desiredAzimuth, ...@@ -240,10 +240,10 @@ void HRTFPanner::pan(double desiredAzimuth,
return; return;
} }
DCHECK_LT(frameDelayL1 / sampleRate(), MaxDelayTimeSeconds); ASSERT(frameDelayL1 / sampleRate() < MaxDelayTimeSeconds &&
DCHECK_LT(frameDelayR1 / sampleRate(), MaxDelayTimeSeconds); frameDelayR1 / sampleRate() < MaxDelayTimeSeconds);
DCHECK_LT(frameDelayL2 / sampleRate(), MaxDelayTimeSeconds); ASSERT(frameDelayL2 / sampleRate() < MaxDelayTimeSeconds &&
DCHECK_LT(frameDelayR2 / sampleRate(), MaxDelayTimeSeconds); frameDelayR2 / sampleRate() < MaxDelayTimeSeconds);
// Crossfade inter-aural delays based on transitions. // Crossfade inter-aural delays based on transitions.
double frameDelayL = double frameDelayL =
......
...@@ -65,7 +65,7 @@ void IIRFilter::process(const float* sourceP, ...@@ -65,7 +65,7 @@ void IIRFilter::process(const float* sourceP,
// Sanity check to see if the feedback coefficients have been scaled // Sanity check to see if the feedback coefficients have been scaled
// appropriately. It must be EXACTLY 1! // appropriately. It must be EXACTLY 1!
DCHECK_EQ(feedback[0], 1); ASSERT(feedback[0] == 1);
int feedbackLength = m_feedback->size(); int feedbackLength = m_feedback->size();
int feedforwardLength = m_feedforward->size(); int feedforwardLength = m_feedforward->size();
......
...@@ -74,7 +74,7 @@ class ChannelProvider final : public AudioSourceProvider { ...@@ -74,7 +74,7 @@ class ChannelProvider final : public AudioSourceProvider {
return; return;
// Copy the channel data from what we received from m_multiChannelProvider. // Copy the channel data from what we received from m_multiChannelProvider.
DCHECK_LE(m_currentChannel, m_numberOfChannels); ASSERT(m_currentChannel <= m_numberOfChannels);
if (m_currentChannel < m_numberOfChannels) { if (m_currentChannel < m_numberOfChannels) {
memcpy(bus->channel(0)->mutableData(), memcpy(bus->channel(0)->mutableData(),
m_multiChannelBus->channel(m_currentChannel)->data(), m_multiChannelBus->channel(m_currentChannel)->data(),
......
...@@ -61,7 +61,7 @@ ReverbConvolverStage::ReverbConvolverStage( ...@@ -61,7 +61,7 @@ ReverbConvolverStage::ReverbConvolverStage(
m_fftConvolver = WTF::makeUnique<FFTConvolver>(fftSize); m_fftConvolver = WTF::makeUnique<FFTConvolver>(fftSize);
} else { } else {
DCHECK(!stageOffset); DCHECK(!stageOffset);
DCHECK_LE(stageLength, fftSize / 2); ASSERT(stageLength <= fftSize / 2);
m_directKernel = WTF::wrapUnique(new AudioFloatArray(fftSize / 2)); m_directKernel = WTF::wrapUnique(new AudioFloatArray(fftSize / 2));
m_directKernel->copyToRange(impulseResponse, 0, stageLength); m_directKernel->copyToRange(impulseResponse, 0, stageLength);
...@@ -77,7 +77,7 @@ ReverbConvolverStage::ReverbConvolverStage( ...@@ -77,7 +77,7 @@ ReverbConvolverStage::ReverbConvolverStage(
// this out... // this out...
size_t halfSize = fftSize / 2; size_t halfSize = fftSize / 2;
if (!m_directMode) { if (!m_directMode) {
DCHECK_GE(totalDelay, halfSize); ASSERT(totalDelay >= halfSize);
if (totalDelay >= halfSize) if (totalDelay >= halfSize)
totalDelay -= halfSize; totalDelay -= halfSize;
} }
...@@ -177,7 +177,7 @@ void ReverbConvolverStage::process(const float* source, ...@@ -177,7 +177,7 @@ void ReverbConvolverStage::process(const float* source,
memcpy(preDelayedDestination, source, sizeof(float) * framesToProcess); memcpy(preDelayedDestination, source, sizeof(float) * framesToProcess);
m_preReadWriteIndex += framesToProcess; m_preReadWriteIndex += framesToProcess;
DCHECK_LE(m_preReadWriteIndex, m_preDelayLength); ASSERT(m_preReadWriteIndex <= m_preDelayLength);
if (m_preReadWriteIndex >= m_preDelayLength) if (m_preReadWriteIndex >= m_preDelayLength)
m_preReadWriteIndex = 0; m_preReadWriteIndex = 0;
} }
......
...@@ -44,7 +44,7 @@ void ReverbInputBuffer::write(const float* sourceP, size_t numberOfFrames) { ...@@ -44,7 +44,7 @@ void ReverbInputBuffer::write(const float* sourceP, size_t numberOfFrames) {
sizeof(float) * numberOfFrames); sizeof(float) * numberOfFrames);
m_writeIndex += numberOfFrames; m_writeIndex += numberOfFrames;
DCHECK_LE(m_writeIndex, bufferLength); ASSERT(m_writeIndex <= bufferLength);
if (m_writeIndex >= bufferLength) if (m_writeIndex >= bufferLength)
m_writeIndex = 0; m_writeIndex = 0;
......
...@@ -156,8 +156,7 @@ class BufferSourceProvider final : public AudioSourceProvider { ...@@ -156,8 +156,7 @@ class BufferSourceProvider final : public AudioSourceProvider {
// Consumes samples from the in-memory buffer. // Consumes samples from the in-memory buffer.
void provideInput(AudioBus* bus, size_t framesToProcess) override { void provideInput(AudioBus* bus, size_t framesToProcess) override {
DCHECK(m_source); ASSERT(m_source && bus);
DCHECK(bus);
if (!m_source || !bus) if (!m_source || !bus)
return; return;
......
...@@ -49,7 +49,7 @@ FFTFrame::FFTFrame(unsigned fftSize) ...@@ -49,7 +49,7 @@ FFTFrame::FFTFrame(unsigned fftSize)
m_inverseContext(nullptr), m_inverseContext(nullptr),
m_complexData(fftSize) { m_complexData(fftSize) {
// We only allow power of two. // We only allow power of two.
DCHECK_EQ(1UL << m_log2FFTSize, m_FFTSize); ASSERT(1UL << m_log2FFTSize == m_FFTSize);
m_forwardContext = contextForSize(m_log2FFTSize); m_forwardContext = contextForSize(m_log2FFTSize);
m_inverseContext = contextForSize(m_log2FFTSize); m_inverseContext = contextForSize(m_log2FFTSize);
...@@ -143,7 +143,7 @@ void FFTFrame::doInverseFFT(float* data) { ...@@ -143,7 +143,7 @@ void FFTFrame::doInverseFFT(float* data) {
OMXFFTSpec_R_F32* FFTFrame::contextForSize(unsigned log2FFTSize) { OMXFFTSpec_R_F32* FFTFrame::contextForSize(unsigned log2FFTSize) {
DCHECK(log2FFTSize); DCHECK(log2FFTSize);
DCHECK_LE(log2FFTSize, kMaxFFTPow2Size); ASSERT(log2FFTSize <= kMaxFFTPow2Size);
int bufSize; int bufSize;
OMXResult status = omxSP_FFTGetBufSize_R_F32(log2FFTSize, &bufSize); OMXResult status = omxSP_FFTGetBufSize_R_F32(log2FFTSize, &bufSize);
......
...@@ -42,9 +42,11 @@ extern "C" { ...@@ -42,9 +42,11 @@ extern "C" {
namespace blink { namespace blink {
#if DCHECK_IS_ON()
// Max FFT size for FFMPEG. WebAudio currently only uses FFTs up to size 15 // Max FFT size for FFMPEG. WebAudio currently only uses FFTs up to size 15
// (2^15 points). // (2^15 points).
const int kMaxFFTPow2Size = 16; const int kMaxFFTPow2Size = 16;
#endif
// Normal constructor: allocates for a given fftSize. // Normal constructor: allocates for a given fftSize.
FFTFrame::FFTFrame(unsigned fftSize) FFTFrame::FFTFrame(unsigned fftSize)
...@@ -56,7 +58,7 @@ FFTFrame::FFTFrame(unsigned fftSize) ...@@ -56,7 +58,7 @@ FFTFrame::FFTFrame(unsigned fftSize)
m_inverseContext(nullptr), m_inverseContext(nullptr),
m_complexData(fftSize) { m_complexData(fftSize) {
// We only allow power of two. // We only allow power of two.
DCHECK_EQ(1UL << m_log2FFTSize, m_FFTSize); ASSERT(1UL << m_log2FFTSize == m_FFTSize);
m_forwardContext = contextForSize(fftSize, DFT_R2C); m_forwardContext = contextForSize(fftSize, DFT_R2C);
m_inverseContext = contextForSize(fftSize, IDFT_C2R); m_inverseContext = contextForSize(fftSize, IDFT_C2R);
...@@ -155,7 +157,7 @@ RDFTContext* FFTFrame::contextForSize(unsigned fftSize, int trans) { ...@@ -155,7 +157,7 @@ RDFTContext* FFTFrame::contextForSize(unsigned fftSize, int trans) {
// by sharing the FFTFrames on a per-thread basis. // by sharing the FFTFrames on a per-thread basis.
DCHECK(fftSize); DCHECK(fftSize);
int pow2size = static_cast<int>(log2(fftSize)); int pow2size = static_cast<int>(log2(fftSize));
DCHECK_LT(pow2size, kMaxFFTPow2Size); ASSERT(pow2size < kMaxFFTPow2Size);
RDFTContext* context = av_rdft_init(pow2size, (RDFTransformType)trans); RDFTContext* context = av_rdft_init(pow2size, (RDFTransformType)trans);
return context; return context;
......
...@@ -47,8 +47,8 @@ FFTFrame::FFTFrame(unsigned fftSize) ...@@ -47,8 +47,8 @@ FFTFrame::FFTFrame(unsigned fftSize)
m_imagData(fftSize / 2), m_imagData(fftSize / 2),
m_complexData(fftSize) { m_complexData(fftSize) {
// We only allow power of two. // We only allow power of two.
DCHECK_EQ(1UL << m_log2FFTSize, m_FFTSize); ASSERT(1UL << m_log2FFTSize == m_FFTSize);
DCHECK_LE(m_log2FFTSize, maximumFFTPower2Size); ASSERT(m_log2FFTSize <= maximumFFTPower2Size);
ippsDFTInitAlloc_R_32f(&m_DFTSpec, m_FFTSize, IPP_FFT_NODIV_BY_ANY, ippsDFTInitAlloc_R_32f(&m_DFTSpec, m_FFTSize, IPP_FFT_NODIV_BY_ANY,
ippAlgHintFast); ippAlgHintFast);
......
...@@ -49,7 +49,7 @@ FFTFrame::FFTFrame(unsigned fftSize) ...@@ -49,7 +49,7 @@ FFTFrame::FFTFrame(unsigned fftSize)
m_log2FFTSize = static_cast<unsigned>(log2(fftSize)); m_log2FFTSize = static_cast<unsigned>(log2(fftSize));
// We only allow power of two // We only allow power of two
DCHECK_EQ(1UL << m_log2FFTSize, m_FFTSize); ASSERT(1UL << m_log2FFTSize == m_FFTSize);
// Lazily create and share fftSetup with other frames // Lazily create and share fftSetup with other frames
m_FFTSetup = fftSetupForSize(fftSize); m_FFTSetup = fftSetupForSize(fftSize);
...@@ -116,7 +116,7 @@ FFTSetup FFTFrame::fftSetupForSize(unsigned fftSize) { ...@@ -116,7 +116,7 @@ FFTSetup FFTFrame::fftSetupForSize(unsigned fftSize) {
} }
int pow2size = static_cast<int>(log2(fftSize)); int pow2size = static_cast<int>(log2(fftSize));
DCHECK_LT(pow2size, kMaxFFTPow2Size); ASSERT(pow2size < kMaxFFTPow2Size);
if (!fftSetups[pow2size]) if (!fftSetups[pow2size])
fftSetups[pow2size] = vDSP_create_fftsetup(pow2size, FFT_RADIX2); fftSetups[pow2size] = vDSP_create_fftsetup(pow2size, FFT_RADIX2);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment