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

Unified Diff: webrtc/modules/video_coding/codecs/vp9/screenshare_layers.cc

Issue 1328113004: Work on flexible mode and screen sharing. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Spatial layers when screensharing. Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/video_coding/codecs/vp9/screenshare_layers.cc
diff --git a/webrtc/modules/video_coding/codecs/vp9/screenshare_layers.cc b/webrtc/modules/video_coding/codecs/vp9/screenshare_layers.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ecf0ffe16f846aa429a7ac406105f95bc3cd172c
--- /dev/null
+++ b/webrtc/modules/video_coding/codecs/vp9/screenshare_layers.cc
@@ -0,0 +1,64 @@
+/* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
sprang_webrtc 2015/09/15 15:41:21 2015
philipel 2015/09/16 09:35:53 Done.
+*
+* Use of this source code is governed by a BSD-style license
+* that can be found in the LICENSE file in the root of the source
+* tree. An additional intellectual property rights grant can be found
+* in the file PATENTS. All contributing project authors may
+* be found in the AUTHORS file in the root of the source tree.
+*/
+
+#include <algorithm>
+#include "webrtc/modules/video_coding/codecs/vp9/screenshare_layers.h"
+#include "webrtc/base/checks.h"
+
+namespace webrtc {
+
+ScreenshareLayersVP9::ScreenshareLayersVP9()
+ : threshold_kbps_(0.f),
+ l0_bits_used_(0.f),
+ last_ts_(0),
+ current_layer_(0) {}
+
+int ScreenshareLayersVP9::CurrentLayer() const {
+ return current_layer_;
+}
+
+void ScreenshareLayersVP9::ConfigureBitrate(int threshold_kbps) {
+ threshold_kbps_ = threshold_kbps;
+}
+
+void ScreenshareLayersVP9::LayerFrameEncoded(unsigned int size_bytes,
+ int layer_id) {
+ if (layer_id == 0) {
+ l0_bits_used_ += size_bytes * 8;
+ }
sprang_webrtc 2015/09/15 15:41:21 remove {}
philipel 2015/09/16 09:35:53 Done.
+}
+
+VP9EncoderImpl::SuperFrameRefSettings ScreenshareLayersVP9::SfSettings(
+ uint32_t timestamp,
+ bool is_keyframe) {
+ VP9EncoderImpl::SuperFrameRefSettings res;
+ res.stop_layer = 1;
+ res.layer[0].upd_buf = 0;
+ res.layer[0].ref_buf1 = 0;
+ res.layer[1].upd_buf = 1;
+ res.layer[1].ref_buf1 = 1;
+ res.is_keyframe = is_keyframe;
+ if (last_ts_ == 0 || is_keyframe) {
+ res.start_layer = 0;
+ } else {
+ float diff = timestamp - last_ts_;
+ l0_bits_used_ =
+ std::max(0.f, l0_bits_used_ - diff / 90.f * threshold_kbps_);
+ if (l0_bits_used_ > threshold_kbps_ * 1000 && !is_keyframe) {
sprang_webrtc 2015/09/15 15:41:21 is_keyframe should always be false here?
philipel 2015/09/16 09:35:53 If it is a keyframe then we must encode both layer
sprang_webrtc 2015/09/25 09:53:15 I was more referring to the fact that if is_keyfra
+ res.start_layer = 1;
+ } else {
+ res.start_layer = 0;
+ }
+ }
sprang_webrtc 2015/09/15 15:41:21 As noted in a previous comment, this measures aver
philipel 2015/09/16 09:35:53 It is NOT true that it measures the average bitrat
sprang_webrtc 2015/09/25 09:53:15 Ah, you're right.
+ current_layer_ = res.start_layer;
+ last_ts_ = timestamp;
+ return res;
+}
+
+} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698