Disable quality scaling if multiple spatial layers are requested for VP9
VP9 automaticResizeOn is disabled if more than one spatial layer is configured via scalability mode. Bug: webrtc:13960 Change-Id: I7c6351bca6d2f32bcc7391894e8dcc9e74ca2050 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/261315 Reviewed-by: Niels Moller <nisse@webrtc.org> Commit-Queue: Åsa Persson <asapersson@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36897}
This commit is contained in:
parent
dab50c6fe8
commit
2698353d43
@ -403,6 +403,21 @@ int NumActiveStreams(const webrtc::RtpParameters& rtp_parameters) {
|
||||
return res;
|
||||
}
|
||||
|
||||
absl::optional<int> NumSpatialLayersFromEncoding(
|
||||
const webrtc::RtpParameters& rtp_parameters,
|
||||
size_t idx) {
|
||||
if (idx >= rtp_parameters.encodings.size())
|
||||
return absl::nullopt;
|
||||
|
||||
absl::optional<webrtc::ScalabilityMode> scalability_mode =
|
||||
webrtc::ScalabilityModeFromString(
|
||||
rtp_parameters.encodings[idx].scalability_mode.value_or(""));
|
||||
return scalability_mode
|
||||
? absl::optional<int>(
|
||||
ScalabilityModeToNumSpatialLayers(*scalability_mode))
|
||||
: absl::nullopt;
|
||||
}
|
||||
|
||||
std::map<uint32_t, webrtc::VideoSendStream::StreamStats>
|
||||
MergeInfoAboutOutboundRtpSubstreams(
|
||||
const std::map<uint32_t, webrtc::VideoSendStream::StreamStats>&
|
||||
@ -525,7 +540,14 @@ WebRtcVideoChannel::WebRtcVideoSendStream::ConfigureVideoEncoderSettings(
|
||||
|
||||
// VP9 denoising is disabled by default.
|
||||
vp9_settings.denoisingOn = codec_default_denoising ? true : denoising;
|
||||
vp9_settings.automaticResizeOn = automatic_resize;
|
||||
// Disable automatic resize if more than one spatial layer is requested.
|
||||
bool vp9_automatic_resize = automatic_resize;
|
||||
absl::optional<int> num_spatial_layers =
|
||||
NumSpatialLayersFromEncoding(rtp_parameters_, /*idx=*/0);
|
||||
if (num_spatial_layers && *num_spatial_layers > 1) {
|
||||
vp9_automatic_resize = false;
|
||||
}
|
||||
vp9_settings.automaticResizeOn = vp9_automatic_resize;
|
||||
if (!is_screencast) {
|
||||
webrtc::FieldTrialFlag interlayer_pred_experiment_enabled("Enabled");
|
||||
webrtc::FieldTrialEnum<webrtc::InterLayerPredMode> inter_layer_pred_mode(
|
||||
|
||||
@ -3536,19 +3536,51 @@ TEST_F(Vp9SettingsTest, VerifyVp9SpecificSettings) {
|
||||
ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
|
||||
EXPECT_TRUE(vp9_settings.denoisingOn)
|
||||
<< "VP9 denoising should be on by default.";
|
||||
EXPECT_TRUE(vp9_settings.automaticResizeOn)
|
||||
<< "Automatic resize on for one active stream.";
|
||||
|
||||
stream = SetDenoisingOption(last_ssrc_, &frame_forwarder, false);
|
||||
|
||||
ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
|
||||
EXPECT_FALSE(vp9_settings.denoisingOn);
|
||||
// Frame dropping always on for real time video.
|
||||
EXPECT_TRUE(stream->GetEncoderConfig().frame_drop_enabled);
|
||||
EXPECT_TRUE(stream->GetEncoderConfig().frame_drop_enabled)
|
||||
<< "Frame dropping always on for real time video.";
|
||||
EXPECT_TRUE(vp9_settings.automaticResizeOn);
|
||||
|
||||
stream = SetDenoisingOption(last_ssrc_, &frame_forwarder, true);
|
||||
|
||||
ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
|
||||
EXPECT_TRUE(vp9_settings.denoisingOn);
|
||||
EXPECT_TRUE(stream->GetEncoderConfig().frame_drop_enabled);
|
||||
EXPECT_TRUE(vp9_settings.automaticResizeOn);
|
||||
|
||||
webrtc::RtpParameters rtp_parameters =
|
||||
channel_->GetRtpSendParameters(last_ssrc_);
|
||||
EXPECT_THAT(
|
||||
rtp_parameters.encodings,
|
||||
ElementsAre(Field(&webrtc::RtpEncodingParameters::scalability_mode,
|
||||
absl::nullopt)));
|
||||
rtp_parameters.encodings[0].scalability_mode = "L2T1";
|
||||
EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, rtp_parameters).ok());
|
||||
|
||||
ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
|
||||
EXPECT_TRUE(vp9_settings.denoisingOn);
|
||||
EXPECT_TRUE(stream->GetEncoderConfig().frame_drop_enabled);
|
||||
EXPECT_FALSE(vp9_settings.automaticResizeOn)
|
||||
<< "Automatic resize off for multiple spatial layers.";
|
||||
|
||||
rtp_parameters = channel_->GetRtpSendParameters(last_ssrc_);
|
||||
EXPECT_THAT(rtp_parameters.encodings,
|
||||
ElementsAre(Field(
|
||||
&webrtc::RtpEncodingParameters::scalability_mode, "L2T1")));
|
||||
rtp_parameters.encodings[0].scalability_mode = "L1T1";
|
||||
EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, rtp_parameters).ok());
|
||||
|
||||
ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
|
||||
EXPECT_TRUE(vp9_settings.denoisingOn);
|
||||
EXPECT_TRUE(stream->GetEncoderConfig().frame_drop_enabled);
|
||||
EXPECT_TRUE(vp9_settings.automaticResizeOn)
|
||||
<< "Automatic resize on for one spatial layer.";
|
||||
|
||||
// In screen-share mode, denoising is forced off.
|
||||
VideoOptions options;
|
||||
@ -3559,14 +3591,17 @@ TEST_F(Vp9SettingsTest, VerifyVp9SpecificSettings) {
|
||||
|
||||
ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
|
||||
EXPECT_FALSE(vp9_settings.denoisingOn);
|
||||
// Frame dropping always on for screen sharing.
|
||||
EXPECT_TRUE(stream->GetEncoderConfig().frame_drop_enabled);
|
||||
EXPECT_TRUE(stream->GetEncoderConfig().frame_drop_enabled)
|
||||
<< "Frame dropping always on for screen sharing.";
|
||||
EXPECT_FALSE(vp9_settings.automaticResizeOn)
|
||||
<< "Automatic resize off for screencast.";
|
||||
|
||||
stream = SetDenoisingOption(last_ssrc_, &frame_forwarder, false);
|
||||
|
||||
ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
|
||||
EXPECT_FALSE(vp9_settings.denoisingOn);
|
||||
EXPECT_TRUE(stream->GetEncoderConfig().frame_drop_enabled);
|
||||
EXPECT_FALSE(vp9_settings.automaticResizeOn);
|
||||
|
||||
EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, nullptr, nullptr));
|
||||
}
|
||||
|
||||
@ -139,6 +139,43 @@ absl::string_view ScalabilityModeToString(ScalabilityMode scalability_mode) {
|
||||
RTC_CHECK_NOTREACHED();
|
||||
}
|
||||
|
||||
int ScalabilityModeToNumSpatialLayers(ScalabilityMode scalability_mode) {
|
||||
switch (scalability_mode) {
|
||||
case ScalabilityMode::kL1T1:
|
||||
case ScalabilityMode::kL1T2:
|
||||
case ScalabilityMode::kL1T2h:
|
||||
case ScalabilityMode::kL1T3:
|
||||
case ScalabilityMode::kL1T3h:
|
||||
return 1;
|
||||
case ScalabilityMode::kL2T1:
|
||||
case ScalabilityMode::kL2T1h:
|
||||
case ScalabilityMode::kL2T1_KEY:
|
||||
case ScalabilityMode::kL2T2:
|
||||
case ScalabilityMode::kL2T2h:
|
||||
case ScalabilityMode::kL2T2_KEY:
|
||||
case ScalabilityMode::kL2T2_KEY_SHIFT:
|
||||
case ScalabilityMode::kL2T3:
|
||||
case ScalabilityMode::kL2T3h:
|
||||
case ScalabilityMode::kL2T3_KEY:
|
||||
return 2;
|
||||
case ScalabilityMode::kL3T1:
|
||||
case ScalabilityMode::kL3T1h:
|
||||
case ScalabilityMode::kL3T1_KEY:
|
||||
case ScalabilityMode::kL3T2:
|
||||
case ScalabilityMode::kL3T2h:
|
||||
case ScalabilityMode::kL3T2_KEY:
|
||||
case ScalabilityMode::kL3T3:
|
||||
case ScalabilityMode::kL3T3h:
|
||||
case ScalabilityMode::kL3T3_KEY:
|
||||
return 3;
|
||||
case ScalabilityMode::kS2T1:
|
||||
return 2;
|
||||
case ScalabilityMode::kS3T3:
|
||||
return 3;
|
||||
}
|
||||
RTC_CHECK_NOTREACHED();
|
||||
}
|
||||
|
||||
int ScalabilityModeToNumTemporalLayers(ScalabilityMode scalability_mode) {
|
||||
switch (scalability_mode) {
|
||||
case ScalabilityMode::kL1T1:
|
||||
|
||||
@ -22,6 +22,8 @@ absl::optional<ScalabilityMode> ScalabilityModeFromString(
|
||||
|
||||
absl::string_view ScalabilityModeToString(ScalabilityMode scalability_mode);
|
||||
|
||||
int ScalabilityModeToNumSpatialLayers(ScalabilityMode scalability_mode);
|
||||
|
||||
int ScalabilityModeToNumTemporalLayers(ScalabilityMode scalability_mode);
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user