| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
| 12 #include "media/base/media_export.h" | 11 #include "media/base/media_export.h" |
| 13 | 12 |
| 14 namespace media { | 13 namespace media { |
| 15 | 14 |
| 16 class AudioBus; | 15 class AudioBus; |
| 17 | 16 |
| 18 // Computes a running hash for a series of AudioBus objects. The hash is the | 17 // Computes a running hash for a series of AudioBus objects. The hash is the |
| 19 // sum of each sample bucketed based on the frame index, channel number, and | 18 // sum of each sample bucketed based on the frame index, channel number, and |
| 20 // current hash count. The hash was designed with two properties in mind: | 19 // current hash count. The hash was designed with two properties in mind: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 39 | 38 |
| 40 // Return a string representation of the current hash. | 39 // Return a string representation of the current hash. |
| 41 std::string ToString() const; | 40 std::string ToString() const; |
| 42 | 41 |
| 43 private: | 42 private: |
| 44 // Storage for the audio hash. The number of buckets controls the importance | 43 // Storage for the audio hash. The number of buckets controls the importance |
| 45 // of position in the hash. A higher number reduces the chance of false | 44 // of position in the hash. A higher number reduces the chance of false |
| 46 // positives related to incorrect sample position. Value chosen by dice roll. | 45 // positives related to incorrect sample position. Value chosen by dice roll. |
| 47 float audio_hash_[6]; | 46 float audio_hash_[6]; |
| 48 | 47 |
| 49 // The total number of samples processed per channel. Uses a uint32 instead | 48 // The total number of samples processed per channel. Uses a uint32_t instead |
| 50 // of size_t so overflows on 64-bit and 32-bit machines are equivalent. | 49 // of size_t so overflows on 64-bit and 32-bit machines are equivalent. |
| 51 uint32 sample_count_; | 50 uint32_t sample_count_; |
| 52 | 51 |
| 53 DISALLOW_COPY_AND_ASSIGN(AudioHash); | 52 DISALLOW_COPY_AND_ASSIGN(AudioHash); |
| 54 }; | 53 }; |
| 55 | 54 |
| 56 } // namespace media | 55 } // namespace media |
| 57 | 56 |
| 58 #endif // MEDIA_BASE_AUDIO_HASH_H_ | 57 #endif // MEDIA_BASE_AUDIO_HASH_H_ |
| OLD | NEW |