Fix SVC controller's bitrate allocation in VP9 encoder

Unlike libvpx, the VideoBitrateAllocation expects that the bitrate
allocation is separate for each temporal layer. In this instance, if the
bitrates are not separated it will fool the SVC controller into thinking
that all temporal layers are always active.

Bug: webrtc:11999
Change-Id: Ibc33ac00b8b7716c011b94e1ec9c640cedb5274e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231693
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Emil Lundmark <lndmrk@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#34980}
This commit is contained in:
Emil Lundmark
2021-09-10 12:05:08 +02:00
committed by WebRTC LUCI CQ
parent e130084c68
commit baa6090825

View File

@ -400,11 +400,18 @@ bool LibvpxVp9Encoder::SetSvcRates(
if (svc_controller_) {
for (int sid = 0; sid < num_spatial_layers_; ++sid) {
// Bitrates in `layer_target_bitrate` are accumulated for each temporal
// layer but in `VideoBitrateAllocation` they should be separated.
int previous_bitrate_kbps = 0;
for (int tid = 0; tid < num_temporal_layers_; ++tid) {
int accumulated_bitrate_kbps =
config_->layer_target_bitrate[sid * num_temporal_layers_ + tid];
int single_layer_bitrate_kbps =
accumulated_bitrate_kbps - previous_bitrate_kbps;
RTC_DCHECK_GE(single_layer_bitrate_kbps, 0);
current_bitrate_allocation_.SetBitrate(
sid, tid,
config_->layer_target_bitrate[sid * num_temporal_layers_ + tid] *
1000);
sid, tid, single_layer_bitrate_kbps * 1'000);
previous_bitrate_kbps = accumulated_bitrate_kbps;
}
}
svc_controller_->OnRatesUpdated(current_bitrate_allocation_);