diff options
Diffstat (limited to 'chromium/media/base/audio_hash.cc')
-rw-r--r-- | chromium/media/base/audio_hash.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/chromium/media/base/audio_hash.cc b/chromium/media/base/audio_hash.cc index d879e545362..7f133dd78ba 100644 --- a/chromium/media/base/audio_hash.cc +++ b/chromium/media/base/audio_hash.cc @@ -5,6 +5,7 @@ // MSVC++ requires this to be set before any other includes to get M_PI. #define _USE_MATH_DEFINES #include <cmath> +#include <sstream> #include "media/base/audio_hash.h" @@ -52,4 +53,17 @@ std::string AudioHash::ToString() const { return result; } +bool AudioHash::IsEquivalent(const std::string& other, double tolerance) const { + float other_hash; + char comma; + + std::stringstream is(other); + for (size_t i = 0; i < arraysize(audio_hash_); ++i) { + is >> other_hash >> comma; + if (fabs(audio_hash_[i] - other_hash) > tolerance) + return false; + } + return true; +} + } // namespace media |