Home | History | Annotate | Download | only in include
      1 /*
      2  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 #ifndef WEBRTC_MODULES_VIDEO_CODING_UTILITY_INCLUDE_EXP_FILTER_H_
     12 #define WEBRTC_MODULES_VIDEO_CODING_UTILITY_INCLUDE_EXP_FILTER_H_
     13 
     14 namespace webrtc
     15 {
     16 
     17 /**********************/
     18 /* ExpFilter class    */
     19 /**********************/
     20 
     21 class VCMExpFilter
     22 {
     23 public:
     24     VCMExpFilter(float alpha, float max = -1.0) : _alpha(alpha), _filtered(-1.0), _max(max) {}
     25 
     26     // Resets the filter to its initial state, and resets alpha to the given value
     27     //
     28     // Input:
     29     //          - alpha     : the new value of the filter factor base.
     30     void Reset(float alpha);
     31 
     32     // Applies the filter with the given exponent on the provided sample
     33     //
     34     // Input:
     35     //          - exp       : Exponent T in y(k) = alpha^T * y(k-1) + (1 - alpha^T) * x(k)
     36     //          - sample    : x(k) in the above filter equation
     37     float Apply(float exp, float sample);
     38 
     39     // Return current filtered value: y(k)
     40     //
     41     // Return value         : The current filter output
     42     float Value() const;
     43 
     44     // Change the filter factor base
     45     //
     46     // Input:
     47     //          - alpha     : The new filter factor base.
     48     void UpdateBase(float alpha);
     49 
     50 private:
     51     float          _alpha;     // Filter factor base
     52     float          _filtered;  // Current filter output
     53     const float    _max;
     54 }; // end of ExpFilter class
     55 
     56 }  // namespace webrtc
     57 
     58 #endif // WEBRTC_MODULES_VIDEO_CODING_UTILITY_INCLUDE_EXP_FILTER_H_
     59