Chromium Code Reviews

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

Issue 1929863002: NetEq: Use TickTimer in DelayManager (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@delay-pdt-tick-timer
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/neteq/decision_logic_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 134 matching lines...)
145 void DecisionLogic::ExpandDecision(Operations operation) { 145 void DecisionLogic::ExpandDecision(Operations operation) {
146 if (operation == kExpand) { 146 if (operation == kExpand) {
147 num_consecutive_expands_++; 147 num_consecutive_expands_++;
148 } else { 148 } else {
149 num_consecutive_expands_ = 0; 149 num_consecutive_expands_ = 0;
150 } 150 }
151 } 151 }
152 152
153 void DecisionLogic::FilterBufferLevel(size_t buffer_size_samples, 153 void DecisionLogic::FilterBufferLevel(size_t buffer_size_samples,
154 Modes prev_mode) { 154 Modes prev_mode) {
155 const int elapsed_time_ms =
156 static_cast<int>(output_size_samples_ / (8 * fs_mult_));
157 delay_manager_->UpdateCounters(elapsed_time_ms);
158
159 // Do not update buffer history if currently playing CNG since it will bias 155 // Do not update buffer history if currently playing CNG since it will bias
160 // the filtered buffer level. 156 // the filtered buffer level.
161 if ((prev_mode != kModeRfc3389Cng) && (prev_mode != kModeCodecInternalCng)) { 157 if ((prev_mode != kModeRfc3389Cng) && (prev_mode != kModeCodecInternalCng)) {
162 buffer_level_filter_->SetTargetBufferLevel( 158 buffer_level_filter_->SetTargetBufferLevel(
163 delay_manager_->base_target_level()); 159 delay_manager_->base_target_level());
164 160
165 size_t buffer_size_packets = 0; 161 size_t buffer_size_packets = 0;
166 if (packet_length_samples_ > 0) { 162 if (packet_length_samples_ > 0) {
167 // Calculate size in packets. 163 // Calculate size in packets.
168 buffer_size_packets = buffer_size_samples / packet_length_samples_; 164 buffer_size_packets = buffer_size_samples / packet_length_samples_;
169 } 165 }
170 int sample_memory_local = 0; 166 int sample_memory_local = 0;
171 if (prev_time_scale_) { 167 if (prev_time_scale_) {
172 sample_memory_local = sample_memory_; 168 sample_memory_local = sample_memory_;
173 timescale_hold_off_ = kMinTimescaleInterval; 169 timescale_hold_off_ = kMinTimescaleInterval;
174 } 170 }
175 buffer_level_filter_->Update(buffer_size_packets, sample_memory_local, 171 buffer_level_filter_->Update(buffer_size_packets, sample_memory_local,
176 packet_length_samples_); 172 packet_length_samples_);
177 prev_time_scale_ = false; 173 prev_time_scale_ = false;
178 } 174 }
179 175
180 timescale_hold_off_ = std::max(timescale_hold_off_ - 1, 0); 176 timescale_hold_off_ = std::max(timescale_hold_off_ - 1, 0);
181 } 177 }
182 178
183 } // namespace webrtc 179 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/neteq/decision_logic_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine