Only set vp9 config when it's changed.

~3-5% speed up on webrtc_perf_tests of vp9 on linux desktop.

Avoid going thru a lot of unnecessary code checks.

Change-Id: I2cb0d794bcf239c5057dfc04cd07a496f89a5016
Bug: None
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167640
Commit-Queue: Jerome Jiang <jianj@google.com>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30586}
This commit is contained in:
Jerome Jiang
2020-02-21 10:47:10 -08:00
committed by Commit Bot
parent 5ed40cfa2e
commit 4a06666325
2 changed files with 12 additions and 3 deletions

View File

@ -249,7 +249,8 @@ VP9EncoderImpl::VP9EncoderImpl(const cricket::VideoCodec& codec)
"WebRTC-VP9VariableFramerateScreenshare")),
variable_framerate_controller_(
variable_framerate_experiment_.framerate_limit),
num_steady_state_frames_(0) {
num_steady_state_frames_(0),
config_changed_(true) {
codec_ = {};
memset(&svc_params_, 0, sizeof(vpx_svc_extra_cfg_t));
}
@ -410,6 +411,7 @@ bool VP9EncoderImpl::SetSvcRates(
}
current_bitrate_allocation_ = bitrate_allocation;
config_changed_ = true;
return true;
}
@ -439,6 +441,7 @@ void VP9EncoderImpl::SetRates(const RateControlParameters& parameters) {
bool res = SetSvcRates(parameters.bitrate);
RTC_DCHECK(res) << "Failed to set new bitrate allocation";
config_changed_ = true;
}
// TODO(eladalon): s/inst/codec_settings/g.
@ -814,6 +817,7 @@ int VP9EncoderImpl::InitAndSetControlSettings(const VideoCodec* inst) {
// Enable encoder skip of static/low content blocks.
vpx_codec_control(encoder_, VP8E_SET_STATIC_THRESHOLD, 1);
inited_ = true;
config_changed_ = true;
return WEBRTC_VIDEO_CODEC_OK;
}
@ -936,8 +940,11 @@ int VP9EncoderImpl::Encode(const VideoFrame& input_image,
&svc_drop_frame_);
}
if (vpx_codec_enc_config_set(encoder_, config_)) {
return WEBRTC_VIDEO_CODEC_ERROR;
if (config_changed_) {
if (vpx_codec_enc_config_set(encoder_, config_)) {
return WEBRTC_VIDEO_CODEC_ERROR;
}
config_changed_ = false;
}
RTC_DCHECK_EQ(input_image.width(), raw_->d_w);