diff --git a/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc b/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc index 616c3bca40..f29ad927f2 100644 --- a/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc +++ b/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc @@ -1851,21 +1851,17 @@ LibvpxVp9Encoder::ParsePerformanceFlagsFromTrials( LibvpxVp9Encoder::PerformanceFlags LibvpxVp9Encoder::GetDefaultPerformanceFlags() { PerformanceFlags flags; - flags.use_per_layer_speed = true; + flags.use_per_layer_speed = false; #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 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}; + // 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}; // Use speed 7 for QCIF and above. - // 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}; + flags.settings_by_resolution[352 * 288] = {7, 7, 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 54d7b52868..e96538427b 100644 --- a/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc +++ b/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc @@ -2205,6 +2205,36 @@ 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( @@ -2303,10 +2333,10 @@ TEST(Vp9SpeedSettingsTrialsTest, EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder.InitEncode(&settings, kSettings)); } -TEST(Vp9SpeedSettingsTrialsTest, DefaultPerLayerFlagsWithSvc) { +TEST(Vp9SpeedSettingsTrialsTest, PerLayerFlagsWithSvc) { // Per-temporal and spatial layer speed settings: // SL0: TL0 = speed 5, TL1/TL2 = speed 8. - // SL1/2: TL0 = speed 7, TL1/TL2 = speed 8. + // SL1/2: TL0 = speed 7, TL1/TL2 = speed 9. // Deblocking-mode per spatial layer: // SL0: mode 1, SL1/2: mode 0. test::ExplicitKeyValueConfig trials( @@ -2314,7 +2344,7 @@ TEST(Vp9SpeedSettingsTrialsTest, DefaultPerLayerFlagsWithSvc) { "use_per_layer_speed," "min_pixel_count:0|129600," "base_layer_speed:5|7," - "high_layer_speed:8|8," + "high_layer_speed:8|9," "deblock_mode:1|0/"); // Keep a raw pointer for EXPECT calls and the like. Ownership is otherwise @@ -2331,7 +2361,7 @@ TEST(Vp9SpeedSettingsTrialsTest, DefaultPerLayerFlagsWithSvc) { // 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, 8, 8}; + const int kHighTlSpeed[VPX_MAX_LAYERS] = {8, 9, 9}; // 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};