Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Side by Side Diff: third_party/WebKit/Source/platform/audio/HRTFPanner.cpp

Issue 2807593003: Revert of Convert RELEASE_ASSERT()/ASSERT(...) to CHECK()/DCHECK_op(...) in platform/audio (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010, Google Inc. All rights reserved. 2 * Copyright (C) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 if (desiredAzimuthIndex != m_azimuthIndex2 || elevation != m_elevation2) { 203 if (desiredAzimuthIndex != m_azimuthIndex2 || elevation != m_elevation2) {
204 // Cross-fade from 2 -> 1 204 // Cross-fade from 2 -> 1
205 m_crossfadeIncr = -1 / fadeFrames; 205 m_crossfadeIncr = -1 / fadeFrames;
206 m_azimuthIndex1 = desiredAzimuthIndex; 206 m_azimuthIndex1 = desiredAzimuthIndex;
207 m_elevation1 = elevation; 207 m_elevation1 = elevation;
208 } 208 }
209 } 209 }
210 210
211 // This algorithm currently requires that we process in power-of-two size 211 // This algorithm currently requires that we process in power-of-two size
212 // chunks at least AudioUtilities::kRenderQuantumFrames. 212 // chunks at least AudioUtilities::kRenderQuantumFrames.
213 DCHECK_EQ(1UL << static_cast<int>(log2(framesToProcess)), framesToProcess); 213 ASSERT(1UL << static_cast<int>(log2(framesToProcess)) == framesToProcess);
214 DCHECK_GE(framesToProcess, AudioUtilities::kRenderQuantumFrames); 214 DCHECK_GE(framesToProcess, AudioUtilities::kRenderQuantumFrames);
215 215
216 const unsigned framesPerSegment = AudioUtilities::kRenderQuantumFrames; 216 const unsigned framesPerSegment = AudioUtilities::kRenderQuantumFrames;
217 const unsigned numberOfSegments = framesToProcess / framesPerSegment; 217 const unsigned numberOfSegments = framesToProcess / framesPerSegment;
218 218
219 for (unsigned segment = 0; segment < numberOfSegments; ++segment) { 219 for (unsigned segment = 0; segment < numberOfSegments; ++segment) {
220 // Get the HRTFKernels and interpolated delays. 220 // Get the HRTFKernels and interpolated delays.
221 HRTFKernel* kernelL1; 221 HRTFKernel* kernelL1;
222 HRTFKernel* kernelR1; 222 HRTFKernel* kernelR1;
223 HRTFKernel* kernelL2; 223 HRTFKernel* kernelL2;
224 HRTFKernel* kernelR2; 224 HRTFKernel* kernelR2;
225 double frameDelayL1; 225 double frameDelayL1;
226 double frameDelayR1; 226 double frameDelayR1;
227 double frameDelayL2; 227 double frameDelayL2;
228 double frameDelayR2; 228 double frameDelayR2;
229 database->getKernelsFromAzimuthElevation(azimuthBlend, m_azimuthIndex1, 229 database->getKernelsFromAzimuthElevation(azimuthBlend, m_azimuthIndex1,
230 m_elevation1, kernelL1, kernelR1, 230 m_elevation1, kernelL1, kernelR1,
231 frameDelayL1, frameDelayR1); 231 frameDelayL1, frameDelayR1);
232 database->getKernelsFromAzimuthElevation(azimuthBlend, m_azimuthIndex2, 232 database->getKernelsFromAzimuthElevation(azimuthBlend, m_azimuthIndex2,
233 m_elevation2, kernelL2, kernelR2, 233 m_elevation2, kernelL2, kernelR2,
234 frameDelayL2, frameDelayR2); 234 frameDelayL2, frameDelayR2);
235 235
236 bool areKernelsGood = kernelL1 && kernelR1 && kernelL2 && kernelR2; 236 bool areKernelsGood = kernelL1 && kernelR1 && kernelL2 && kernelR2;
237 DCHECK(areKernelsGood); 237 DCHECK(areKernelsGood);
238 if (!areKernelsGood) { 238 if (!areKernelsGood) {
239 outputBus->zero(); 239 outputBus->zero();
240 return; 240 return;
241 } 241 }
242 242
243 DCHECK_LT(frameDelayL1 / sampleRate(), MaxDelayTimeSeconds); 243 ASSERT(frameDelayL1 / sampleRate() < MaxDelayTimeSeconds &&
244 DCHECK_LT(frameDelayR1 / sampleRate(), MaxDelayTimeSeconds); 244 frameDelayR1 / sampleRate() < MaxDelayTimeSeconds);
245 DCHECK_LT(frameDelayL2 / sampleRate(), MaxDelayTimeSeconds); 245 ASSERT(frameDelayL2 / sampleRate() < MaxDelayTimeSeconds &&
246 DCHECK_LT(frameDelayR2 / sampleRate(), MaxDelayTimeSeconds); 246 frameDelayR2 / sampleRate() < MaxDelayTimeSeconds);
247 247
248 // Crossfade inter-aural delays based on transitions. 248 // Crossfade inter-aural delays based on transitions.
249 double frameDelayL = 249 double frameDelayL =
250 (1 - m_crossfadeX) * frameDelayL1 + m_crossfadeX * frameDelayL2; 250 (1 - m_crossfadeX) * frameDelayL1 + m_crossfadeX * frameDelayL2;
251 double frameDelayR = 251 double frameDelayR =
252 (1 - m_crossfadeX) * frameDelayR1 + m_crossfadeX * frameDelayR2; 252 (1 - m_crossfadeX) * frameDelayR1 + m_crossfadeX * frameDelayR2;
253 253
254 // Calculate the source and destination pointers for the current segment. 254 // Calculate the source and destination pointers for the current segment.
255 unsigned offset = segment * framesPerSegment; 255 unsigned offset = segment * framesPerSegment;
256 const float* segmentSourceL = sourceL + offset; 256 const float* segmentSourceL = sourceL + offset;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 (fftSize() / 2) / static_cast<double>(sampleRate()); 353 (fftSize() / 2) / static_cast<double>(sampleRate());
354 } 354 }
355 355
356 double HRTFPanner::latencyTime() const { 356 double HRTFPanner::latencyTime() const {
357 // The latency of a FFTConvolver is also fftSize() / 2, and is in addition to 357 // The latency of a FFTConvolver is also fftSize() / 2, and is in addition to
358 // its tailTime of the same value. 358 // its tailTime of the same value.
359 return (fftSize() / 2) / static_cast<double>(sampleRate()); 359 return (fftSize() / 2) / static_cast<double>(sampleRate());
360 } 360 }
361 361
362 } // namespace blink 362 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/audio/HRTFKernel.cpp ('k') | third_party/WebKit/Source/platform/audio/IIRFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698