summaryrefslogtreecommitdiff
path: root/vp8
diff options
context:
space:
mode:
authorWan-Teh Chang <wtc@google.com>2023-03-22 16:09:24 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2023-03-22 16:09:24 +0000
commita0bf98de0d7f7017bccc287bbf986d7518502e29 (patch)
treebca4e44c784653fd133bb32652d201bdfcb9c685 /vp8
parent882399bd54a82aa72ba766356d8fda31fbe40450 (diff)
parent430c6c1553df0abfe2dadc480b21dd691a98140f (diff)
downloadlibvpx-a0bf98de0d7f7017bccc287bbf986d7518502e29.tar
libvpx-a0bf98de0d7f7017bccc287bbf986d7518502e29.tar.gz
libvpx-a0bf98de0d7f7017bccc287bbf986d7518502e29.tar.bz2
libvpx-a0bf98de0d7f7017bccc287bbf986d7518502e29.zip
Merge "Change UpdateRateControl() to return bool" into main
Diffstat (limited to 'vp8')
-rw-r--r--vp8/vp8_ratectrl_rtc.cc15
-rw-r--r--vp8/vp8_ratectrl_rtc.h4
2 files changed, 13 insertions, 6 deletions
diff --git a/vp8/vp8_ratectrl_rtc.cc b/vp8/vp8_ratectrl_rtc.cc
index c36cfea48..65c58536a 100644
--- a/vp8/vp8_ratectrl_rtc.cc
+++ b/vp8/vp8_ratectrl_rtc.cc
@@ -62,7 +62,7 @@ std::unique_ptr<VP8RateControlRTC> VP8RateControlRTC::Create(
if (!rc_api->cpi_) return nullptr;
vp8_zero(*rc_api->cpi_);
- rc_api->InitRateControl(cfg);
+ if (!rc_api->InitRateControl(cfg)) return nullptr;
return rc_api;
}
@@ -74,7 +74,7 @@ VP8RateControlRTC::~VP8RateControlRTC() {
}
}
-void VP8RateControlRTC::InitRateControl(const VP8RateControlRtcConfig &rc_cfg) {
+bool VP8RateControlRTC::InitRateControl(const VP8RateControlRtcConfig &rc_cfg) {
VP8_COMMON *cm = &cpi_->common;
VP8_CONFIG *oxcf = &cpi_->oxcf;
oxcf->end_usage = USAGE_STREAM_FROM_SERVER;
@@ -92,13 +92,19 @@ void VP8RateControlRTC::InitRateControl(const VP8RateControlRtcConfig &rc_cfg) {
cpi_->kf_bitrate_adjustment = 0;
cpi_->gf_overspend_bits = 0;
cpi_->non_gf_bitrate_adjustment = 0;
- UpdateRateControl(rc_cfg);
+ if (!UpdateRateControl(rc_cfg)) return false;
cpi_->buffer_level = oxcf->starting_buffer_level;
cpi_->bits_off_target = oxcf->starting_buffer_level;
+ return true;
}
-void VP8RateControlRTC::UpdateRateControl(
+bool VP8RateControlRTC::UpdateRateControl(
const VP8RateControlRtcConfig &rc_cfg) {
+ if (rc_cfg.ts_number_layers < 1 ||
+ rc_cfg.ts_number_layers > VPX_TS_MAX_LAYERS) {
+ return false;
+ }
+
VP8_COMMON *cm = &cpi_->common;
VP8_CONFIG *oxcf = &cpi_->oxcf;
const unsigned int prev_number_of_layers = oxcf->number_of_layers;
@@ -199,6 +205,7 @@ void VP8RateControlRTC::UpdateRateControl(
vp8_new_framerate(cpi_, cpi_->framerate);
vpx_clear_system_state();
+ return true;
}
void VP8RateControlRTC::ComputeQP(const VP8FrameParamsQpRTC &frame_params) {
diff --git a/vp8/vp8_ratectrl_rtc.h b/vp8/vp8_ratectrl_rtc.h
index 0e81592ec..a8a886c56 100644
--- a/vp8/vp8_ratectrl_rtc.h
+++ b/vp8/vp8_ratectrl_rtc.h
@@ -39,7 +39,7 @@ class VP8RateControlRTC {
const VP8RateControlRtcConfig &cfg);
~VP8RateControlRTC();
- void UpdateRateControl(const VP8RateControlRtcConfig &rc_cfg);
+ bool UpdateRateControl(const VP8RateControlRtcConfig &rc_cfg);
// GetQP() needs to be called after ComputeQP() to get the latest QP
int GetQP() const;
// int GetLoopfilterLevel() const;
@@ -49,7 +49,7 @@ class VP8RateControlRTC {
private:
VP8RateControlRTC() {}
- void InitRateControl(const VP8RateControlRtcConfig &cfg);
+ bool InitRateControl(const VP8RateControlRtcConfig &cfg);
struct VP8_COMP *cpi_;
int q_;
};