From 3101666d2a8b5b2e6bff14ffb39db685f1cc98a0 Mon Sep 17 00:00:00 2001 From: Marco Paniconi Date: Tue, 16 Jun 2020 11:41:00 -0700 Subject: [PATCH] vp9-svc: Add svc test for denoiser and dynamic resize This catches the assert/crash fixed in 5174eb5. Also fix to only check for dynamic resize in SVC mode for base temporal layer. Change-Id: Ie6eb7d233cc43eafb1b78cec4aeb94fb4d7fe11a --- test/svc_datarate_test.cc | 56 +++++++++++++++++++++++++++++++++++--- vp9/encoder/vp9_ratectrl.c | 3 +- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/test/svc_datarate_test.cc b/test/svc_datarate_test.cc index 7260d8ec8..1920debfc 100644 --- a/test/svc_datarate_test.cc +++ b/test/svc_datarate_test.cc @@ -354,6 +354,20 @@ class DatarateOnePassCbrSvc : public OnePassCbrSvc { cfg_.rc_target_bitrate = cfg_.layer_target_bitrate[0]; encoder->Config(&cfg_); } + } else if (!dynamic_drop_layer_ && single_layer_resize_) { + if (video->frame() == 2) { + cfg_.layer_target_bitrate[0] = 30; + cfg_.layer_target_bitrate[1] = 50; + cfg_.rc_target_bitrate = + (cfg_.layer_target_bitrate[0] + cfg_.layer_target_bitrate[1]); + encoder->Config(&cfg_); + } else if (video->frame() == 160) { + cfg_.layer_target_bitrate[0] = 1500; + cfg_.layer_target_bitrate[1] = 2000; + cfg_.rc_target_bitrate = + (cfg_.layer_target_bitrate[0] + cfg_.layer_target_bitrate[1]); + encoder->Config(&cfg_); + } } if (force_key_test_ && force_key_) frame_flags_ = VPX_EFLAG_FORCE_KF; @@ -452,10 +466,12 @@ class DatarateOnePassCbrSvc : public OnePassCbrSvc { parse_superframe_index(static_cast(pkt->data.frame.buf), pkt->data.frame.sz, sizes_parsed, &count); // Count may be less than number of spatial layers because of frame drops. - for (int sl = 0; sl < number_spatial_layers_; ++sl) { - if (pkt->data.frame.spatial_layer_encoded[sl]) { - sizes[sl] = sizes_parsed[num_layers_encoded]; - num_layers_encoded++; + if (number_spatial_layers_ > 1) { + for (int sl = 0; sl < number_spatial_layers_; ++sl) { + if (pkt->data.frame.spatial_layer_encoded[sl]) { + sizes[sl] = sizes_parsed[num_layers_encoded]; + num_layers_encoded++; + } } } // For superframe with Intra-only count will be +1 larger @@ -875,6 +891,38 @@ TEST_P(DatarateOnePassCbrSvcSingleBR, OnePassCbrSvc2SL_SingleLayerResize) { #endif } +// For pass CBR SVC with 1 spatial and 2 temporal layers with dynamic resize +// and denoiser enabled. The resizer will resize the single layer down and back +// up again, as the bitrate goes back up. +TEST_P(DatarateOnePassCbrSvcSingleBR, OnePassCbrSvc1SL2TL_DenoiseResize) { + SetSvcConfig(1, 2); + cfg_.rc_buf_initial_sz = 500; + cfg_.rc_buf_optimal_sz = 500; + cfg_.rc_buf_sz = 1000; + cfg_.rc_min_quantizer = 0; + cfg_.rc_max_quantizer = 63; + cfg_.g_threads = 1; + cfg_.temporal_layering_mode = 2; + cfg_.rc_dropframe_thresh = 30; + cfg_.kf_max_dist = 9999; + cfg_.rc_resize_allowed = 1; + ::libvpx_test::I420VideoSource video("desktop_office1.1280_720-020.yuv", 1280, + 720, 12, 1, 0, 300); + top_sl_width_ = 1280; + top_sl_height_ = 720; + cfg_.rc_target_bitrate = 800; + ResetModel(); + dynamic_drop_layer_ = false; + single_layer_resize_ = true; + denoiser_on_ = 1; + base_speed_setting_ = speed_setting_; + AssignLayerBitrates(); + ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); + // Expect at least one resize down and at least one resize back up. + EXPECT_GE(num_resize_down_, 1); + EXPECT_GE(num_resize_up_, 1); +} + // Run SVC encoder for 1 temporal layer, 2 spatial layers, with spatial // downscale 5x5. TEST_P(DatarateOnePassCbrSvcSingleBR, OnePassCbrSvc2SL1TL5x5MultipleRuns) { diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index 2d03bad4d..2a279d4fc 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -2376,7 +2376,8 @@ void vp9_rc_get_svc_params(VP9_COMP *cpi) { if (cm->show_frame) update_buffer_level_svc_preencode(cpi); if (cpi->oxcf.resize_mode == RESIZE_DYNAMIC && svc->single_layer_svc == 1 && - svc->spatial_layer_id == svc->first_spatial_layer_to_encode) { + svc->spatial_layer_id == svc->first_spatial_layer_to_encode && + svc->temporal_layer_id == 0) { LAYER_CONTEXT *lc = NULL; cpi->resize_pending = vp9_resize_one_pass_cbr(cpi); if (cpi->resize_pending) { -- 2.40.0