chromium/media/gpu/exponential_moving_average.h

// Copyright 2023 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_GPU_EXPONENTIAL_MOVING_AVERAGE_H_
#define MEDIA_GPU_EXPONENTIAL_MOVING_AVERAGE_H_

#include <algorithm>
#include <memory>

#include "base/time/time.h"
#include "media/gpu/media_gpu_export.h"

namespace media {

// An Exponential Moving Average filter.
// It is an implementation of exponential moving average filter with a time
// constant. The effective window size equals to the time elapsed since the
// first sample was added, until the maximum window size is reached. This makes
// a difference to the standard exponential moving average filter
// implementation. Alpha, the time constant, is calculated as a ratio between
// the time period passed from the last added sample and the effective window
// size.
//     mean += alpha * (value - mean)
//     mean_square += alpha * (value^2 - mean_square)
//     std_dev = sqrt(mean_square - mean^2)
//     alpha = elapsed_time / curr_window_size
class MEDIA_GPU_EXPORT ExponentialMovingAverage {};

}  // namespace media

#endif  // MEDIA_GPU_EXPONENTIAL_MOVING_AVERAGE_H_