From 99fb5945b9c278cf33ef434ebacd5dfb9bde865d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98Michael?= Date: Fri, 6 Aug 2021 09:02:29 -0500 Subject: [PATCH] Updated the default VP9 per-spatial-temporal layer settings. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:11551 Change-Id: If2029df444f576b41bfef302985d6e18d7cdc3b5 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227782 Commit-Queue: Michael Horowitz Reviewed-by: Erik Språng Cr-Commit-Position: refs/heads/master@{#34668} --- .../codecs/vp9/libvpx_vp9_encoder.cc | 14 ++++--- .../codecs/vp9/test/vp9_impl_unittest.cc | 38 ++----------------- 2 files changed, 13 insertions(+), 39 deletions(-) diff --git a/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc b/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc index f29ad927f2..616c3bca40 100644 --- a/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc +++ b/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc @@ -1851,17 +1851,21 @@ LibvpxVp9Encoder::ParsePerformanceFlagsFromTrials( LibvpxVp9Encoder::PerformanceFlags LibvpxVp9Encoder::GetDefaultPerformanceFlags() { PerformanceFlags flags; - flags.use_per_layer_speed = false; + flags.use_per_layer_speed = true; #if defined(WEBRTC_ARCH_ARM) || defined(WEBRTC_ARCH_ARM64) || defined(ANDROID) // Speed 8 on all layers for all resolutions. flags.settings_by_resolution[0] = {8, 8, 0}; #else - // For smaller resolutions, use lower speed setting (get some coding gain at - // the cost of increased encoding complexity). - flags.settings_by_resolution[0] = {5, 5, 0}; + // For smaller resolutions, use lower speed setting for the temporal base + // layer (get some coding gain at the cost of increased encoding complexity). + // Set encoder Speed 5 for TL0, encoder Speed 8 for upper temporal layers, and + // disable deblocking for upper-most temporal layers. + flags.settings_by_resolution[0] = {5, 8, 1}; // Use speed 7 for QCIF and above. - flags.settings_by_resolution[352 * 288] = {7, 7, 0}; + // Set encoder Speed 7 for TL0, encoder Speed 8 for upper temporal layers, and + // enable deblocking for all temporal layers. + flags.settings_by_resolution[352 * 288] = {7, 8, 0}; #endif return flags; } 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 e96538427b..54d7b52868 100644 --- a/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc +++ b/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc @@ -2205,36 +2205,6 @@ GetWrapImageFunction(vpx_image_t* img) { }; } -TEST(Vp9SpeedSettingsTrialsTest, SvcExtraCfgNotPopulatedByDefault) { - test::ExplicitKeyValueConfig trials(""); - - // Keep a raw pointer for EXPECT calls and the like. Ownership is otherwise - // passed on to LibvpxVp9Encoder. - auto* const vpx = new NiceMock(); - LibvpxVp9Encoder encoder(cricket::VideoCodec(), - absl::WrapUnique(vpx), trials); - - VideoCodec settings = DefaultCodecSettings(); - // Configure 3 spatial and three temporal ayers. - ConfigureSvc(settings, 3, 3); - vpx_image_t img; - - ON_CALL(*vpx, img_wrap).WillByDefault(GetWrapImageFunction(&img)); - ON_CALL(*vpx, codec_enc_config_default) - .WillByDefault(DoAll(WithArg<1>([](vpx_codec_enc_cfg_t* cfg) { - memset(cfg, 0, sizeof(vpx_codec_enc_cfg_t)); - }), - Return(VPX_CODEC_OK))); - EXPECT_CALL(*vpx, - codec_control( - _, VP9E_SET_SVC_PARAMETERS, - SafeMatcherCast(AllOf( - Field(&vpx_svc_extra_cfg_t::speed_per_layer, Each(0)), - Field(&vpx_svc_extra_cfg_t::loopfilter_ctrl, Each(0)))))); - - EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder.InitEncode(&settings, kSettings)); -} - TEST(Vp9SpeedSettingsTrialsTest, NoSvcUsesGlobalSpeedFromTl0InLayerConfig) { // TL0 speed 8 at >= 480x270, 5 if below that. test::ExplicitKeyValueConfig trials( @@ -2333,10 +2303,10 @@ TEST(Vp9SpeedSettingsTrialsTest, EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder.InitEncode(&settings, kSettings)); } -TEST(Vp9SpeedSettingsTrialsTest, PerLayerFlagsWithSvc) { +TEST(Vp9SpeedSettingsTrialsTest, DefaultPerLayerFlagsWithSvc) { // Per-temporal and spatial layer speed settings: // SL0: TL0 = speed 5, TL1/TL2 = speed 8. - // SL1/2: TL0 = speed 7, TL1/TL2 = speed 9. + // SL1/2: TL0 = speed 7, TL1/TL2 = speed 8. // Deblocking-mode per spatial layer: // SL0: mode 1, SL1/2: mode 0. test::ExplicitKeyValueConfig trials( @@ -2344,7 +2314,7 @@ TEST(Vp9SpeedSettingsTrialsTest, PerLayerFlagsWithSvc) { "use_per_layer_speed," "min_pixel_count:0|129600," "base_layer_speed:5|7," - "high_layer_speed:8|9," + "high_layer_speed:8|8," "deblock_mode:1|0/"); // Keep a raw pointer for EXPECT calls and the like. Ownership is otherwise @@ -2361,7 +2331,7 @@ TEST(Vp9SpeedSettingsTrialsTest, PerLayerFlagsWithSvc) { // Speed settings per spatial layer, for TL0. const int kBaseTlSpeed[VPX_MAX_LAYERS] = {5, 7, 7}; // Speed settings per spatial layer, for TL1, TL2. - const int kHighTlSpeed[VPX_MAX_LAYERS] = {8, 9, 9}; + const int kHighTlSpeed[VPX_MAX_LAYERS] = {8, 8, 8}; // Loopfilter settings are handled within libvpx, so this array is valid for // both TL0 and higher. const int kLoopFilter[VPX_MAX_LAYERS] = {1, 0, 0};