Reuse QP limits from the main encoder config

Set layer QP limits equal to QP limits in the main encoder config. This reduces number of nodes to modify if you need to change the settings.

Bug: b/337757868
Change-Id: Id7f6f9d6527903e8e22ff4fad2c974bee6e87cb3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/353982
Reviewed-by: Marco Paniconi <marpan@webrtc.org>
Commit-Queue: Sergey Silkin <ssilkin@webrtc.org>
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42466}
This commit is contained in:
Sergey Silkin 2024-06-07 11:02:14 +00:00 committed by WebRTC LUCI CQ
parent ff2bf4b195
commit 6e37ee34d1

View File

@ -107,7 +107,8 @@ class LibaomAv1Encoder final : public VideoEncoder {
bool SvcEnabled() const { return svc_params_.has_value(); } bool SvcEnabled() const { return svc_params_.has_value(); }
// Fills svc_params_ memeber value. Returns false on error. // Fills svc_params_ memeber value. Returns false on error.
bool SetSvcParams(ScalableVideoController::StreamLayersConfig svc_config); bool SetSvcParams(ScalableVideoController::StreamLayersConfig svc_config,
const aom_codec_enc_cfg_t& encoder_config);
// Configures the encoder with layer for the next frame. // Configures the encoder with layer for the next frame.
void SetSvcLayerId( void SetSvcLayerId(
const ScalableVideoController::LayerFrameConfig& layer_frame); const ScalableVideoController::LayerFrameConfig& layer_frame);
@ -223,10 +224,6 @@ int LibaomAv1Encoder::InitEncode(const VideoCodec* codec_settings,
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
} }
if (!SetSvcParams(svc_controller_->StreamConfig())) {
return WEBRTC_VIDEO_CODEC_ERROR;
}
// Initialize encoder configuration structure with default values // Initialize encoder configuration structure with default values
aom_codec_err_t ret = aom_codec_err_t ret =
aom_codec_enc_config_default(aom_codec_av1_cx(), &cfg_, kUsageProfile); aom_codec_enc_config_default(aom_codec_av1_cx(), &cfg_, kUsageProfile);
@ -276,6 +273,11 @@ int LibaomAv1Encoder::InitEncode(const VideoCodec* codec_settings,
<< " on aom_codec_enc_init."; << " on aom_codec_enc_init.";
return WEBRTC_VIDEO_CODEC_ERROR; return WEBRTC_VIDEO_CODEC_ERROR;
} }
if (!SetSvcParams(svc_controller_->StreamConfig(), cfg_)) {
return WEBRTC_VIDEO_CODEC_ERROR;
}
inited_ = true; inited_ = true;
// Set control parameters // Set control parameters
@ -441,7 +443,8 @@ int LibaomAv1Encoder::NumberOfThreads(int width,
} }
bool LibaomAv1Encoder::SetSvcParams( bool LibaomAv1Encoder::SetSvcParams(
ScalableVideoController::StreamLayersConfig svc_config) { ScalableVideoController::StreamLayersConfig svc_config,
const aom_codec_enc_cfg_t& encoder_config) {
bool svc_enabled = bool svc_enabled =
svc_config.num_spatial_layers > 1 || svc_config.num_temporal_layers > 1; svc_config.num_spatial_layers > 1 || svc_config.num_temporal_layers > 1;
if (!svc_enabled) { if (!svc_enabled) {
@ -466,8 +469,8 @@ bool LibaomAv1Encoder::SetSvcParams(
int num_layers = int num_layers =
svc_config.num_spatial_layers * svc_config.num_temporal_layers; svc_config.num_spatial_layers * svc_config.num_temporal_layers;
for (int i = 0; i < num_layers; ++i) { for (int i = 0; i < num_layers; ++i) {
svc_params.min_quantizers[i] = kQpMin; svc_params.min_quantizers[i] = encoder_config.rc_min_quantizer;
svc_params.max_quantizers[i] = encoder_settings_.qpMax; svc_params.max_quantizers[i] = encoder_config.rc_max_quantizer;
} }
// Assume each temporal layer doubles framerate. // Assume each temporal layer doubles framerate.