From: Jingning Han Date: Sat, 12 Nov 2016 00:10:01 +0000 (-0800) Subject: Enable asymptotic closed-loop encoding decision X-Git-Tag: v1.6.1~82^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=44f8ee7258c5e9bac9a4e25d265aa34eb47e08fb;p=libvpx Enable asymptotic closed-loop encoding decision This commit enables asymptotic closed-loop encoding decision for the key frame and alternate reference frame. It follows the regular rate control scheme, but leaves out additional iteration on the updated frame level probability model. It is enabled for speed 0. The compression performance is improved: lowres 0.2% midres 0.35% hdres 0.4% Change-Id: I905ffa057c9a1ef2e90ef87c9723a6cf7dbe67cb --- diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 2a5800382..600ebec9c 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -3238,9 +3238,14 @@ static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size, int frame_over_shoot_limit; int frame_under_shoot_limit; int q = 0, q_low = 0, q_high = 0; + int enable_acl; set_size_independent_vars(cpi); + enable_acl = cpi->sf.allow_acl + ? (cm->frame_type == KEY_FRAME) || (cm->show_frame == 0) + : 0; + do { vpx_clear_system_state(); @@ -3335,7 +3340,6 @@ static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size, if (!cpi->sf.use_nonrd_pick_mode) vp9_pack_bitstream(cpi, dest, size); rc->projected_frame_size = (int)(*size) << 3; - restore_coding_context(cpi); if (frame_over_shoot_limit == 0) frame_over_shoot_limit = 1; } @@ -3505,7 +3509,22 @@ static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size, ++cpi->tot_recode_hits; #endif } + + if (cpi->sf.recode_loop >= ALLOW_RECODE_KFARFGF) + if (loop || !enable_acl) restore_coding_context(cpi); } while (loop); + + if (enable_acl) { + vp9_encode_frame(cpi); + vpx_clear_system_state(); + restore_coding_context(cpi); + vp9_pack_bitstream(cpi, dest, size); + + vp9_encode_frame(cpi); + vpx_clear_system_state(); + + restore_coding_context(cpi); + } } static int get_ref_frame_flags(const VP9_COMP *cpi) { diff --git a/vp9/encoder/vp9_speed_features.c b/vp9/encoder/vp9_speed_features.c index 3e1ed50a6..6f8ed1909 100644 --- a/vp9/encoder/vp9_speed_features.c +++ b/vp9/encoder/vp9_speed_features.c @@ -182,6 +182,7 @@ static void set_good_speed_feature(VP9_COMP *cpi, VP9_COMMON *cm, sf->mv.subpel_iters_per_step = 1; sf->mode_skip_start = 10; sf->adaptive_pred_interp_filter = 1; + sf->allow_acl = 0; sf->intra_y_mode_mask[TX_32X32] = INTRA_DC_H_V; sf->intra_uv_mode_mask[TX_32X32] = INTRA_DC_H_V; @@ -309,6 +310,7 @@ static void set_rt_speed_feature(VP9_COMP *cpi, SPEED_FEATURES *sf, int speed, sf->use_fast_coef_costing = 1; sf->allow_exhaustive_searches = 0; sf->exhaustive_searches_thresh = INT_MAX; + sf->allow_acl = 0; if (speed >= 1) { sf->allow_txfm_domain_distortion = 1; @@ -592,6 +594,7 @@ void vp9_set_speed_features_framesize_independent(VP9_COMP *cpi) { sf->tx_domain_thresh = 99.0; sf->allow_quant_coeff_opt = sf->optimize_coefficients; sf->quant_opt_thresh = 99.0; + sf->allow_acl = 1; for (i = 0; i < TX_SIZES; i++) { sf->intra_y_mode_mask[i] = INTRA_ALL; diff --git a/vp9/encoder/vp9_speed_features.h b/vp9/encoder/vp9_speed_features.h index 6d0b9420a..7f83c606f 100644 --- a/vp9/encoder/vp9_speed_features.h +++ b/vp9/encoder/vp9_speed_features.h @@ -244,6 +244,10 @@ typedef struct SPEED_FEATURES { int allow_quant_coeff_opt; double quant_opt_thresh; + // Enable asymptotic closed-loop encoding decision for key frame and + // alternate reference frames. + int allow_acl; + // Use transform domain distortion. Use pixel domain distortion in speed 0 // and certain situations in higher speed to improve the RD model precision. int allow_txfm_domain_distortion;