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

Side by Side Diff: webrtc/common_audio/smoothing_filter.cc

Issue 2687433004: TWCC-PLR -based FecController doesn’t need smoothing (Closed)
Patch Set: Rebased. 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) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 ExtrapolateLastSample(*init_end_time_ms_); 104 ExtrapolateLastSample(*init_end_time_ms_);
105 // Then extrapolate the rest by the following. 105 // Then extrapolate the rest by the following.
106 } 106 }
107 multiplier = powf(alpha_, time_ms - last_state_time_ms_); 107 multiplier = powf(alpha_, time_ms - last_state_time_ms_);
108 } 108 }
109 109
110 state_ = multiplier * state_ + (1.0f - multiplier) * last_sample_; 110 state_ = multiplier * state_ + (1.0f - multiplier) * last_sample_;
111 last_state_time_ms_ = time_ms; 111 last_state_time_ms_ = time_ms;
112 } 112 }
113 113
114 } // namespace webrtc
115
116 // Appendix: derivation of extrapolation during initialization phase. 114 // Appendix: derivation of extrapolation during initialization phase.
117 // (LaTeX syntax) 115 // (LaTeX syntax)
118 // Assuming 116 // Assuming
119 // \begin{align} 117 // \begin{align}
120 // y(n) &= \alpha_{n-1} y(n-1) + \left(1 - \alpha_{n-1}\right) x(m) \\* 118 // y(n) &= \alpha_{n-1} y(n-1) + \left(1 - \alpha_{n-1}\right) x(m) \\*
121 // &= \left(\prod_{i=m}^{n-1} \alpha_i\right) y(m) + 119 // &= \left(\prod_{i=m}^{n-1} \alpha_i\right) y(m) +
122 // \left(1 - \prod_{i=m}^{n-1} \alpha_i \right) x(m) 120 // \left(1 - \prod_{i=m}^{n-1} \alpha_i \right) x(m)
123 // \end{align} 121 // \end{align}
124 // Taking $\alpha_{n} = \exp(-\gamma^n)$, $\gamma$ denotes init\_factor\_, the 122 // Taking $\alpha_{n} = \exp(-\gamma^n)$, $\gamma$ denotes init\_factor\_, the
125 // multiplier becomes 123 // multiplier becomes
126 // \begin{align} 124 // \begin{align}
127 // \prod_{i=m}^{n-1} \alpha_i 125 // \prod_{i=m}^{n-1} \alpha_i
128 // &= \exp\left(-\sum_{i=m}^{n-1} \gamma^i \right) \\* 126 // &= \exp\left(-\sum_{i=m}^{n-1} \gamma^i \right) \\*
129 // &= \begin{cases} 127 // &= \begin{cases}
130 // \exp\left(-\frac{\gamma^m - \gamma^n}{1 - \gamma} \right) 128 // \exp\left(-\frac{\gamma^m - \gamma^n}{1 - \gamma} \right)
131 // & \gamma \neq 1 \\* 129 // & \gamma \neq 1 \\*
132 // m-n & \gamma = 1 130 // m-n & \gamma = 1
133 // \end{cases} 131 // \end{cases}
134 // \end{align} 132 // \end{align}
135 // We know $\gamma = T^{-\frac{1}{T}}$, where $T$ denotes init\_time\_ms\_. Then 133 // We know $\gamma = T^{-\frac{1}{T}}$, where $T$ denotes init\_time\_ms\_. Then
136 // $1 - \gamma$ approaches zero when $T$ increases. This can cause numerical 134 // $1 - \gamma$ approaches zero when $T$ increases. This can cause numerical
137 // difficulties. We multiply $T$ (if $T > 0$) to both numerator and denominator 135 // difficulties. We multiply $T$ (if $T > 0$) to both numerator and denominator
138 // in the fraction. See. 136 // in the fraction. See.
139 // \begin{align} 137 // \begin{align}
140 // \frac{\gamma^m - \gamma^n}{1 - \gamma} 138 // \frac{\gamma^m - \gamma^n}{1 - \gamma}
141 // &= \frac{T^\frac{T-m}{T} - T^\frac{T-n}{T}}{T - T^{1-\frac{1}{T}}} 139 // &= \frac{T^\frac{T-m}{T} - T^\frac{T-n}{T}}{T - T^{1-\frac{1}{T}}}
142 // \end{align} 140 // \end{align}
141
142 NullSmoothingFilter::NullSmoothingFilter() = default;
143
144 NullSmoothingFilter::~NullSmoothingFilter() = default;
145
146 void NullSmoothingFilter::AddSample(float sample) {
147 last_sample_ = rtc::Optional<float>(sample);
148 }
149
150 rtc::Optional<float> NullSmoothingFilter::GetAverage() {
151 return last_sample_;
152 }
153
154 bool NullSmoothingFilter::SetTimeConstantMs(int time_constant_ms) {
155 RTC_NOTREACHED();
156 return false;
157 }
158
159 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698