| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 #include "content/browser/media/capture/feedback_signal_accumulator.h" | 5 #include "media/capture/feedback_signal_accumulator.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 namespace content { | 10 namespace media { |
| 11 | 11 |
| 12 FeedbackSignalAccumulator::FeedbackSignalAccumulator(base::TimeDelta half_life) | 12 FeedbackSignalAccumulator::FeedbackSignalAccumulator(base::TimeDelta half_life) |
| 13 : half_life_(half_life) { | 13 : half_life_(half_life) { |
| 14 DCHECK(half_life_ > base::TimeDelta()); | 14 DCHECK(half_life_ > base::TimeDelta()); |
| 15 } | 15 } |
| 16 | 16 |
| 17 void FeedbackSignalAccumulator::Reset(double starting_value, | 17 void FeedbackSignalAccumulator::Reset(double starting_value, |
| 18 base::TimeTicks timestamp) { | 18 base::TimeTicks timestamp) { |
| 19 DCHECK(!timestamp.is_null()); | 19 DCHECK(!timestamp.is_null()); |
| 20 average_ = update_value_ = prior_average_ = starting_value; | 20 average_ = update_value_ = prior_average_ = starting_value; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 46 | 46 |
| 47 const double elapsed_us = | 47 const double elapsed_us = |
| 48 static_cast<double>((update_time_ - prior_update_time_).InMicroseconds()); | 48 static_cast<double>((update_time_ - prior_update_time_).InMicroseconds()); |
| 49 const double weight = elapsed_us / (elapsed_us + half_life_.InMicroseconds()); | 49 const double weight = elapsed_us / (elapsed_us + half_life_.InMicroseconds()); |
| 50 average_ = weight * update_value_ + (1.0 - weight) * prior_average_; | 50 average_ = weight * update_value_ + (1.0 - weight) * prior_average_; |
| 51 DCHECK(std::isfinite(average_)); | 51 DCHECK(std::isfinite(average_)); |
| 52 | 52 |
| 53 return true; | 53 return true; |
| 54 } | 54 } |
| 55 | 55 |
| 56 } // namespace content | 56 } // namespace media |
| OLD | NEW |