Commit 2f05847d authored by Dmitry Kovalev's avatar Dmitry Kovalev

Cleaning up encode_frame_to_data_rate().

Change-Id: Ib76a31e68aef5cb9eeba57dc58d9c30c9c98ed95
parent 77f7f6a8
......@@ -2918,14 +2918,14 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
int bottom_index;
SPEED_FEATURES *const sf = &cpi->sf;
unsigned int max_mv_def = MIN(cpi->common.width, cpi->common.height);
unsigned int max_mv_def = MIN(cm->width, cm->height);
struct segmentation *const seg = &cm->seg;
set_ext_overrides(cpi);
/* Scale the source buffer, if required. */
if (cm->mi_cols * 8 != cpi->un_scaled_source->y_width ||
cm->mi_rows * 8 != cpi->un_scaled_source->y_height) {
if (cm->mi_cols * MI_SIZE != cpi->un_scaled_source->y_width ||
cm->mi_rows * MI_SIZE != cpi->un_scaled_source->y_height) {
scale_and_extend_frame_nonnormative(cpi->un_scaled_source,
&cpi->scaled_source);
cpi->Source = &cpi->scaled_source;
......@@ -2934,12 +2934,8 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
}
scale_references(cpi);
// Clear down mmx registers to allow floating point in what follows.
vp9_clear_system_state();
// Clear zbin over-quant value and mode boost values.
cpi->zbin_mode_boost = 0;
// Enable or disable mode based tweaking of the zbin.
// For 2 pass only used where GF/ARF prediction quality
// is above a threshold.
......@@ -2947,7 +2943,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
cpi->zbin_mode_boost_enabled = 0;
// Current default encoder behavior for the altref sign bias.
cpi->common.ref_frame_sign_bias[ALTREF_FRAME] = cpi->rc.source_alt_ref_active;
cm->ref_frame_sign_bias[ALTREF_FRAME] = cpi->rc.source_alt_ref_active;
// Set default state for segment based loop filter update flags.
cm->lf.mode_ref_delta_update = 0;
......@@ -2956,7 +2952,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
cpi->mv_step_param = vp9_init_search_range(cpi, max_mv_def);
// Initialize cpi->max_mv_magnitude and cpi->mv_step_param if appropriate.
if (sf->auto_mv_step_size) {
if (frame_is_intra_only(&cpi->common)) {
if (frame_is_intra_only(cm)) {
// Initialize max_mv_magnitude for use in the first INTER frame
// after a key/intra-only frame.
cpi->max_mv_magnitude = max_mv_def;
......@@ -2965,8 +2961,8 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
// Allow mv_steps to correspond to twice the max mv magnitude found
// in the previous frame, capped by the default max_mv_magnitude based
// on resolution.
cpi->mv_step_param = vp9_init_search_range(
cpi, MIN(max_mv_def, 2 * cpi->max_mv_magnitude));
cpi->mv_step_param = vp9_init_search_range(cpi, MIN(max_mv_def, 2 *
cpi->max_mv_magnitude));
cpi->max_mv_magnitude = 0;
}
}
......@@ -3003,9 +2999,8 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
// static regions if indicated.
// Only allowed in second pass of two pass (as requires lagged coding)
// and if the relevant speed feature flag is set.
if ((cpi->pass == 2) && (cpi->sf.static_segmentation)) {
if (cpi->pass == 2 && cpi->sf.static_segmentation)
configure_static_seg_features(cpi);
}
// For 1 pass CBR, check if we are dropping this frame.
// Never drop on key frame.
......@@ -3066,7 +3061,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
// should be larger. Q of 0 is disabled because we force tx size to be
// 16x16...
if (cpi->sf.super_fast_rtc) {
if (cpi->common.current_video_frame == 0)
if (cm->current_video_frame == 0)
q /= 3;
if (q == 0)
......@@ -3079,14 +3074,8 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
set_high_precision_mv(cpi, (q < HIGH_PRECISION_MV_QTHRESH));
}
encode_with_recode_loop(cpi,
size,
dest,
&q,
bottom_index,
top_index,
frame_over_shoot_limit,
frame_under_shoot_limit);
encode_with_recode_loop(cpi, size, dest, &q, bottom_index, top_index,
frame_over_shoot_limit, frame_under_shoot_limit);
// Special case code to reduce pulsing when key frames are forced at a
// fixed interval. Note the reconstruction error if it is the frame before
......@@ -3133,18 +3122,15 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
update_reference_frames(cpi);
for (t = TX_4X4; t <= TX_32X32; t++)
full_to_model_counts(cpi->common.counts.coef[t],
cpi->coef_counts[t]);
if (!cpi->common.error_resilient_mode &&
!cpi->common.frame_parallel_decoding_mode) {
vp9_adapt_coef_probs(&cpi->common);
}
if (!frame_is_intra_only(&cpi->common)) {
if (!cpi->common.error_resilient_mode &&
!cpi->common.frame_parallel_decoding_mode) {
vp9_adapt_mode_probs(&cpi->common);
vp9_adapt_mv_probs(&cpi->common, cpi->common.allow_high_precision_mv);
full_to_model_counts(cm->counts.coef[t], cpi->coef_counts[t]);
if (!cm->error_resilient_mode && !cm->frame_parallel_decoding_mode)
vp9_adapt_coef_probs(cm);
if (!frame_is_intra_only(cm)) {
if (!cm->error_resilient_mode && !cm->frame_parallel_decoding_mode) {
vp9_adapt_mode_probs(cm);
vp9_adapt_mv_probs(cm, cm->allow_high_precision_mv);
}
}
......@@ -3156,14 +3142,14 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
output_frame_level_debug_stats(cpi);
#endif
if (cpi->refresh_golden_frame == 1)
cm->frame_flags = cm->frame_flags | FRAMEFLAGS_GOLDEN;
cm->frame_flags |= FRAMEFLAGS_GOLDEN;
else
cm->frame_flags = cm->frame_flags&~FRAMEFLAGS_GOLDEN;
cm->frame_flags &= ~FRAMEFLAGS_GOLDEN;
if (cpi->refresh_alt_ref_frame == 1)
cm->frame_flags = cm->frame_flags | FRAMEFLAGS_ALTREF;
cm->frame_flags |= FRAMEFLAGS_ALTREF;
else
cm->frame_flags = cm->frame_flags&~FRAMEFLAGS_ALTREF;
cm->frame_flags &= ~FRAMEFLAGS_ALTREF;
get_ref_frame_flags(cpi);
......@@ -3212,6 +3198,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
// reset to normal state now that we are done.
if (!cm->show_existing_frame)
cm->last_show_frame = cm->show_frame;
if (cm->show_frame) {
// current mip will be the prev_mip for the next frame
MODE_INFO *temp = cm->prev_mip;
......@@ -3232,6 +3219,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
// update not a real frame
++cm->current_video_frame;
}
// restore prev_mi
cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1;
cm->prev_mi_grid_visible = cm->prev_mi_grid_base + cm->mode_info_stride + 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment