Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(501)

Side by Side Diff: media/base/moving_average.h

Issue 1021943002: Introduce cadence based VideoRendererAlgorithm. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switch to MovingAverage. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_BASE_MOVING_AVERAGE_H_
6 #define MEDIA_BASE_MOVING_AVERAGE_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "base/time/time.h"
10 #include "media/base/media_export.h"
11
12 namespace media {
13
14 // Simple class for calculating a moving average of fixed size.
15 class MEDIA_EXPORT MovingAverage {
16 public:
17 // Creates a MovingAverage instance with space for |depth| samples.
18 explicit MovingAverage(size_t depth);
19 ~MovingAverage();
20
21 // Add a new sample to the average; replaces the oldest sample if |depth_| has
xhwang 2015/04/28 16:01:07 nit: s/Add/Adds
DaleCurtis 2015/04/28 21:45:24 Done.
22 // been exceeded. Updates |total_| to the new sum of values.
23 void AddSample(base::TimeDelta sample);
24
25 // Returns the current average of all held samples.
26 base::TimeDelta Average() const;
27
28 // Resets the state of the class to its initial post-construction state.
29 void Reset();
30
31 private:
32 // Maximum number of elements allowed in the average.
33 const size_t depth_;
34
35 // Number of elements seen thus far.
36 size_t count_;
37
38 scoped_ptr<base::TimeDelta[]> samples_;
xhwang 2015/04/28 16:01:07 Will a vector work?
DaleCurtis 2015/04/28 21:45:24 Done.
39 base::TimeDelta total_;
40
41 DISALLOW_COPY_AND_ASSIGN(MovingAverage);
42 };
43
44 } // namespace media
45
46 #endif // MEDIA_BASE_MOVING_AVERAGE_H_
OLDNEW
« no previous file with comments | « media/base/BUILD.gn ('k') | media/base/moving_average.cc » ('j') | media/base/moving_average.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698