Add WebRTC-VP8-GetEncoderInfoOverride field trial to libvpx.
This trial allows the downstream users to quickly set the
requested resolution alignment.
Bug: webrtc:11832
Change-Id: I55b3213179021455740311247829b44926722efe
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/180884
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Commit-Queue: Rasmus Brandt <brandtr@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31857}
diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
index 9b64d16..2f901ad 100644
--- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
+++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
@@ -44,12 +44,17 @@
namespace webrtc {
namespace {
#if defined(WEBRTC_IOS)
-const char kVP8IosMaxNumberOfThreadFieldTrial[] =
+constexpr char kVP8IosMaxNumberOfThreadFieldTrial[] =
"WebRTC-VP8IosMaxNumberOfThread";
-const char kVP8IosMaxNumberOfThreadFieldTrialParameter[] = "max_thread";
+constexpr char kVP8IosMaxNumberOfThreadFieldTrialParameter[] = "max_thread";
#endif
-const char kVp8ForcePartitionResilience[] =
+constexpr char kVp8GetEncoderInfoOverrideFieldTrial[] =
+ "WebRTC-VP8-GetEncoderInfoOverride";
+constexpr char kVp8RequestedResolutionAlignmentFieldTrialParameter[] =
+ "requested_resolution_alignment";
+
+constexpr char kVp8ForcePartitionResilience[] =
"WebRTC-VP8-ForcePartitionResilience";
// QP is obtained from VP8-bitstream for HW, so the QP corresponds to the
@@ -222,6 +227,15 @@
}
}
+absl::optional<int> GetRequestedResolutionAlignmentOverride() {
+ const std::string trial_string =
+ field_trial::FindFullName(kVp8GetEncoderInfoOverrideFieldTrial);
+ FieldTrialOptional<int> requested_resolution_alignment(
+ kVp8RequestedResolutionAlignmentFieldTrialParameter);
+ ParseFieldTrial({&requested_resolution_alignment}, trial_string);
+ return requested_resolution_alignment.GetOptional();
+}
+
} // namespace
std::unique_ptr<VideoEncoder> VP8Encoder::Create() {
@@ -279,6 +293,8 @@
: libvpx_(std::move(interface)),
experimental_cpu_speed_config_arm_(CpuSpeedExperiment::GetConfigs()),
rate_control_settings_(RateControlSettings::ParseFromFieldTrials()),
+ requested_resolution_alignment_override_(
+ GetRequestedResolutionAlignmentOverride()),
frame_buffer_controller_factory_(
std::move(settings.frame_buffer_controller_factory)),
resolution_bitrate_limits_(std::move(settings.resolution_bitrate_limits)),
@@ -1233,6 +1249,10 @@
if (!resolution_bitrate_limits_.empty()) {
info.resolution_bitrate_limits = resolution_bitrate_limits_;
}
+ if (requested_resolution_alignment_override_) {
+ info.requested_resolution_alignment =
+ *requested_resolution_alignment_override_;
+ }
const bool enable_scaling =
num_active_streams_ == 1 &&
diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h
index 8afcaae..f6cfd0f 100644
--- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h
+++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h
@@ -99,6 +99,9 @@
experimental_cpu_speed_config_arm_;
const RateControlSettings rate_control_settings_;
+ // EncoderInfo::requested_resolution_alignment override from field trial.
+ const absl::optional<int> requested_resolution_alignment_override_;
+
EncodedImageCallback* encoded_complete_callback_ = nullptr;
VideoCodec codec_;
bool inited_ = false;
diff --git a/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc b/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc
index d3e4a17..342187b 100644
--- a/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc
+++ b/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc
@@ -565,6 +565,19 @@
EXPECT_FALSE(info.has_internal_source);
EXPECT_TRUE(info.supports_simulcast);
EXPECT_EQ(info.implementation_name, "libvpx");
+ EXPECT_EQ(info.requested_resolution_alignment, 1);
+}
+
+TEST(LibvpxVp8EncoderTest, RequestedResolutionAlignmentFromFieldTrial) {
+ test::ScopedFieldTrials field_trials(
+ "WebRTC-VP8-GetEncoderInfoOverride/"
+ "requested_resolution_alignment:10/");
+
+ auto* const vpx = new NiceMock<MockLibvpxVp8Interface>();
+ LibvpxVp8Encoder encoder((std::unique_ptr<LibvpxInterface>(vpx)),
+ VP8Encoder::Settings());
+
+ EXPECT_EQ(encoder.GetEncoderInfo().requested_resolution_alignment, 10);
}
TEST(LibvpxVp8EncoderTest,