summaryrefslogtreecommitdiff
path: root/vp9/encoder
diff options
context:
space:
mode:
Diffstat (limited to 'vp9/encoder')
-rw-r--r--vp9/encoder/vp9_onyx_if.c50
-rw-r--r--vp9/encoder/vp9_rdopt.c26
2 files changed, 56 insertions, 20 deletions
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c
index 342ff8473..a979a4b5e 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -767,6 +767,7 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
#endif
sf->use_avoid_tested_higherror = 1;
sf->adaptive_rd_thresh = 1;
+ sf->recode_loop = (speed < 1);
if (speed == 1) {
sf->use_square_partition_only = !(cpi->common.frame_type == KEY_FRAME ||
@@ -786,6 +787,7 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
sf->adaptive_motion_search = 1;
sf->auto_mv_step_size = 1;
sf->adaptive_rd_thresh = 2;
+ sf->recode_loop = 2;
}
if (speed == 2) {
sf->use_square_partition_only = !(cpi->common.frame_type == KEY_FRAME ||
@@ -2609,14 +2611,15 @@ static void output_frame_level_debug_stats(VP9_COMP *cpi) {
}
#endif
-static int pick_q_and_adjust_q_bounds(VP9_COMP *cpi) {
+static int pick_q_and_adjust_q_bounds(VP9_COMP *cpi,
+ int * bottom_index, int * top_index) {
// Set an active best quality and if necessary active worst quality
int q = cpi->active_worst_quality;
VP9_COMMON *const cm = &cpi->common;
if (cm->frame_type == KEY_FRAME) {
#if !CONFIG_MULTIPLE_ARF
- // Handle the special case for key frames forced when we have reached
+ // Handle the special case for key frames forced when we have75 reached
// the maximum key frame interval. Here force the Q to a range
// based on the ambient Q to reduce the risk of popping.
if (cpi->this_key_frame_forced) {
@@ -2662,12 +2665,13 @@ static int pick_q_and_adjust_q_bounds(VP9_COMP *cpi) {
cpi->active_best_quality = cpi->active_worst_quality
+ compute_qdelta(cpi, current_q, current_q * 0.3);
#endif
- } else if (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame) {
+ } else if (!cpi->is_src_frame_alt_ref &&
+ (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)) {
int high = 2000;
int low = 400;
// Use the lower of cpi->active_worst_quality and recent
- // average Q as basis for GF/ARF Q limit unless last frame was
+ // average Q as basis for GF/ARF best Q limit unless last frame was
// a key frame.
if (cpi->frames_since_key > 1 &&
cpi->avg_frame_qindex < cpi->active_worst_quality) {
@@ -2708,14 +2712,10 @@ static int pick_q_and_adjust_q_bounds(VP9_COMP *cpi) {
}
}
} else {
- if (!cpi->refresh_alt_ref_frame) {
- cpi->active_best_quality = inter_minq[q];
- } else {
cpi->active_best_quality = get_active_quality(q, cpi->gfu_boost,
low, high,
gf_low_motion_minq,
gf_high_motion_minq);
- }
}
} else {
if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) {
@@ -2731,7 +2731,7 @@ static int pick_q_and_adjust_q_bounds(VP9_COMP *cpi) {
cpi->active_best_quality = inter_minq[q];
#endif
- // For the constant/constrained quality mode we don't want
+ // For the constrained quality mode we don't want
// q to fall below the cq level.
if ((cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) &&
(cpi->active_best_quality < cpi->cq_target_quality)) {
@@ -2759,14 +2759,28 @@ static int pick_q_and_adjust_q_bounds(VP9_COMP *cpi) {
if (cpi->active_worst_quality < cpi->active_best_quality)
cpi->active_worst_quality = cpi->active_best_quality;
- // Special case code to try and match quality with forced key frames
+ // Limit Q range for the adaptive loop.
+ if (cm->frame_type == KEY_FRAME && !cpi->this_key_frame_forced) {
+ *top_index = cpi->active_best_quality;
+ } else if (!cpi->is_src_frame_alt_ref &&
+ (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)) {
+ *top_index =
+ (cpi->active_worst_quality + cpi->active_best_quality * 3) / 4;
+ } else {
+ *top_index = cpi->active_worst_quality;
+ }
+ *bottom_index = cpi->active_best_quality;
+
if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) {
q = cpi->active_best_quality;
+ // Special case code to try and match quality with forced key frames
} else if ((cm->frame_type == KEY_FRAME) && cpi->this_key_frame_forced) {
q = cpi->last_boosted_qindex;
} else {
// Determine initial Q to try
q = vp9_regulate_q(cpi, cpi->this_frame_target);
+ if (q > *top_index)
+ q = *top_index;
}
return q;
@@ -2905,7 +2919,10 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
vp9_clear_system_state();
- q = pick_q_and_adjust_q_bounds(cpi);
+ q = pick_q_and_adjust_q_bounds(cpi, &bottom_index, &top_index);
+
+ q_high = top_index;
+ q_low = bottom_index;
vp9_compute_frame_size_bounds(cpi, &frame_under_shoot_limit,
&frame_over_shoot_limit);
@@ -2929,16 +2946,9 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
q_high = q;
printf("frame:%d q:%d\n", cm->current_video_frame, q);
- } else {
-#endif
- // Limit Q range for the adaptive loop.
- bottom_index = cpi->active_best_quality;
- top_index = cpi->active_worst_quality;
- q_low = cpi->active_best_quality;
- q_high = cpi->active_worst_quality;
-#if CONFIG_MULTIPLE_ARF
}
#endif
+
loop_count = 0;
vp9_zero(cpi->rd_tx_select_threshes);
@@ -3029,10 +3039,10 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
frame_over_shoot_limit = 1;
active_worst_qchanged = 0;
- // Special case handling for forced key frames
if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) {
loop = 0;
} else {
+ // Special case handling for forced key frames
if ((cm->frame_type == KEY_FRAME) && cpi->this_key_frame_forced) {
int last_q = q;
int kf_err = vp9_calc_ss_err(cpi->Source,
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index 5ba3ec8ad..60fec389d 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -3903,6 +3903,32 @@ int64_t vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x,
ref_frame = vp9_ref_order[mode_index].ref_frame;
second_ref_frame = vp9_ref_order[mode_index].second_ref_frame;
+ // Look at the reference frame of the best mode so far and set the
+ // skip mask to look at a subset of the remaining modes.
+ if (mode_index > 2 && cpi->sf.mode_skip_start < MAX_MODES) {
+ if (mode_index == 3) {
+ switch (vp9_ref_order[best_mode_index].ref_frame) {
+ case INTRA_FRAME:
+ cpi->mode_skip_mask = 0;
+ break;
+ case LAST_FRAME:
+ cpi->mode_skip_mask = 0x0010;
+ break;
+ case GOLDEN_FRAME:
+ cpi->mode_skip_mask = 0x0008;
+ break;
+ case ALTREF_FRAME:
+ cpi->mode_skip_mask = 0x0000;
+ break;
+ case NONE:
+ case MAX_REF_FRAMES:
+ assert(!"Invalid Reference frame");
+ }
+ }
+ if (cpi->mode_skip_mask & ((int64_t)1 << mode_index))
+ continue;
+ }
+
// Skip if the current reference frame has been masked off
if (cpi->sf.reference_masking && !cpi->set_ref_frame_mask &&
(cpi->ref_frame_mask & (1 << ref_frame)))