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

Side by Side Diff: webrtc/modules/audio_coding/neteq/statistics_calculator.cc

Issue 2714063002: Introduce dchecked_cast, and start using it (Closed)
Patch Set: Created 3 years, 9 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
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 const DecisionLogic& decision_logic, 211 const DecisionLogic& decision_logic,
212 NetEqNetworkStatistics *stats) { 212 NetEqNetworkStatistics *stats) {
213 if (fs_hz <= 0 || !stats) { 213 if (fs_hz <= 0 || !stats) {
214 assert(false); 214 assert(false);
215 return; 215 return;
216 } 216 }
217 217
218 stats->added_zero_samples = added_zero_samples_; 218 stats->added_zero_samples = added_zero_samples_;
219 stats->current_buffer_size_ms = 219 stats->current_buffer_size_ms =
220 static_cast<uint16_t>(num_samples_in_buffers * 1000 / fs_hz); 220 static_cast<uint16_t>(num_samples_in_buffers * 1000 / fs_hz);
221 const int ms_per_packet = rtc::checked_cast<int>( 221 const int ms_per_packet = rtc::dchecked_cast<int>(
222 decision_logic.packet_length_samples() / (fs_hz / 1000)); 222 decision_logic.packet_length_samples() / (fs_hz / 1000));
223 stats->preferred_buffer_size_ms = (delay_manager.TargetLevel() >> 8) * 223 stats->preferred_buffer_size_ms = (delay_manager.TargetLevel() >> 8) *
224 ms_per_packet; 224 ms_per_packet;
225 stats->jitter_peaks_found = delay_manager.PeakFound(); 225 stats->jitter_peaks_found = delay_manager.PeakFound();
226 stats->clockdrift_ppm = 226 stats->clockdrift_ppm =
227 rtc::saturated_cast<int32_t>(delay_manager.EstimatedClockDriftPpm()); 227 rtc::saturated_cast<int32_t>(delay_manager.EstimatedClockDriftPpm());
228 228
229 stats->packet_loss_rate = 229 stats->packet_loss_rate =
230 CalculateQ14Ratio(lost_timestamps_, timestamps_since_last_report_); 230 CalculateQ14Ratio(lost_timestamps_, timestamps_since_last_report_);
231 231
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 // Ratio must be smaller than 1 in Q14. 288 // Ratio must be smaller than 1 in Q14.
289 assert((numerator << 14) / denominator < (1 << 14)); 289 assert((numerator << 14) / denominator < (1 << 14));
290 return static_cast<uint16_t>((numerator << 14) / denominator); 290 return static_cast<uint16_t>((numerator << 14) / denominator);
291 } else { 291 } else {
292 // Will not produce a ratio larger than 1, since this is probably an error. 292 // Will not produce a ratio larger than 1, since this is probably an error.
293 return 1 << 14; 293 return 1 << 14;
294 } 294 }
295 } 295 }
296 296
297 } // namespace webrtc 297 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698