summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vp9/encoder/vp9_firstpass.c26
-rw-r--r--vp9/encoder/vp9_ratectrl.c6
2 files changed, 26 insertions, 6 deletions
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index 89348e666..e102b4939 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -1582,7 +1582,24 @@ static double calc_correction_factor(double err_per_mb, double err_divisor,
return fclamp(pow(error_term, power_term), 0.05, 5.0);
}
-#define ERR_DIVISOR 115.0
+static double wq_err_divisor(VP9_COMP *cpi) {
+ const VP9_COMMON *const cm = &cpi->common;
+ unsigned int screen_area = (cm->width * cm->height);
+
+ // Use a different error per mb factor for calculating boost for
+ // different formats.
+ if (screen_area < 1280 * 720) {
+ return 125.0;
+ } else if (screen_area <= 1920 * 1080) {
+ return 130.0;
+ } else if (screen_area < 3840 * 2160) {
+ return 150.0;
+ }
+
+ // Fall through to here only for 4K and above.
+ return 200.0;
+}
+
#define NOISE_FACTOR_MIN 0.9
#define NOISE_FACTOR_MAX 1.1
static int get_twopass_worst_quality(VP9_COMP *cpi, const double section_err,
@@ -1642,7 +1659,7 @@ static int get_twopass_worst_quality(VP9_COMP *cpi, const double section_err,
// content at the given rate.
for (q = rc->best_quality; q < rc->worst_quality; ++q) {
const double factor =
- calc_correction_factor(av_err_per_mb, ERR_DIVISOR, q);
+ calc_correction_factor(av_err_per_mb, wq_err_divisor(cpi), q);
const int bits_per_mb = vp9_rc_bits_per_mb(
INTER_FRAME, q,
factor * speed_term * cpi->twopass.bpm_factor * noise_factor,
@@ -2877,6 +2894,7 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
double zero_motion_accumulator = 1.0;
double boost_score = 0.0;
double kf_mod_err = 0.0;
+ double kf_raw_err = 0.0;
double kf_group_err = 0.0;
double recent_loop_decay[FRAMES_TO_CHECK_DECAY];
double sr_accumulator = 0.0;
@@ -2905,6 +2923,7 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
twopass->kf_group_bits = 0; // Total bits available to kf group
twopass->kf_group_error_left = 0.0; // Group modified error score.
+ kf_raw_err = this_frame->intra_error;
kf_mod_err =
calculate_norm_frame_score(cpi, twopass, oxcf, this_frame, av_err);
@@ -3072,7 +3091,8 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
fabs(next_frame.mv_in_out_count * next_frame.pcnt_motion);
if ((frame_boost < 25.00) ||
- (abs_mv_in_out_accumulator > KF_ABS_ZOOM_THRESH))
+ (abs_mv_in_out_accumulator > KF_ABS_ZOOM_THRESH) ||
+ (sr_accumulator > (kf_raw_err * 1.50)))
break;
} else {
break;
diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c
index 46c917b8e..5e199ac5b 100644
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -100,8 +100,8 @@ 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;
+static int kf_high = 4800;
+static int kf_low = 300;
#endif
// Functions to compute the active minq lookup table entries based on a
@@ -131,7 +131,7 @@ static void init_minq_luts(int *kf_low_m, int *kf_high_m, int *arfgf_low,
for (i = 0; i < QINDEX_RANGE; i++) {
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);
+ kf_high_m[i] = get_minq_index(maxq, 0.0000021, -0.00125, 0.45, bit_depth);
#ifdef AGGRESSIVE_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);