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}
This commit is contained in:
committed by
Commit Bot
parent
2a8f226374
commit
dabe48bb4c
@ -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 @@ void ApplyVp8EncoderConfigToVpxConfig(const Vp8EncoderConfig& encoder_config,
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ LibvpxVp8Encoder::LibvpxVp8Encoder(std::unique_ptr<LibvpxInterface> interface,
|
||||
: 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 @@ VideoEncoder::EncoderInfo LibvpxVp8Encoder::GetEncoderInfo() const {
|
||||
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 &&
|
||||
|
||||
@ -99,6 +99,9 @@ class LibvpxVp8Encoder : public VideoEncoder {
|
||||
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;
|
||||
|
||||
@ -565,6 +565,19 @@ TEST(LibvpxVp8EncoderTest, GetEncoderInfoReturnsStaticInformation) {
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user