diff options
author | Paul Wilkins <paulwilkins@google.com> | 2017-02-15 10:37:02 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-02-15 10:37:02 +0000 |
commit | 7635ee0f3794c8fb2030037f0ec3c2ebff8dc926 (patch) | |
tree | 68b499bbb4922dc3d99f5b0266e0d9ed87a133fa /vp9 | |
parent | 61927ba4ac6390bc98396b9ba30d050f63e720fa (diff) | |
parent | ce7b38459aee4442c66a32647b650de79e35d437 (diff) | |
download | libvpx-7635ee0f3794c8fb2030037f0ec3c2ebff8dc926.tar libvpx-7635ee0f3794c8fb2030037f0ec3c2ebff8dc926.tar.gz libvpx-7635ee0f3794c8fb2030037f0ec3c2ebff8dc926.tar.bz2 libvpx-7635ee0f3794c8fb2030037f0ec3c2ebff8dc926.zip |
Merge "Aggressive VBR method."
Diffstat (limited to 'vp9')
-rw-r--r-- | vp9/encoder/vp9_encoder.c | 21 | ||||
-rw-r--r-- | vp9/encoder/vp9_firstpass.c | 14 | ||||
-rw-r--r-- | vp9/encoder/vp9_ratectrl.c | 14 | ||||
-rw-r--r-- | vp9/encoder/vp9_ratectrl.h | 3 |
4 files changed, 49 insertions, 3 deletions
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 2ce46c657..d61c11ef1 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -3312,6 +3312,9 @@ static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size, int frame_under_shoot_limit; int q = 0, q_low = 0, q_high = 0; int enable_acl; +#ifdef AGRESSIVE_VBR + int qrange_adj = 1; +#endif set_size_independent_vars(cpi); @@ -3327,6 +3330,17 @@ static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size, if (loop_count == 0 || cpi->resize_pending != 0) { set_size_dependent_vars(cpi, &q, &bottom_index, &top_index); +#ifdef AGRESSIVE_VBR + if (two_pass_first_group_inter(cpi)) { + // Adjustment limits for min and max q + qrange_adj = VPXMAX(1, (top_index - bottom_index) / 2); + + bottom_index = VPXMAX(bottom_index - qrange_adj / 2, + cpi->oxcf.best_allowed_q); + top_index = VPXMIN(cpi->oxcf.worst_allowed_q, + top_index + qrange_adj / 2); + } +#endif // TODO(agrange) Scale cpi->max_mv_magnitude if frame-size has changed. set_mv_search_params(cpi); @@ -3593,6 +3607,13 @@ static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size, if (loop || !enable_acl) restore_coding_context(cpi); } while (loop); +#ifdef AGRESSIVE_VBR + if (two_pass_first_group_inter(cpi)) { + cpi->twopass.active_worst_quality = + VPXMIN(q + qrange_adj, cpi->oxcf.worst_allowed_q); + } +#endif + if (enable_acl) { vp9_encode_frame(cpi); vpx_clear_system_state(); diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index bfa84ad38..493e76805 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -2464,7 +2464,11 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { } // Limit maximum boost based on interval length. +#ifdef AGRESSIVE_VBR + rc->gfu_boost = VPXMIN((int)rc->gfu_boost, i * 140); +#else rc->gfu_boost = VPXMIN((int)rc->gfu_boost, i * 200); +#endif // Set the interval until the next gf. rc->baseline_gf_interval = i - (is_key_frame || rc->source_alt_ref_pending); @@ -2667,11 +2671,17 @@ static int test_candidate_kf(TWO_PASS *twopass, } #define FRAMES_TO_CHECK_DECAY 8 -#define KF_MAX_FRAME_BOOST 96.0 #define MIN_KF_TOT_BOOST 300 -#define MAX_KF_TOT_BOOST 5400 #define KF_BOOST_SCAN_MAX_FRAMES 32 +#ifdef AGRESSIVE_VBR +#define KF_MAX_FRAME_BOOST 80.0 +#define MAX_KF_TOT_BOOST 4800 +#else +#define KF_MAX_FRAME_BOOST 96.0 +#define MAX_KF_TOT_BOOST 5400 +#endif + static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { int i, j; RATE_CONTROL *const rc = &cpi->rc; diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index 0b869a827..67f2959c8 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -93,10 +93,17 @@ static int inter_minq_12[QINDEX_RANGE]; static int rtc_minq_12[QINDEX_RANGE]; #endif +#ifdef AGRESSIVE_VBR +static int gf_high = 2400; +static int gf_low = 400; +static int kf_high = 4000; +static int kf_low = 400; +#else static int gf_high = 2000; static int gf_low = 400; static int kf_high = 5000; static int kf_low = 400; +#endif // Functions to compute the active minq lookup table entries based on a // formulaic approach to facilitate easier adjustment of the Q tables. @@ -126,9 +133,14 @@ static void init_minq_luts(int *kf_low_m, int *kf_high_m, int *arfgf_low, const double maxq = vp9_convert_qindex_to_q(i, bit_depth); kf_low_m[i] = get_minq_index(maxq, 0.000001, -0.0004, 0.150, bit_depth); kf_high_m[i] = get_minq_index(maxq, 0.0000021, -0.00125, 0.55, bit_depth); +#ifdef AGRESSIVE_VBR + arfgf_low[i] = get_minq_index(maxq, 0.0000015, -0.0009, 0.275, bit_depth); + inter[i] = get_minq_index(maxq, 0.00000271, -0.00113, 0.80, bit_depth); +#else arfgf_low[i] = get_minq_index(maxq, 0.0000015, -0.0009, 0.30, bit_depth); - arfgf_high[i] = get_minq_index(maxq, 0.0000021, -0.00125, 0.55, bit_depth); inter[i] = get_minq_index(maxq, 0.00000271, -0.00113, 0.70, bit_depth); +#endif + arfgf_high[i] = get_minq_index(maxq, 0.0000021, -0.00125, 0.55, bit_depth); rtc[i] = get_minq_index(maxq, 0.00000271, -0.00113, 0.70, bit_depth); } } diff --git a/vp9/encoder/vp9_ratectrl.h b/vp9/encoder/vp9_ratectrl.h index b119691fc..7bd428e23 100644 --- a/vp9/encoder/vp9_ratectrl.h +++ b/vp9/encoder/vp9_ratectrl.h @@ -21,6 +21,9 @@ extern "C" { #endif +// Used to control agressive VBR mode. +// #define AGRESSIVE_VBR 1 + // Bits Per MB at different Q (Multiplied by 512) #define BPER_MB_NORMBITS 9 |