OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // To know more about the algorithm used and the original code which this is | 5 // To know more about the algorithm used and the original code which this is |
6 // based of, see | 6 // based of, see |
7 // https://wiki.corp.google.com/twiki/bin/view/Main/ChromeGoogleCodeXRef | 7 // https://wiki.corp.google.com/twiki/bin/view/Main/ChromeGoogleCodeXRef |
8 | 8 |
9 #include "content/browser/speech/endpointer/energy_endpointer.h" | 9 #include "content/browser/speech/endpointer/energy_endpointer.h" |
10 | 10 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 91 } |
92 | 92 |
93 int64_t EnergyEndpointer::HistoryRing::EndTime() const { | 93 int64_t EnergyEndpointer::HistoryRing::EndTime() const { |
94 int ind = insertion_index_ - 1; | 94 int ind = insertion_index_ - 1; |
95 if (ind < 0) | 95 if (ind < 0) |
96 ind = decision_points_.size() - 1; | 96 ind = decision_points_.size() - 1; |
97 return decision_points_[ind].time_us; | 97 return decision_points_[ind].time_us; |
98 } | 98 } |
99 | 99 |
100 float EnergyEndpointer::HistoryRing::RingSum(float duration_sec) { | 100 float EnergyEndpointer::HistoryRing::RingSum(float duration_sec) { |
101 if (!decision_points_.size()) | 101 if (decision_points_.empty()) |
102 return 0.0; | 102 return 0.0; |
103 | 103 |
104 int64_t sum_us = 0; | 104 int64_t sum_us = 0; |
105 int ind = insertion_index_ - 1; | 105 int ind = insertion_index_ - 1; |
106 if (ind < 0) | 106 if (ind < 0) |
107 ind = decision_points_.size() - 1; | 107 ind = decision_points_.size() - 1; |
108 int64_t end_us = decision_points_[ind].time_us; | 108 int64_t end_us = decision_points_[ind].time_us; |
109 bool is_on = decision_points_[ind].decision; | 109 bool is_on = decision_points_[ind].decision; |
110 int64_t start_us = | 110 int64_t start_us = |
111 end_us - static_cast<int64_t>(0.5 + (1.0e6 * duration_sec)); | 111 end_us - static_cast<int64_t>(0.5 + (1.0e6 * duration_sec)); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 decision_threshold_ = params_.min_decision_threshold(); | 370 decision_threshold_ = params_.min_decision_threshold(); |
371 } | 371 } |
372 } | 372 } |
373 | 373 |
374 EpStatus EnergyEndpointer::Status(int64_t* status_time) const { | 374 EpStatus EnergyEndpointer::Status(int64_t* status_time) const { |
375 *status_time = history_->EndTime(); | 375 *status_time = history_->EndTime(); |
376 return status_; | 376 return status_; |
377 } | 377 } |
378 | 378 |
379 } // namespace content | 379 } // namespace content |
OLD | NEW |