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

Side by Side Diff: webrtc/test/fake_encoder.cc

Issue 1474533006: Fix bug in calculation of averge queue time in paced sender. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added comment Created 5 years 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
« no previous file with comments | « webrtc/modules/pacing/paced_sender_unittest.cc ('k') | no next file » | 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 const std::vector<FrameType>* frame_types) { 50 const std::vector<FrameType>* frame_types) {
51 assert(config_.maxFramerate > 0); 51 assert(config_.maxFramerate > 0);
52 int64_t time_since_last_encode_ms = 1000 / config_.maxFramerate; 52 int64_t time_since_last_encode_ms = 1000 / config_.maxFramerate;
53 int64_t time_now_ms = clock_->TimeInMilliseconds(); 53 int64_t time_now_ms = clock_->TimeInMilliseconds();
54 const bool first_encode = last_encode_time_ms_ == 0; 54 const bool first_encode = last_encode_time_ms_ == 0;
55 if (!first_encode) { 55 if (!first_encode) {
56 // For all frames but the first we can estimate the display time by looking 56 // For all frames but the first we can estimate the display time by looking
57 // at the display time of the previous frame. 57 // at the display time of the previous frame.
58 time_since_last_encode_ms = time_now_ms - last_encode_time_ms_; 58 time_since_last_encode_ms = time_now_ms - last_encode_time_ms_;
59 } 59 }
60 if (time_since_last_encode_ms > 3 * 1000 / config_.maxFramerate) {
61 // Rudimentary check to make sure we don't widely overshoot bitrate target
62 // when resuming encoding after a suspension.
63 time_since_last_encode_ms = 3 * 1000 / config_.maxFramerate;
64 }
60 65
61 size_t bits_available = 66 size_t bits_available =
62 static_cast<size_t>(target_bitrate_kbps_ * time_since_last_encode_ms); 67 static_cast<size_t>(target_bitrate_kbps_ * time_since_last_encode_ms);
63 size_t min_bits = static_cast<size_t>( 68 size_t min_bits = static_cast<size_t>(
64 config_.simulcastStream[0].minBitrate * time_since_last_encode_ms); 69 config_.simulcastStream[0].minBitrate * time_since_last_encode_ms);
65 if (bits_available < min_bits) 70 if (bits_available < min_bits)
66 bits_available = min_bits; 71 bits_available = min_bits;
67 size_t max_bits = 72 size_t max_bits =
68 static_cast<size_t>(max_target_bitrate_kbps_ * time_since_last_encode_ms); 73 static_cast<size_t>(max_target_bitrate_kbps_ * time_since_last_encode_ms);
69 if (max_bits > 0 && max_bits < bits_available) 74 if (max_bits > 0 && max_bits < bits_available)
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 delay_ms_(delay_ms) {} 193 delay_ms_(delay_ms) {}
189 194
190 int32_t DelayedEncoder::Encode(const VideoFrame& input_image, 195 int32_t DelayedEncoder::Encode(const VideoFrame& input_image,
191 const CodecSpecificInfo* codec_specific_info, 196 const CodecSpecificInfo* codec_specific_info,
192 const std::vector<FrameType>* frame_types) { 197 const std::vector<FrameType>* frame_types) {
193 SleepMs(delay_ms_); 198 SleepMs(delay_ms_);
194 return FakeEncoder::Encode(input_image, codec_specific_info, frame_types); 199 return FakeEncoder::Encode(input_image, codec_specific_info, frame_types);
195 } 200 }
196 } // namespace test 201 } // namespace test
197 } // namespace webrtc 202 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/pacing/paced_sender_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698