| OLD | NEW |
| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 private: | 87 private: |
| 88 typedef std::pair<int64_t, uint32_t> TimeSizePair; | 88 typedef std::pair<int64_t, uint32_t> TimeSizePair; |
| 89 | 89 |
| 90 const int64_t kWindowSizeUs; | 90 const int64_t kWindowSizeUs; |
| 91 uint32_t packets_per_second_; | 91 uint32_t packets_per_second_; |
| 92 uint32_t bytes_per_second_; | 92 uint32_t bytes_per_second_; |
| 93 int64_t last_accumulated_us_; | 93 int64_t last_accumulated_us_; |
| 94 std::list<TimeSizePair> window_; | 94 std::list<TimeSizePair> window_; |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 Random::Random(uint32_t seed) | |
| 98 : a_(0x531FDB97 ^ seed), | |
| 99 b_(0x6420ECA8 + seed) { | |
| 100 } | |
| 101 | |
| 102 float Random::Rand() { | |
| 103 const float kScale = 1.0f / 0xffffffff; | |
| 104 float result = kScale * b_; | |
| 105 a_ ^= b_; | |
| 106 b_ += a_; | |
| 107 return result; | |
| 108 } | |
| 109 | |
| 110 int Random::Gaussian(int mean, int standard_deviation) { | |
| 111 // Creating a Normal distribution variable from two independent uniform | |
| 112 // variables based on the Box-Muller transform, which is defined on the | |
| 113 // interval (0, 1], hence the mask+add below. | |
| 114 const double kPi = 3.14159265358979323846; | |
| 115 const double kScale = 1.0 / 0x80000000ul; | |
| 116 double u1 = kScale * ((a_ & 0x7ffffffful) + 1); | |
| 117 double u2 = kScale * ((b_ & 0x7ffffffful) + 1); | |
| 118 a_ ^= b_; | |
| 119 b_ += a_; | |
| 120 return static_cast<int>(mean + standard_deviation * | |
| 121 sqrt(-2 * log(u1)) * cos(2 * kPi * u2)); | |
| 122 } | |
| 123 | |
| 124 Packet::Packet() | 97 Packet::Packet() |
| 125 : flow_id_(0), creation_time_us_(-1), send_time_us_(-1), payload_size_(0) { | 98 : flow_id_(0), creation_time_us_(-1), send_time_us_(-1), payload_size_(0) { |
| 126 } | 99 } |
| 127 | 100 |
| 128 Packet::Packet(int flow_id, int64_t send_time_us, size_t payload_size) | 101 Packet::Packet(int flow_id, int64_t send_time_us, size_t payload_size) |
| 129 : flow_id_(flow_id), | 102 : flow_id_(flow_id), |
| 130 creation_time_us_(send_time_us), | 103 creation_time_us_(send_time_us), |
| 131 send_time_us_(send_time_us), | 104 send_time_us_(send_time_us), |
| 132 payload_size_(payload_size) { | 105 payload_size_(payload_size) { |
| 133 } | 106 } |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 uint32_t PeriodicKeyFrameSource::NextPacketSize(uint32_t frame_size, | 714 uint32_t PeriodicKeyFrameSource::NextPacketSize(uint32_t frame_size, |
| 742 uint32_t remaining_payload) { | 715 uint32_t remaining_payload) { |
| 743 uint32_t fragments = | 716 uint32_t fragments = |
| 744 (frame_size + (kMaxPayloadSizeBytes - 1)) / kMaxPayloadSizeBytes; | 717 (frame_size + (kMaxPayloadSizeBytes - 1)) / kMaxPayloadSizeBytes; |
| 745 uint32_t avg_size = (frame_size + fragments - 1) / fragments; | 718 uint32_t avg_size = (frame_size + fragments - 1) / fragments; |
| 746 return std::min(avg_size, remaining_payload); | 719 return std::min(avg_size, remaining_payload); |
| 747 } | 720 } |
| 748 } // namespace bwe | 721 } // namespace bwe |
| 749 } // namespace testing | 722 } // namespace testing |
| 750 } // namespace webrtc | 723 } // namespace webrtc |
| OLD | NEW |