From 058972f84ea4ccd2d9c20d25824fbf15d5a72a04 Mon Sep 17 00:00:00 2001 From: Sergey Silkin Date: Thu, 29 Aug 2024 09:47:17 +0200 Subject: [PATCH] Make LAYER_DROP and max_consec_drop=2 to be default settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on the results of the experiment (b/335129329). Bug: webrtc:15827, b/320629637, b/335129329, chromium:329396373 Change-Id: I1599f4c1be79ee3385aac1ff345168982c8278f8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/360960 Commit-Queue: Erik Språng Reviewed-by: Erik Språng Auto-Submit: Sergey Silkin Cr-Commit-Position: refs/heads/main@{#42895} --- experiments/field_trials.py | 3 -- .../codecs/vp9/libvpx_vp9_encoder.cc | 35 ++---------- .../codecs/vp9/libvpx_vp9_encoder.h | 8 --- .../codecs/vp9/test/vp9_impl_unittest.cc | 54 ++++--------------- 4 files changed, 15 insertions(+), 85 deletions(-) diff --git a/experiments/field_trials.py b/experiments/field_trials.py index 06969ebdf1..c6b6da6e2f 100755 --- a/experiments/field_trials.py +++ b/experiments/field_trials.py @@ -98,9 +98,6 @@ ACTIVE_FIELD_TRIALS: FrozenSet[FieldTrial] = frozenset([ FieldTrial('WebRTC-LibaomAv1Encoder-AdaptiveMaxConsecDrops', 351644568, date(2025, 7, 1)), - FieldTrial('WebRTC-LibvpxVp9Encoder-SvcFrameDropConfig', - 42226190, - date(2024, 9, 1)), FieldTrial('WebRTC-LibvpxVp8Encoder-AndroidSpecificThreadingSettings', 42226191, date(2024, 9, 1)), diff --git a/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc b/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc index fc3640cee0..7a2b4940fe 100644 --- a/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc +++ b/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc @@ -263,8 +263,7 @@ LibvpxVp9Encoder::LibvpxVp9Encoder(const Environment& env, performance_flags_(ParsePerformanceFlagsFromTrials(env.field_trials())), num_steady_state_frames_(0), config_changed_(true), - encoder_info_override_(env.field_trials()), - svc_frame_drop_config_(ParseSvcFrameDropConfig(env.field_trials())) { + encoder_info_override_(env.field_trials()) { codec_ = {}; memset(&svc_params_, 0, sizeof(vpx_svc_extra_cfg_t)); } @@ -845,8 +844,7 @@ int LibvpxVp9Encoder::InitAndSetControlSettings(const VideoCodec* inst) { memset(&svc_drop_frame_, 0, sizeof(svc_drop_frame_)); const bool reverse_constrained_drop_mode = inter_layer_pred_ == InterLayerPredMode::kOn && - codec_.mode == VideoCodecMode::kScreensharing && - num_spatial_layers_ > 1; + codec_.mode == VideoCodecMode::kScreensharing; if (reverse_constrained_drop_mode) { // Screenshare dropping mode: drop a layer only together with all lower // layers. This ensures that drops on lower layers won't reduce frame-rate @@ -857,9 +855,7 @@ int LibvpxVp9Encoder::InitAndSetControlSettings(const VideoCodec* inst) { svc_drop_frame_.framedrop_thresh[i] = config_->rc_dropframe_thresh; } } else { - if (svc_frame_drop_config_.enabled && - svc_frame_drop_config_.layer_drop_mode == LAYER_DROP && - is_flexible_mode_ && svc_controller_ && + if (is_flexible_mode_ && svc_controller_ && (inter_layer_pred_ == InterLayerPredMode::kOff || inter_layer_pred_ == InterLayerPredMode::kOnKeyPic)) { // SVC controller is required since it properly accounts for dropped @@ -871,10 +867,7 @@ int LibvpxVp9Encoder::InitAndSetControlSettings(const VideoCodec* inst) { // quality flickering and is not compatible with RTP non-flexible mode. svc_drop_frame_.framedrop_mode = FULL_SUPERFRAME_DROP; } - svc_drop_frame_.max_consec_drop = - svc_frame_drop_config_.enabled - ? svc_frame_drop_config_.max_consec_drop - : std::numeric_limits::max(); + svc_drop_frame_.max_consec_drop = 2; for (size_t i = 0; i < num_spatial_layers_; ++i) { svc_drop_frame_.framedrop_thresh[i] = config_->rc_dropframe_thresh; } @@ -1846,26 +1839,6 @@ LibvpxVp9Encoder::ParseQualityScalerConfig(const FieldTrialsView& trials) { return config; } -LibvpxVp9Encoder::SvcFrameDropConfig LibvpxVp9Encoder::ParseSvcFrameDropConfig( - const FieldTrialsView& trials) { - FieldTrialFlag enabled = FieldTrialFlag("Enabled"); - FieldTrialParameter layer_drop_mode("layer_drop_mode", - FULL_SUPERFRAME_DROP); - FieldTrialParameter max_consec_drop("max_consec_drop", - std::numeric_limits::max()); - ParseFieldTrial({&enabled, &layer_drop_mode, &max_consec_drop}, - trials.Lookup("WebRTC-LibvpxVp9Encoder-SvcFrameDropConfig")); - SvcFrameDropConfig config; - config.enabled = enabled.Get(); - config.layer_drop_mode = layer_drop_mode.Get(); - config.max_consec_drop = max_consec_drop.Get(); - RTC_LOG(LS_INFO) << "Libvpx VP9 encoder SVC frame drop config: " - << (config.enabled ? "enabled" : "disabled") - << " layer_drop_mode " << config.layer_drop_mode - << " max_consec_drop " << config.max_consec_drop; - return config; -} - void LibvpxVp9Encoder::UpdatePerformanceFlags() { flat_map params_by_resolution; if (codec_.GetVideoEncoderComplexity() == diff --git a/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.h b/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.h index 0134e3ea58..f83fe2de80 100644 --- a/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.h +++ b/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.h @@ -222,14 +222,6 @@ class LibvpxVp9Encoder : public VideoEncoder { bool config_changed_; const LibvpxVp9EncoderInfoSettings encoder_info_override_; - - const struct SvcFrameDropConfig { - bool enabled; - int layer_drop_mode; // SVC_LAYER_DROP_MODE - int max_consec_drop; - } svc_frame_drop_config_; - static SvcFrameDropConfig ParseSvcFrameDropConfig( - const FieldTrialsView& trials); }; } // namespace webrtc diff --git a/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc b/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc index ae53001957..26326106e4 100644 --- a/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc +++ b/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc @@ -2480,68 +2480,36 @@ INSTANTIATE_TEST_SUITE_P( All, TestVp9ImplSvcFrameDropConfig, ::testing::Values( - // Flexible mode is disabled. Layer drop is not allowed. Ignore - // layer_drop_mode from field trial. + // Flexible mode is disabled, KSVC. Layer drop is not allowed. SvcFrameDropConfigTestParameters{ .flexible_mode = false, .scalability_mode = ScalabilityMode::kL3T3_KEY, - .field_trial = "WebRTC-LibvpxVp9Encoder-SvcFrameDropConfig/" - "Enabled,layer_drop_mode:1,max_consec_drop:7/", .expected_framedrop_mode = FULL_SUPERFRAME_DROP, - .expected_max_consec_drop = 7}, - // Flexible mode is enabled but the field trial is not set. Use default - // settings. + .expected_max_consec_drop = 2}, + // Flexible mode is enabled, KSVC. Layer drop is enabled. SvcFrameDropConfigTestParameters{ .flexible_mode = true, .scalability_mode = ScalabilityMode::kL3T3_KEY, - .field_trial = "", - .expected_framedrop_mode = FULL_SUPERFRAME_DROP, - .expected_max_consec_drop = std::numeric_limits::max()}, - // Flexible mode is enabled but the field trial is disabled. Use default - // settings. - SvcFrameDropConfigTestParameters{ - .flexible_mode = true, - .scalability_mode = ScalabilityMode::kL3T3_KEY, - .field_trial = "WebRTC-LibvpxVp9Encoder-SvcFrameDropConfig/" - "Disabled,layer_drop_mode:1,max_consec_drop:7/", - .expected_framedrop_mode = FULL_SUPERFRAME_DROP, - .expected_max_consec_drop = std::numeric_limits::max()}, - // Flexible mode is enabled, layer drop is enabled, KSVC. Apply config - // from field trial. - SvcFrameDropConfigTestParameters{ - .flexible_mode = true, - .scalability_mode = ScalabilityMode::kL3T3_KEY, - .field_trial = "WebRTC-LibvpxVp9Encoder-SvcFrameDropConfig/" - "Enabled,layer_drop_mode:1,max_consec_drop:7/", .expected_framedrop_mode = LAYER_DROP, - .expected_max_consec_drop = 7}, - // Flexible mode is enabled, layer drop is enabled, simulcast. Apply - // config from field trial. + .expected_max_consec_drop = 2}, + // Flexible mode is enabled, simulcast. Layer drop is enabled. SvcFrameDropConfigTestParameters{ .flexible_mode = true, .scalability_mode = ScalabilityMode::kS3T3, - .field_trial = "WebRTC-LibvpxVp9Encoder-SvcFrameDropConfig/" - "Enabled,layer_drop_mode:1,max_consec_drop:7/", .expected_framedrop_mode = LAYER_DROP, - .expected_max_consec_drop = 7}, - // Flexible mode is enabled, layer drop is enabled, full SVC. Apply - // config from field trial. + .expected_max_consec_drop = 2}, + // Flexible mode is enabled, full SVC. Layer drop is not allowed. SvcFrameDropConfigTestParameters{ .flexible_mode = false, .scalability_mode = ScalabilityMode::kL3T3, - .field_trial = "WebRTC-LibvpxVp9Encoder-SvcFrameDropConfig/" - "Enabled,layer_drop_mode:1,max_consec_drop:7/", .expected_framedrop_mode = FULL_SUPERFRAME_DROP, - .expected_max_consec_drop = 7}, - // Flexible mode is enabled, layer-drop is enabled, scalability mode is - // not set (i.e., SVC controller is not enabled). Ignore layer_drop_mode - // from field trial. + .expected_max_consec_drop = 2}, + // Flexible mode is enabled, scalability mode is not set (i.e., SVC + // controller is not enabled). Layer drop is not allowed. SvcFrameDropConfigTestParameters{ .flexible_mode = true, .scalability_mode = absl::nullopt, - .field_trial = "WebRTC-LibvpxVp9Encoder-SvcFrameDropConfig/" - "Enabled,layer_drop_mode:1,max_consec_drop:7/", .expected_framedrop_mode = FULL_SUPERFRAME_DROP, - .expected_max_consec_drop = 7})); + .expected_max_consec_drop = 2})); } // namespace webrtc