From: Jerome Jiang Date: Fri, 8 Jun 2018 01:05:23 +0000 (-0700) Subject: vp9: Enable cyclic refresh for HBD in real-time. X-Git-Tag: v1.8.0~600^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=59c41b7814f1a5a4ba63392313de03ae6c9cf802;p=libvpx vp9: Enable cyclic refresh for HBD in real-time. Keep denoiser and skin detection disabled since some key functions don't work with >8 bits source. Add test for HBD with denoiser and cyclic refresh enabled to make sure nothing crashes. BUG=webm:1534 Change-Id: Id61fe1e38ed1768f273870a6bdd5f163aa769fe4 --- diff --git a/test/vp9_end_to_end_test.cc b/test/vp9_end_to_end_test.cc index d0cbfbbda..90a60c2f3 100644 --- a/test/vp9_end_to_end_test.cc +++ b/test/vp9_end_to_end_test.cc @@ -63,7 +63,7 @@ const libvpx_test::TestMode kEncodingModeVectors[] = { }; // Speed settings tested -const int kCpuUsedVectors[] = { 1, 2, 3, 5, 6 }; +const int kCpuUsedVectors[] = { 1, 2, 3, 5, 6, 7 }; int is_extension_y4m(const char *filename) { const char *dot = strrchr(filename, '.'); @@ -82,7 +82,10 @@ class EndToEndTestLarge EndToEndTestLarge() : EncoderTest(GET_PARAM(0)), test_video_param_(GET_PARAM(2)), cpu_used_(GET_PARAM(3)), psnr_(0.0), nframes_(0), - encoding_mode_(GET_PARAM(1)) {} + encoding_mode_(GET_PARAM(1)) { + cyclic_refresh_ = 0; + denoiser_on_ = 0; + } virtual ~EndToEndTestLarge() {} @@ -123,6 +126,9 @@ class EndToEndTestLarge encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7); encoder->Control(VP8E_SET_ARNR_STRENGTH, 5); encoder->Control(VP8E_SET_ARNR_TYPE, 3); + } else { + encoder->Control(VP9E_SET_NOISE_SENSITIVITY, denoiser_on_); + encoder->Control(VP9E_SET_AQ_MODE, cyclic_refresh_); } } } @@ -138,6 +144,8 @@ class EndToEndTestLarge TestVideoParam test_video_param_; int cpu_used_; + int cyclic_refresh_; + int denoiser_on_; private: double psnr_; @@ -170,6 +178,33 @@ TEST_P(EndToEndTestLarge, EndtoEndPSNRTest) { EXPECT_GT(psnr, GetPsnrThreshold()); } +TEST_P(EndToEndTestLarge, EndtoEndPSNRDenoiserAQTest) { + cfg_.rc_target_bitrate = kBitrate; + cfg_.g_error_resilient = 0; + cfg_.g_profile = test_video_param_.profile; + cfg_.g_input_bit_depth = test_video_param_.input_bit_depth; + cfg_.g_bit_depth = test_video_param_.bit_depth; + init_flags_ = VPX_CODEC_USE_PSNR; + cyclic_refresh_ = 3; + denoiser_on_ = 1; + if (cfg_.g_bit_depth > 8) init_flags_ |= VPX_CODEC_USE_HIGHBITDEPTH; + + testing::internal::scoped_ptr video; + if (is_extension_y4m(test_video_param_.filename)) { + video.reset(new libvpx_test::Y4mVideoSource(test_video_param_.filename, 0, + kFrames)); + } else { + video.reset(new libvpx_test::YUVVideoSource( + test_video_param_.filename, test_video_param_.fmt, kWidth, kHeight, + kFramerate, 1, 0, kFrames)); + } + ASSERT_TRUE(video.get() != NULL); + + ASSERT_NO_FATAL_FAILURE(RunLoop(video.get())); + const double psnr = GetAveragePsnr(); + EXPECT_GT(psnr, GetPsnrThreshold()); +} + VP9_INSTANTIATE_TEST_CASE(EndToEndTestLarge, ::testing::ValuesIn(kEncodingModeVectors), ::testing::ValuesIn(kTestVectors), diff --git a/vp9/encoder/vp9_aq_cyclicrefresh.c b/vp9/encoder/vp9_aq_cyclicrefresh.c index 95daadfe2..aadedba39 100644 --- a/vp9/encoder/vp9_aq_cyclicrefresh.c +++ b/vp9/encoder/vp9_aq_cyclicrefresh.c @@ -428,9 +428,7 @@ void vp9_cyclic_refresh_update_parameters(VP9_COMP *const cpi) { double weight_segment = 0; int thresh_low_motion = (cm->width < 720) ? 55 : 20; cr->apply_cyclic_refresh = 1; - // TODO(jianj): Look into issue of cyclic refresh with high bitdepth. - if (cm->bit_depth > 8 || cm->frame_type == KEY_FRAME || - cpi->svc.temporal_layer_id > 0 || + if (cm->frame_type == KEY_FRAME || cpi->svc.temporal_layer_id > 0 || (cpi->use_svc && cpi->svc.layer_context[cpi->svc.temporal_layer_id].is_key_frame) || (!cpi->use_svc && rc->avg_frame_low_motion < thresh_low_motion && diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 2b1f2237f..fc1999687 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -4888,6 +4888,12 @@ int vp9_receive_raw_frame(VP9_COMP *cpi, vpx_enc_frame_flags_t frame_flags, check_initial_width(cpi, subsampling_x, subsampling_y); #endif // CONFIG_VP9_HIGHBITDEPTH +#if CONFIG_VP9_HIGHBITDEPTH + // Disable denoiser for high bitdepth since vp9_denoiser_filter only works for + // 8 bits. + if (cm->bit_depth > 8) cpi->oxcf.noise_sensitivity = 0; +#endif + #if CONFIG_VP9_TEMPORAL_DENOISING setup_denoiser_buffer(cpi); #endif diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c index 0f0f6066f..55a26745c 100644 --- a/vp9/vp9_cx_iface.c +++ b/vp9/vp9_cx_iface.c @@ -709,8 +709,6 @@ static vpx_codec_err_t ctrl_set_noise_sensitivity(vpx_codec_alg_priv_t *ctx, va_list args) { struct vp9_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.noise_sensitivity = CAST(VP9E_SET_NOISE_SENSITIVITY, args); - // TODO(jianj): Look into issue of noise estimation with high bitdepth. - if (ctx->cfg.g_bit_depth > 8) extra_cfg.noise_sensitivity = 0; return update_extra_cfg(ctx, &extra_cfg); }