chromium/media/base/audio_hash.h

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_BASE_AUDIO_HASH_H_
#define MEDIA_BASE_AUDIO_HASH_H_

#include <stddef.h>
#include <stdint.h>

#include <string>

#include "media/base/media_export.h"

namespace media {

class AudioBus;

// Computes a running hash for a series of AudioBus objects.  The hash is the
// sum of each sample bucketed based on the frame index, channel number, and
// current hash count.  The hash was designed with two properties in mind:
//
//   1. Uniform error distribution across the input sample.
//   2. Resilience to error below a certain threshold.
//
// The first is achieved by using a simple summing approach and moving position
// weighting into the bucket choice.  The second is handled during conversion to
// string by rounding out values to only two decimal places.
//
// Using only two decimal places allows for roughly -40 dBFS of error.  For
// reference, SincResampler produces an RMS error of around -15 dBFS.  See
// http://en.wikipedia.org/wiki/DBFS and http://crbug.com/168204 for more info.
class MEDIA_EXPORT AudioHash {};

}  // namespace media

#endif  // MEDIA_BASE_AUDIO_HASH_H_