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

Unified Diff: third_party/WebKit/Source/platform/audio/Biquad.cpp

Issue 1530723004: Use clampTo instead of chaining std::max(std::min(...)) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More rebase Created 5 years 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/audio/Biquad.cpp
diff --git a/third_party/WebKit/Source/platform/audio/Biquad.cpp b/third_party/WebKit/Source/platform/audio/Biquad.cpp
index 355c4d0a64496dc292e5c836a9c078ab3e04da08..ffa469f040d6eb8a85da362db14d3d2b4e98ca63 100644
--- a/third_party/WebKit/Source/platform/audio/Biquad.cpp
+++ b/third_party/WebKit/Source/platform/audio/Biquad.cpp
@@ -34,6 +34,7 @@
#include "platform/audio/DenormalDisabler.h"
#include "wtf/MathExtras.h"
+#include <complex>
#if OS(MACOSX)
#include <Accelerate/Accelerate.h>
#endif
@@ -206,7 +207,7 @@ void Biquad::reset()
void Biquad::setLowpassParams(double cutoff, double resonance)
{
// Limit cutoff to 0 to 1.
- cutoff = std::max(0.0, std::min(cutoff, 1.0));
+ cutoff = clampTo(cutoff, 0.0, 1.0);
if (cutoff == 1) {
// When cutoff is 1, the z-transform is 1.
@@ -242,7 +243,7 @@ void Biquad::setLowpassParams(double cutoff, double resonance)
void Biquad::setHighpassParams(double cutoff, double resonance)
{
// Limit cutoff to 0 to 1.
- cutoff = std::max(0.0, std::min(cutoff, 1.0));
+ cutoff = clampTo(cutoff, 0.0, 1.0);
if (cutoff == 1) {
// The z-transform is 0.
@@ -304,7 +305,7 @@ void Biquad::setNormalizedCoefficients(double b0, double b1, double b2, double a
void Biquad::setLowShelfParams(double frequency, double dbGain)
{
// Clip frequencies to between 0 and 1, inclusive.
- frequency = std::max(0.0, std::min(frequency, 1.0));
+ frequency = clampTo(frequency, 0.0, 1.0);
double A = pow(10.0, dbGain / 40);
@@ -339,7 +340,7 @@ void Biquad::setLowShelfParams(double frequency, double dbGain)
void Biquad::setHighShelfParams(double frequency, double dbGain)
{
// Clip frequencies to between 0 and 1, inclusive.
- frequency = std::max(0.0, std::min(frequency, 1.0));
+ frequency = clampTo(frequency, 0.0, 1.0);
double A = pow(10.0, dbGain / 40);
@@ -374,7 +375,7 @@ void Biquad::setHighShelfParams(double frequency, double dbGain)
void Biquad::setPeakingParams(double frequency, double Q, double dbGain)
{
// Clip frequencies to between 0 and 1, inclusive.
- frequency = std::max(0.0, std::min(frequency, 1.0));
+ frequency = clampTo(frequency, 0.0, 1.0);
// Don't let Q go negative, which causes an unstable filter.
Q = std::max(0.0, Q);
@@ -412,7 +413,7 @@ void Biquad::setPeakingParams(double frequency, double Q, double dbGain)
void Biquad::setAllpassParams(double frequency, double Q)
{
// Clip frequencies to between 0 and 1, inclusive.
- frequency = std::max(0.0, std::min(frequency, 1.0));
+ frequency = clampTo(frequency, 0.0, 1.0);
// Don't let Q go negative, which causes an unstable filter.
Q = std::max(0.0, Q);
@@ -448,7 +449,7 @@ void Biquad::setAllpassParams(double frequency, double Q)
void Biquad::setNotchParams(double frequency, double Q)
{
// Clip frequencies to between 0 and 1, inclusive.
- frequency = std::max(0.0, std::min(frequency, 1.0));
+ frequency = clampTo(frequency, 0.0, 1.0);
// Don't let Q go negative, which causes an unstable filter.
Q = std::max(0.0, Q);

Powered by Google App Engine
This is Rietveld 408576698