diff options
Diffstat (limited to 'vp9/encoder/vp9_firstpass.c')
-rw-r--r-- | vp9/encoder/vp9_firstpass.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index 1dacfaaae..3d4b96259 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -28,10 +28,10 @@ #include "vp9/encoder/vp9_encodeframe.h" #include "vp9/encoder/vp9_encodemb.h" #include "vp9/encoder/vp9_encodemv.h" +#include "vp9/encoder/vp9_encoder.h" #include "vp9/encoder/vp9_extend.h" #include "vp9/encoder/vp9_firstpass.h" #include "vp9/encoder/vp9_mcomp.h" -#include "vp9/encoder/vp9_onyx_int.h" #include "vp9/encoder/vp9_quantize.h" #include "vp9/encoder/vp9_ratectrl.h" #include "vp9/encoder/vp9_rdopt.h" @@ -533,6 +533,9 @@ void vp9_first_pass(VP9_COMP *cpi) { // Disable golden frame for svc first pass for now. gld_yv12 = NULL; set_ref_ptrs(cm, xd, ref_frame, NONE); + + cpi->Source = vp9_scale_if_required(cm, cpi->un_scaled_source, + &cpi->scaled_source); } vp9_setup_src_planes(x, cpi->Source, 0, 0); @@ -849,6 +852,8 @@ void vp9_first_pass(VP9_COMP *cpi) { ++twopass->sr_update_lag; } + vp9_extend_frame_borders(new_yv12); + if (cpi->use_svc && cpi->svc.number_temporal_layers == 1) { vp9_update_reference_frames(cpi); } else { @@ -856,8 +861,6 @@ void vp9_first_pass(VP9_COMP *cpi) { swap_yv12(lst_yv12, new_yv12); } - vp9_extend_frame_borders(lst_yv12); - // Special case for the first frame. Copy into the GF buffer as a second // reference. if (cm->current_video_frame == 0 && gld_yv12 != NULL) { @@ -930,7 +933,7 @@ static int get_twopass_worst_quality(const VP9_COMP *cpi, } // Restriction on active max q for constrained quality mode. - if (oxcf->end_usage == USAGE_CONSTRAINED_QUALITY) + if (cpi->oxcf.rc_mode == RC_MODE_CONSTRAINED_QUALITY) q = MAX(q, oxcf->cq_level); return q; } @@ -1932,7 +1935,8 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { // Find the next keyframe. i = 0; - while (twopass->stats_in < twopass->stats_in_end) { + while (twopass->stats_in < twopass->stats_in_end && + rc->frames_to_key < cpi->oxcf.key_freq) { // Accumulate kf group error. kf_group_err += calculate_modified_err(cpi, this_frame); @@ -1962,7 +1966,7 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { // Special check for transition or high motion followed by a // static scene. - if (detect_transition_to_still(twopass, i, cpi->key_frame_frequency - i, + if (detect_transition_to_still(twopass, i, cpi->oxcf.key_freq - i, loop_decay_rate, decay_accumulator)) break; @@ -1970,8 +1974,8 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { ++rc->frames_to_key; // If we don't have a real key frame within the next two - // key_frame_frequency intervals then break out of the loop. - if (rc->frames_to_key >= 2 * (int)cpi->key_frame_frequency) + // key_freq intervals then break out of the loop. + if (rc->frames_to_key >= 2 * cpi->oxcf.key_freq) break; } else { ++rc->frames_to_key; @@ -1984,7 +1988,7 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { // This code centers the extra kf if the actual natural interval // is between 1x and 2x. if (cpi->oxcf.auto_key && - rc->frames_to_key > (int)cpi->key_frame_frequency) { + rc->frames_to_key > cpi->oxcf.key_freq) { FIRSTPASS_STATS tmp_frame = first_frame; rc->frames_to_key /= 2; @@ -2000,7 +2004,8 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { input_stats(twopass, &tmp_frame); } rc->next_key_frame_forced = 1; - } else if (twopass->stats_in == twopass->stats_in_end) { + } else if (twopass->stats_in == twopass->stats_in_end || + rc->frames_to_key >= cpi->oxcf.key_freq) { rc->next_key_frame_forced = 1; } else { rc->next_key_frame_forced = 0; @@ -2244,7 +2249,7 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) { cm->frame_type = INTER_FRAME; #ifdef LONG_TERM_VBR_CORRECTION // Correction to rate target based on prior over or under shoot. - if (cpi->oxcf.end_usage == USAGE_LOCAL_FILE_PLAYBACK) + if (cpi->oxcf.rc_mode == RC_MODE_VBR) vbr_rate_correction(&modified_target, rc->vbr_bits_off_target); #endif vp9_rc_set_frame_target(cpi, modified_target); @@ -2258,7 +2263,7 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) { twopass->gf_intra_err_min = GF_MB_INTRA_MIN * cpi->common.MBs; } - if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) { + if (cpi->oxcf.rc_mode == RC_MODE_CONSTANT_QUALITY) { twopass->active_worst_quality = cpi->oxcf.cq_level; } else if (cm->current_video_frame == 0 || (is_spatial_svc && lc->current_video_frame_in_layer == 0)) { @@ -2346,7 +2351,7 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) { rc->base_frame_target = target; #ifdef LONG_TERM_VBR_CORRECTION // Correction to rate target based on prior over or under shoot. - if (cpi->oxcf.end_usage == USAGE_LOCAL_FILE_PLAYBACK) + if (cpi->oxcf.rc_mode == RC_MODE_VBR) vbr_rate_correction(&target, rc->vbr_bits_off_target); #endif vp9_rc_set_frame_target(cpi, target); |