Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | |
|
sprang_webrtc
2015/09/07 14:39:04
2015? :)
| |
| 2 * | |
| 3 * Use of this source code is governed by a BSD-style license | |
| 4 * that can be found in the LICENSE file in the root of the source | |
| 5 * tree. An additional intellectual property rights grant can be found | |
| 6 * in the file PATENTS. All contributing project authors may | |
| 7 * be found in the AUTHORS file in the root of the source tree. | |
| 8 */ | |
| 9 | |
| 10 #include <algorithm> | |
| 11 #include "webrtc/modules/video_coding/codecs/vp9/screenshare_layers.h" | |
| 12 #include "webrtc/base/checks.h" | |
| 13 | |
| 14 namespace webrtc { | |
| 15 | |
| 16 ScreenshareLayersVP9::ScreenshareLayersVP9() | |
| 17 : threshold_kbps_(0.f), sl0_bits_used_(0.f), current_sl_(0), last_ts_(0) { | |
| 18 } | |
| 19 | |
| 20 bool ScreenshareLayersVP9::ConfigureBitrate(int threshold_kbps) { | |
| 21 threshold_kbps_ = threshold_kbps; | |
| 22 return true; | |
|
sprang_webrtc
2015/09/07 14:39:04
Why do we return a bool here?
philipel
2015/09/10 14:47:01
Because I copied the interface from the temporal l
| |
| 23 } | |
| 24 | |
| 25 void ScreenshareLayersVP9::FrameEncoded(unsigned int size_bytes) { | |
| 26 sl0_bits_used_ += current_sl_ == 0 ? size_bytes * 8 : 0; | |
|
sprang_webrtc
2015/09/07 14:39:04
Would prefer
if (current_sl_ == 0)
sl0_bits_used
philipel
2015/09/10 14:47:01
Done.
| |
| 27 } | |
| 28 | |
| 29 int8_t ScreenshareLayersVP9::CurrentLayer() { | |
|
sprang_webrtc
2015/09/07 14:39:04
const?
philipel
2015/09/10 14:47:01
Done.
| |
| 30 return current_sl_; | |
| 31 } | |
| 32 | |
| 33 // TODO(philipel): suppose to be used for different spatial layers, | |
|
sprang_webrtc
2015/09/07 14:39:04
Can we refer to a libvpx issue or some other refer
philipel
2015/09/10 14:47:01
Comment removed.
| |
| 34 // but for now is used for different temporal layers. | |
| 35 std::array<int8_t, 4> ScreenshareLayersVP9::BufferArguments( | |
| 36 uint32_t timestamp) { | |
| 37 std::array<int8_t, 4> res; | |
|
sprang_webrtc
2015/09/07 14:39:04
Please comment how this res (result?) is to be int
philipel
2015/09/10 14:47:01
Changed to new data structure
| |
| 38 if (last_ts_ == 0) { | |
| 39 res[0] = 0; | |
| 40 res[1] = 0; | |
| 41 } else { | |
| 42 float diff = timestamp - last_ts_; | |
| 43 // A check to make sure the used bits calculation doesn't overflow, | |
| 44 // which can happen if you debug and use a real time clock | |
| 45 // (diff becomes to big). | |
|
sprang_webrtc
2015/09/07 14:39:04
or too big?
philipel
2015/09/10 14:47:01
Removed check and comment.
| |
| 46 DCHECK(sl0_bits_used_ >= (sl0_bits_used_ - diff / 90.f * threshold_kbps_)); | |
| 47 sl0_bits_used_ = | |
| 48 std::max(0.f, sl0_bits_used_ - diff / 90.f * threshold_kbps_); | |
| 49 | |
|
sprang_webrtc
2015/09/07 14:39:04
This means you are looking at the average bitrate
philipel
2015/09/10 14:47:01
No, this is not the bitrate over the entire lifeti
| |
| 50 if (sl0_bits_used_ > threshold_kbps_ * 1000) { | |
| 51 res[0] = 1; | |
| 52 res[1] = current_sl_; | |
| 53 current_sl_ = 1; | |
| 54 } else { | |
| 55 res[0] = 0; | |
| 56 res[1] = 0; | |
| 57 current_sl_ = 0; | |
| 58 } | |
| 59 } | |
| 60 last_ts_ = timestamp; | |
| 61 res[2] = res[3] = -1; | |
| 62 return res; | |
| 63 } | |
| 64 | |
| 65 } // namespace webrtc | |
| OLD | NEW |