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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 config_ = *config; | 43 config_ = *config; |
44 target_bitrate_kbps_ = config_.startBitrate; | 44 target_bitrate_kbps_ = config_.startBitrate; |
45 return 0; | 45 return 0; |
46 } | 46 } |
47 | 47 |
48 int32_t FakeEncoder::Encode(const VideoFrame& input_image, | 48 int32_t FakeEncoder::Encode(const VideoFrame& input_image, |
49 const CodecSpecificInfo* codec_specific_info, | 49 const CodecSpecificInfo* codec_specific_info, |
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 if (time_since_last_encode_ms > 1000 / config_.maxFramerate) { | |
stefan-webrtc
2015/11/25 18:14:22
I don't think this does much... :)
You probably w
sprang_webrtc
2015/11/25 19:40:42
Oops. Done.
| |
54 // Rudimentary check to make sure we don't widely overshoot bitrate target | |
55 // when resuming encoding after a suspension. | |
56 time_since_last_encode_ms = 3 * 1000 / config_.maxFramerate; | |
57 } | |
53 int64_t time_now_ms = clock_->TimeInMilliseconds(); | 58 int64_t time_now_ms = clock_->TimeInMilliseconds(); |
54 const bool first_encode = last_encode_time_ms_ == 0; | 59 const bool first_encode = last_encode_time_ms_ == 0; |
55 if (!first_encode) { | 60 if (!first_encode) { |
56 // For all frames but the first we can estimate the display time by looking | 61 // For all frames but the first we can estimate the display time by looking |
57 // at the display time of the previous frame. | 62 // at the display time of the previous frame. |
58 time_since_last_encode_ms = time_now_ms - last_encode_time_ms_; | 63 time_since_last_encode_ms = time_now_ms - last_encode_time_ms_; |
59 } | 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); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 |
OLD | NEW |