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

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

Issue 1656233002: Avoid undefined behavior in vp8 screenshare_layers (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/video_coding/codecs/vp8/screenshare_layers.cc
diff --git a/webrtc/modules/video_coding/codecs/vp8/screenshare_layers.cc b/webrtc/modules/video_coding/codecs/vp8/screenshare_layers.cc
index 536587a13ee07795f7bacab1c2eec4fbe41ffa27..282268a087eb0afeb6e4868e149bd68337ad44b4 100644
--- a/webrtc/modules/video_coding/codecs/vp8/screenshare_layers.cc
+++ b/webrtc/modules/video_coding/codecs/vp8/screenshare_layers.cc
@@ -147,7 +147,8 @@ bool ScreenshareLayers::ConfigureBitrates(int bitrate_kbps,
}
// Don't reconfigure qp limits during quality boost frames.
- if (layers_[active_layer_].state != TemporalLayer::State::kQualityBoost) {
+ if (active_layer_ != -1 &&
pbos-webrtc 2016/02/02 21:16:14 Can you amend the comment above to include what -1
sprang 2016/02/03 10:05:37 Done.
+ layers_[active_layer_].state != TemporalLayer::State::kQualityBoost) {
min_qp_ = cfg->rc_min_quantizer;
max_qp_ = cfg->rc_max_quantizer;
// After a dropped frame, a frame with max qp will be encoded and the
@@ -169,6 +170,7 @@ bool ScreenshareLayers::ConfigureBitrates(int bitrate_kbps,
void ScreenshareLayers::FrameEncoded(unsigned int size,
uint32_t timestamp,
int qp) {
+ RTC_DCHECK_NE(-1, active_layer_);
if (size == 0) {
layers_[active_layer_].state = TemporalLayer::State::kDropped;
return;
@@ -198,6 +200,7 @@ void ScreenshareLayers::PopulateCodecSpecific(bool base_layer_sync,
vp8_info->layerSync = false;
vp8_info->tl0PicIdx = kNoTl0PicIdx;
} else {
+ RTC_DCHECK_NE(-1, active_layer_);
vp8_info->temporalIdx = active_layer_;
if (base_layer_sync) {
vp8_info->temporalIdx = 0;
@@ -248,6 +251,7 @@ bool ScreenshareLayers::TimeToSync(int64_t timestamp) const {
bool ScreenshareLayers::UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) {
if (max_qp_ == -1 || number_of_temporal_layers_ <= 1)
return false;
+ RTC_DCHECK_NE(-1, active_layer_);
// If layer is in the quality boost state (following a dropped frame), update
// the configuration with the adjusted (lower) qp and set the state back to
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698