Extract bitrate allocation of spatial/temporal layers out of codec impl.
This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 Review-Url: https://codereview.webrtc.org/2434073003 Cr-Commit-Position: refs/heads/master@{#14998}
This commit is contained in:
@ -77,6 +77,7 @@ VP9EncoderImpl::VP9EncoderImpl()
|
||||
frames_since_kf_(0),
|
||||
num_temporal_layers_(0),
|
||||
num_spatial_layers_(0),
|
||||
is_flexible_mode_(false),
|
||||
frames_encoded_(0),
|
||||
// Use two spatial when screensharing with flexible mode.
|
||||
spatial_layer_(new ScreenshareLayersVP9(2)) {
|
||||
@ -193,24 +194,28 @@ bool VP9EncoderImpl::SetSvcRates() {
|
||||
return true;
|
||||
}
|
||||
|
||||
int VP9EncoderImpl::SetRates(uint32_t new_bitrate_kbit,
|
||||
uint32_t new_framerate) {
|
||||
int VP9EncoderImpl::SetRateAllocation(
|
||||
const BitrateAllocation& bitrate_allocation,
|
||||
uint32_t frame_rate) {
|
||||
if (!inited_) {
|
||||
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
|
||||
}
|
||||
if (encoder_->err) {
|
||||
return WEBRTC_VIDEO_CODEC_ERROR;
|
||||
}
|
||||
if (new_framerate < 1) {
|
||||
if (frame_rate < 1) {
|
||||
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
|
||||
}
|
||||
// Update bit rate
|
||||
if (codec_.maxBitrate > 0 && new_bitrate_kbit > codec_.maxBitrate) {
|
||||
new_bitrate_kbit = codec_.maxBitrate;
|
||||
if (codec_.maxBitrate > 0 &&
|
||||
bitrate_allocation.get_sum_kbps() > codec_.maxBitrate) {
|
||||
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
|
||||
}
|
||||
config_->rc_target_bitrate = new_bitrate_kbit;
|
||||
codec_.maxFramerate = new_framerate;
|
||||
spatial_layer_->ConfigureBitrate(new_bitrate_kbit, 0);
|
||||
|
||||
// TODO(sprang): Actually use BitrateAllocation layer info.
|
||||
config_->rc_target_bitrate = bitrate_allocation.get_sum_kbps();
|
||||
codec_.maxFramerate = frame_rate;
|
||||
spatial_layer_->ConfigureBitrate(bitrate_allocation.get_sum_kbps(), 0);
|
||||
|
||||
if (!SetSvcRates()) {
|
||||
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
|
||||
|
||||
Reference in New Issue
Block a user