OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_BASE_AUDIO_HASH_H_ | 5 #ifndef MEDIA_BASE_AUDIO_HASH_H_ |
6 #define MEDIA_BASE_AUDIO_HASH_H_ | 6 #define MEDIA_BASE_AUDIO_HASH_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 public: | 36 public: |
37 AudioHash(); | 37 AudioHash(); |
38 ~AudioHash(); | 38 ~AudioHash(); |
39 | 39 |
40 // Update current hash with the contents of the provided AudioBus. | 40 // Update current hash with the contents of the provided AudioBus. |
41 void Update(const AudioBus* audio_bus, int frames); | 41 void Update(const AudioBus* audio_bus, int frames); |
42 | 42 |
43 // Return a string representation of the current hash. | 43 // Return a string representation of the current hash. |
44 std::string ToString() const; | 44 std::string ToString() const; |
45 | 45 |
| 46 // Compare with another hash value given as string representation. |
| 47 // Returns true if for every bucket the difference between this and |
| 48 // other is less than tolerance. |
| 49 bool IsEquivalent(const std::string& other, double tolerance) const; |
| 50 |
46 private: | 51 private: |
47 // Storage for the audio hash. The number of buckets controls the importance | 52 // Storage for the audio hash. The number of buckets controls the importance |
48 // of position in the hash. A higher number reduces the chance of false | 53 // of position in the hash. A higher number reduces the chance of false |
49 // positives related to incorrect sample position. Value chosen by dice roll. | 54 // positives related to incorrect sample position. Value chosen by dice roll. |
50 float audio_hash_[6]; | 55 float audio_hash_[6]; |
51 | 56 |
52 // The total number of samples processed per channel. Uses a uint32_t instead | 57 // The total number of samples processed per channel. Uses a uint32_t instead |
53 // of size_t so overflows on 64-bit and 32-bit machines are equivalent. | 58 // of size_t so overflows on 64-bit and 32-bit machines are equivalent. |
54 uint32_t sample_count_; | 59 uint32_t sample_count_; |
55 | 60 |
56 DISALLOW_COPY_AND_ASSIGN(AudioHash); | 61 DISALLOW_COPY_AND_ASSIGN(AudioHash); |
57 }; | 62 }; |
58 | 63 |
59 } // namespace media | 64 } // namespace media |
60 | 65 |
61 #endif // MEDIA_BASE_AUDIO_HASH_H_ | 66 #endif // MEDIA_BASE_AUDIO_HASH_H_ |
OLD | NEW |