OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 | 79 |
80 // Remove offset to prevent badly scaled matrices | 80 // Remove offset to prevent badly scaled matrices |
81 tMs -= _startMs; | 81 tMs -= _startMs; |
82 | 82 |
83 CheckForWrapArounds(ts90khz); | 83 CheckForWrapArounds(ts90khz); |
84 | 84 |
85 int64_t unwrapped_ts90khz = static_cast<int64_t>(ts90khz) + | 85 int64_t unwrapped_ts90khz = static_cast<int64_t>(ts90khz) + |
86 _wrapArounds * ((static_cast<int64_t>(1) << 32) - 1); | 86 _wrapArounds * ((static_cast<int64_t>(1) << 32) - 1); |
87 | 87 |
88 if (_prevUnwrappedTimestamp >= 0 && | |
89 unwrapped_ts90khz < _prevUnwrappedTimestamp) | |
90 { | |
91 // Drop reordered frames. | |
92 _rwLock->ReleaseLockExclusive(); | |
93 return; | |
94 } | |
95 | |
96 if (_firstAfterReset) | 88 if (_firstAfterReset) |
97 { | 89 { |
98 // Make an initial guess of the offset, | 90 // Make an initial guess of the offset, |
99 // should be almost correct since tMs - _startMs | 91 // should be almost correct since tMs - _startMs |
100 // should about zero at this time. | 92 // should about zero at this time. |
101 _w[1] = -_w[0] * tMs; | 93 _w[1] = -_w[0] * tMs; |
102 _firstTimestamp = unwrapped_ts90khz; | 94 _firstTimestamp = unwrapped_ts90khz; |
103 _firstAfterReset = false; | 95 _firstAfterReset = false; |
104 } | 96 } |
105 | 97 |
106 double residual = | 98 double residual = |
107 (static_cast<double>(unwrapped_ts90khz) - _firstTimestamp) - | 99 (static_cast<double>(unwrapped_ts90khz) - _firstTimestamp) - |
108 static_cast<double>(tMs) * _w[0] - _w[1]; | 100 static_cast<double>(tMs) * _w[0] - _w[1]; |
109 if (DelayChangeDetection(residual) && | 101 if (DelayChangeDetection(residual) && |
110 _packetCount >= _startUpFilterDelayInPackets) | 102 _packetCount >= _startUpFilterDelayInPackets) |
111 { | 103 { |
112 // A sudden change of average network delay has been detected. | 104 // A sudden change of average network delay has been detected. |
113 // Force the filter to adjust its offset parameter by changing | 105 // Force the filter to adjust its offset parameter by changing |
114 // the offset uncertainty. Don't do this during startup. | 106 // the offset uncertainty. Don't do this during startup. |
115 _pP[1][1] = _pP11; | 107 _pP[1][1] = _pP11; |
116 } | 108 } |
| 109 |
| 110 if (_prevUnwrappedTimestamp >= 0 && |
| 111 unwrapped_ts90khz < _prevUnwrappedTimestamp) |
| 112 { |
| 113 // Drop reordered frames. |
| 114 _rwLock->ReleaseLockExclusive(); |
| 115 return; |
| 116 } |
| 117 |
117 //T = [t(k) 1]'; | 118 //T = [t(k) 1]'; |
118 //that = T'*w; | 119 //that = T'*w; |
119 //K = P*T/(lambda + T'*P*T); | 120 //K = P*T/(lambda + T'*P*T); |
120 double K[2]; | 121 double K[2]; |
121 K[0] = _pP[0][0] * tMs + _pP[0][1]; | 122 K[0] = _pP[0][0] * tMs + _pP[0][1]; |
122 K[1] = _pP[1][0] * tMs + _pP[1][1]; | 123 K[1] = _pP[1][0] * tMs + _pP[1][1]; |
123 double TPT = _lambda + tMs * K[0] + K[1]; | 124 double TPT = _lambda + tMs * K[0] + K[1]; |
124 K[0] /= TPT; | 125 K[0] /= TPT; |
125 K[1] /= TPT; | 126 K[1] /= TPT; |
126 //w = w + K*(ts(k) - that); | 127 //w = w + K*(ts(k) - that); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 if (_detectorAccumulatorPos > _alarmThreshold || _detectorAccumulatorNeg < -
_alarmThreshold) | 226 if (_detectorAccumulatorPos > _alarmThreshold || _detectorAccumulatorNeg < -
_alarmThreshold) |
226 { | 227 { |
227 // Alarm | 228 // Alarm |
228 _detectorAccumulatorPos = _detectorAccumulatorNeg = 0; | 229 _detectorAccumulatorPos = _detectorAccumulatorNeg = 0; |
229 return true; | 230 return true; |
230 } | 231 } |
231 return false; | 232 return false; |
232 } | 233 } |
233 | 234 |
234 } | 235 } |
OLD | NEW |