From 0d8723f8d5372eaaadfb5373a3b9d35e2c78c42d Mon Sep 17 00:00:00 2001 From: Deb Mukherjee Date: Mon, 19 Aug 2013 14:16:26 -0700 Subject: [PATCH] Make "good" quality 2-pass vpxenc encoding default Currently, the best quality mode in VP9 is not very well developed, and unnecessarily makes the encode too slow. Hence the command line default is changed to "good" quality. Also, the number of passes default is changed to 2 passes as well, since 1-pass encoding is not very efficient in VP9. Besides, a number of VP9 defaults are set to the currently recommended settings. With these changes, vpxenc run with --codec=vp9 --kf-max-dist=9999 --cpu-used=0 should work about the same as our borg results. Note when the --cpu-used=0 option is dropped there will be a slight difference in the output, because of a difference in the cpu-used value for the first pass. Specifically, the default when unspecified is to use cpu_used=1 for the first pass and cpu_used=0 for the second pass. But when specified, both passes will use the cpu-used value specified. Note that this also changes the default for VP8 as being "good" but other options stay unchanged. Change-Id: Ib23c1a05ae2f36ee076c0e34403efbda518c5066 --- test/encode_test_driver.cc | 2 +- test/error_resilience_test.cc | 7 ++++-- vp9/vp9_cx_iface.c | 45 +++++++++++++++++------------------ vpxenc.c | 9 ++++++- 4 files changed, 36 insertions(+), 27 deletions(-) diff --git a/test/encode_test_driver.cc b/test/encode_test_driver.cc index eed3e33af..df9e4216c 100644 --- a/test/encode_test_driver.cc +++ b/test/encode_test_driver.cc @@ -158,7 +158,7 @@ void EncoderTest::RunLoop(VideoSource *video) { Decoder* const decoder = codec_->CreateDecoder(dec_cfg, 0); bool again; for (again = true, video->Begin(); again; video->Next()) { - again = video->img() != NULL; + again = (video->img() != NULL); PreEncodeFrameHook(video); PreEncodeFrameHook(video, encoder); diff --git a/test/error_resilience_test.cc b/test/error_resilience_test.cc index d4a6967f6..16d250c76 100644 --- a/test/error_resilience_test.cc +++ b/test/error_resilience_test.cc @@ -62,7 +62,7 @@ class ErrorResilienceTest : public ::libvpx_test::EncoderTest, if (droppable_nframes_ > 0 && (cfg_.g_pass == VPX_RC_LAST_PASS || cfg_.g_pass == VPX_RC_ONE_PASS)) { for (unsigned int i = 0; i < droppable_nframes_; ++i) { - if (droppable_frames_[i] == nframes_) { + if (droppable_frames_[i] == video->frame()) { std::cout << " Encoding droppable frame: " << droppable_frames_[i] << "\n"; frame_flags_ |= (VP8_EFLAG_NO_UPD_LAST | @@ -148,7 +148,7 @@ TEST_P(ErrorResilienceTest, OnVersusOff) { const vpx_rational timebase = { 33333333, 1000000000 }; cfg_.g_timebase = timebase; cfg_.rc_target_bitrate = 2000; - cfg_.g_lag_in_frames = 25; + cfg_.g_lag_in_frames = 10; init_flags_ = VPX_CODEC_USE_PSNR; @@ -179,6 +179,9 @@ TEST_P(ErrorResilienceTest, DropFramesWithoutRecovery) { const vpx_rational timebase = { 33333333, 1000000000 }; cfg_.g_timebase = timebase; cfg_.rc_target_bitrate = 500; + // FIXME(debargha): Fix this to work for any lag. + // Currently this test only works for lag = 0 + cfg_.g_lag_in_frames = 0; init_flags_ = VPX_CODEC_USE_PSNR; diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c index be7828f38..0874afdbc 100644 --- a/vp9/vp9_cx_iface.c +++ b/vp9/vp9_cx_iface.c @@ -51,14 +51,14 @@ static const struct extraconfig_map extracfg_map[] = { { NULL, 0, /* cpu_used */ - 0, /* enable_auto_alt_ref */ + 1, /* enable_auto_alt_ref */ 0, /* noise_sensitivity */ 0, /* Sharpness */ 0, /* static_thresh */ 0, /* tile_columns */ 0, /* tile_rows */ - 0, /* arnr_max_frames */ - 3, /* arnr_strength */ + 7, /* arnr_max_frames */ + 5, /* arnr_strength */ 3, /* arnr_type*/ 0, /* experimental mode */ 0, /* tuning*/ @@ -411,21 +411,20 @@ static vpx_codec_err_t set_param(vpx_codec_alg_priv_t *ctx, #define MAP(id, var) case id: var = CAST(id, args); break; switch (ctrl_id) { - MAP(VP8E_SET_CPUUSED, xcfg.cpu_used); - MAP(VP8E_SET_ENABLEAUTOALTREF, xcfg.enable_auto_alt_ref); - MAP(VP8E_SET_NOISE_SENSITIVITY, xcfg.noise_sensitivity); - MAP(VP8E_SET_SHARPNESS, xcfg.Sharpness); - MAP(VP8E_SET_STATIC_THRESHOLD, xcfg.static_thresh); - MAP(VP9E_SET_TILE_COLUMNS, xcfg.tile_columns); - MAP(VP9E_SET_TILE_ROWS, xcfg.tile_rows); - - MAP(VP8E_SET_ARNR_MAXFRAMES, xcfg.arnr_max_frames); - MAP(VP8E_SET_ARNR_STRENGTH, xcfg.arnr_strength); - MAP(VP8E_SET_ARNR_TYPE, xcfg.arnr_type); - MAP(VP8E_SET_TUNING, xcfg.tuning); - MAP(VP8E_SET_CQ_LEVEL, xcfg.cq_level); - MAP(VP8E_SET_MAX_INTRA_BITRATE_PCT, xcfg.rc_max_intra_bitrate_pct); - MAP(VP9E_SET_LOSSLESS, xcfg.lossless); + MAP(VP8E_SET_CPUUSED, xcfg.cpu_used); + MAP(VP8E_SET_ENABLEAUTOALTREF, xcfg.enable_auto_alt_ref); + MAP(VP8E_SET_NOISE_SENSITIVITY, xcfg.noise_sensitivity); + MAP(VP8E_SET_SHARPNESS, xcfg.Sharpness); + MAP(VP8E_SET_STATIC_THRESHOLD, xcfg.static_thresh); + MAP(VP9E_SET_TILE_COLUMNS, xcfg.tile_columns); + MAP(VP9E_SET_TILE_ROWS, xcfg.tile_rows); + MAP(VP8E_SET_ARNR_MAXFRAMES, xcfg.arnr_max_frames); + MAP(VP8E_SET_ARNR_STRENGTH, xcfg.arnr_strength); + MAP(VP8E_SET_ARNR_TYPE, xcfg.arnr_type); + MAP(VP8E_SET_TUNING, xcfg.tuning); + MAP(VP8E_SET_CQ_LEVEL, xcfg.cq_level); + MAP(VP8E_SET_MAX_INTRA_BITRATE_PCT, xcfg.rc_max_intra_bitrate_pct); + MAP(VP9E_SET_LOSSLESS, xcfg.lossless); MAP(VP9E_SET_FRAME_PARALLEL_DECODING, xcfg.frame_parallel_decoding_mode); } @@ -1026,8 +1025,8 @@ static vpx_codec_ctrl_fn_map_t vp9e_ctf_maps[] = { {VP8E_GET_LAST_QUANTIZER, get_param}, {VP8E_GET_LAST_QUANTIZER_64, get_param}, {VP8E_SET_ARNR_MAXFRAMES, set_param}, - {VP8E_SET_ARNR_STRENGTH, set_param}, - {VP8E_SET_ARNR_TYPE, set_param}, + {VP8E_SET_ARNR_STRENGTH, set_param}, + {VP8E_SET_ARNR_TYPE, set_param}, {VP8E_SET_TUNING, set_param}, {VP8E_SET_CQ_LEVEL, set_param}, {VP8E_SET_MAX_INTRA_BITRATE_PCT, set_param}, @@ -1053,7 +1052,7 @@ static vpx_codec_enc_cfg_map_t vp9e_usage_cfg_map[] = { VPX_RC_ONE_PASS, /* g_pass */ - 0, /* g_lag_in_frames */ + 25, /* g_lag_in_frames */ 0, /* rc_dropframe_thresh */ 0, /* rc_resize_allowed */ @@ -1065,7 +1064,7 @@ static vpx_codec_enc_cfg_map_t vp9e_usage_cfg_map[] = { {0}, /* rc_twopass_stats_in */ #endif 256, /* rc_target_bandwidth */ - 4, /* rc_min_quantizer */ + 0, /* rc_min_quantizer */ 63, /* rc_max_quantizer */ 100, /* rc_undershoot_pct */ 100, /* rc_overshoot_pct */ @@ -1076,7 +1075,7 @@ static vpx_codec_enc_cfg_map_t vp9e_usage_cfg_map[] = { 50, /* rc_two_pass_vbrbias */ 0, /* rc_two_pass_vbrmin_section */ - 400, /* rc_two_pass_vbrmax_section */ + 2000, /* rc_two_pass_vbrmax_section */ /* keyframing settings (kf) */ VPX_KF_AUTO, /* g_kfmode*/ diff --git a/vpxenc.c b/vpxenc.c index 244ae073f..5d29c15e2 100644 --- a/vpxenc.c +++ b/vpxenc.c @@ -1688,8 +1688,10 @@ static void parse_global_config(struct global_config *global, char **argv) { /* Initialize default parameters */ memset(global, 0, sizeof(*global)); global->codec = codecs; - global->passes = 1; + global->passes = 0; global->use_i420 = 1; + /* Assign default deadline to good quality */ + global->deadline = VPX_DL_GOOD_QUALITY; for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step) { arg.argv_step = 1; @@ -1761,6 +1763,11 @@ static void parse_global_config(struct global_config *global, char **argv) { } /* Validate global config */ + if (global->passes == 0) { + // Make default VP9 passes = 2 until there is a better quality 1-pass + // encoder + global->passes = (global->codec->iface == vpx_codec_vp9_cx ? 2 : 1); + } if (global->pass) { /* DWIM: Assume the user meant passes=2 if pass=2 is specified */