diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h index 535bdaacb05309db5f1ea4996a1fbb1975fdc68b..ab26125158ff997b5362ee7173c985813988aa71 100644 --- a/vp9/encoder/vp9_onyx_int.h +++ b/vp9/encoder/vp9_onyx_int.h @@ -587,6 +587,13 @@ static INLINE YV12_BUFFER_CONFIG *get_ref_frame_buffer( .buf; } +// Intra only frames, golden frames (except alt ref overlays) and +// alt ref frames tend to be coded at a higher than ambient quality +static INLINE int vp9_frame_is_boosted(const VP9_COMP *cpi) { + return frame_is_intra_only(&cpi->common) || cpi->refresh_alt_ref_frame || + (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref); +} + static INLINE int get_token_alloc(int mb_rows, int mb_cols) { // TODO(JBB): make this work for alpha channel and double check we can't // exceed this token count if we have a 32x32 transform crossing a boundary diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index 9ee58185c1addaacc760122ec28073af622863cb..b798d6c95d8d5e67de10d0d5803cb93287e71f45 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -1002,28 +1002,14 @@ void vp9_rc_compute_frame_size_bounds(const VP9_COMP *cpi, *frame_under_shoot_limit = 0; *frame_over_shoot_limit = INT_MAX; } else { - if (cpi->common.frame_type == KEY_FRAME) { - *frame_over_shoot_limit = this_frame_target * 9 / 8; - *frame_under_shoot_limit = this_frame_target * 7 / 8; - } else { - if (cpi->refresh_alt_ref_frame || cpi->refresh_golden_frame) { - *frame_over_shoot_limit = this_frame_target * 9 / 8; - *frame_under_shoot_limit = this_frame_target * 7 / 8; - } else { - // Strong overshoot limit for constrained quality - if (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) { - *frame_over_shoot_limit = this_frame_target * 11 / 8; - *frame_under_shoot_limit = this_frame_target * 2 / 8; - } else { - *frame_over_shoot_limit = this_frame_target * 11 / 8; - *frame_under_shoot_limit = this_frame_target * 5 / 8; - } - } - } + int recode_tolerance = + (cpi->sf.recode_tolerance * this_frame_target) / 100; + + *frame_over_shoot_limit = this_frame_target + recode_tolerance; + *frame_under_shoot_limit = this_frame_target - recode_tolerance; // For very small rate targets where the fractional adjustment - // (eg * 7/8) may be tiny make sure there is at least a minimum - // range. + // may be tiny make sure there is at least a minimum range. *frame_over_shoot_limit += 200; *frame_under_shoot_limit -= 200; if (*frame_under_shoot_limit < 0) diff --git a/vp9/encoder/vp9_speed_features.c b/vp9/encoder/vp9_speed_features.c index f090350775f747b838979111aad0674717341367..6a437bf03ec2139c577e199f5626fd10750a3438 100644 --- a/vp9/encoder/vp9_speed_features.c +++ b/vp9/encoder/vp9_speed_features.c @@ -25,13 +25,6 @@ #define DISABLE_COMPOUND_SPLIT 0x18 #define LAST_AND_INTRA_SPLIT_ONLY 0x1E -// Intra only frames, golden frames (except alt ref overlays) and -// alt ref frames tend to be coded at a higher than ambient quality -static INLINE int frame_is_boosted(const VP9_COMP *cpi) { - return frame_is_intra_only(&cpi->common) || cpi->refresh_alt_ref_frame || - (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref); -} - static void set_good_speed_feature(VP9_COMP *cpi, VP9_COMMON *cm, SPEED_FEATURES *sf, @@ -44,7 +37,7 @@ static void set_good_speed_feature(VP9_COMP *cpi, if (speed >= 1) { sf->use_square_partition_only = !frame_is_intra_only(cm); sf->less_rectangular_check = 1; - sf->tx_size_search_method = frame_is_boosted(cpi) + sf->tx_size_search_method = vp9_frame_is_boosted(cpi) ? USE_FULL_RD : USE_LARGESTALL; if (MIN(cm->width, cm->height) >= 720) @@ -68,7 +61,7 @@ static void set_good_speed_feature(VP9_COMP *cpi, } // Additions or changes from speed 1 for speed >= 2. if (speed >= 2) { - sf->tx_size_search_method = frame_is_boosted(cpi) + sf->tx_size_search_method = vp9_frame_is_boosted(cpi) ? USE_FULL_RD : USE_LARGESTALL; if (MIN(cm->width, cm->height) >= 720) @@ -326,6 +319,9 @@ void vp9_set_speed_features(VP9_COMP *cpi) { // to FIXED_PARTITION. sf->always_this_block_size = BLOCK_16X16; + // Recode loop tolerence %. + sf->recode_tolerance = 25; + switch (cpi->oxcf.mode) { case MODE_BESTQUALITY: case MODE_SECONDPASS_BEST: // This is the best quality mode. diff --git a/vp9/encoder/vp9_speed_features.h b/vp9/encoder/vp9_speed_features.h index 5091e2b06d6680953d2b7bd2c6ebca3f61f9dc4d..9d706dc7beb82b6b44df3e00e4951ae9478a744e 100644 --- a/vp9/encoder/vp9_speed_features.h +++ b/vp9/encoder/vp9_speed_features.h @@ -301,6 +301,10 @@ typedef struct { // calculation in the rd coefficient costing loop. int use_fast_coef_costing; + // This feature controls the tolerence vs target used in deciding whether to + // recode a frame. It has no meaning if recode is disabled. + int recode_tolerance; + // This variable controls the maximum block size where intra blocks can be // used in inter frames. // TODO(aconverse): Fold this into one of the other many mode skips