set_tile_limits(cpi);
}
-static int get_pass(MODE mode) {
- switch (mode) {
- case REALTIME:
- case ONE_PASS_GOOD:
- case ONE_PASS_BEST:
- return 0;
-
- case TWO_PASS_FIRST:
- return 1;
-
- case TWO_PASS_SECOND_GOOD:
- case TWO_PASS_SECOND_BEST:
- return 2;
- }
- return -1;
-}
-
void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) {
VP9_COMMON *const cm = &cpi->common;
RATE_CONTROL *const rc = &cpi->rc;
assert(cm->bit_depth > BITS_8);
cpi->oxcf = *oxcf;
- cpi->pass = get_pass(cpi->oxcf.mode);
rc->baseline_gf_interval = DEFAULT_GF_INTERVAL;
if ((cpi->svc.number_temporal_layers > 1 &&
cpi->oxcf.rc_mode == VPX_CBR) ||
- (cpi->svc.number_spatial_layers > 1 && cpi->pass == 2)) {
+ (cpi->svc.number_spatial_layers > 1 && cpi->oxcf.pass == 2)) {
vp9_update_layer_context_change_config(cpi,
(int)cpi->oxcf.target_bandwidth);
}
cpi->use_svc = 0;
init_config(cpi, oxcf);
- vp9_rc_init(&cpi->oxcf, cpi->pass, &cpi->rc);
+ vp9_rc_init(&cpi->oxcf, oxcf->pass, &cpi->rc);
cm->current_video_frame = 0;
// pending further tuning and testing. The code is left in place here
// as a place holder in regard to the required paths.
cpi->multi_arf_last_grp_enabled = 0;
- if (cpi->pass == 2) {
+ if (oxcf->pass == 2) {
if (cpi->use_svc) {
cpi->multi_arf_allowed = 0;
cpi->multi_arf_enabled = 0;
cpi->allow_encode_breakout = ENCODE_BREAKOUT_ENABLED;
- if (cpi->pass == 1) {
+ if (oxcf->pass == 1) {
vp9_init_first_pass(cpi);
- } else if (cpi->pass == 2) {
+ } else if (oxcf->pass == 2) {
const size_t packet_sz = sizeof(FIRSTPASS_STATS);
const int packets = (int)(oxcf->two_pass_stats_in.sz / packet_sz);
vp9_clear_system_state();
// printf("\n8x8-4x4:%d-%d\n", cpi->t8x8_count, cpi->t4x4_count);
- if (cpi->pass != 1) {
+ if (cpi->oxcf.pass != 1) {
FILE *f = fopen("opsnr.stt", "a");
double time_encoded = (cpi->last_end_time_stamp_seen
- cpi->first_time_stamp_ever) / 10000000.000;
} else { /* For non key/golden frames */
if (cpi->refresh_alt_ref_frame) {
int arf_idx = cpi->alt_fb_idx;
- if ((cpi->pass == 2) && cpi->multi_arf_allowed) {
+ if ((cpi->oxcf.pass == 2) && cpi->multi_arf_allowed) {
const GF_GROUP *const gf_group = &cpi->twopass.gf_group;
arf_idx = gf_group->arf_update_idx[gf_group->index];
}
VP9_COMMON *const cm = &cpi->common;
int arf_sign_bias;
- if ((cpi->pass == 2) && cpi->multi_arf_allowed) {
+ if ((cpi->oxcf.pass == 2) && cpi->multi_arf_allowed) {
const GF_GROUP *const gf_group = &cpi->twopass.gf_group;
arf_sign_bias = cpi->rc.source_alt_ref_active &&
(!cpi->refresh_alt_ref_frame ||
// 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->oxcf.pass == 2 && cpi->sf.static_segmentation)
configure_static_seg_features(cpi);
// Check if the current frame is skippable for the partition search in the
// second pass according to the first pass stats
- if (cpi->pass == 2 &&
+ if (cpi->oxcf.pass == 2 &&
(!cpi->use_svc || is_spatial_svc(cpi))) {
configure_skippable_frame(cpi);
}
// For 1 pass CBR, check if we are dropping this frame.
// Never drop on key frame.
- if (cpi->pass == 0 &&
+ if (cpi->oxcf.pass == 0 &&
cpi->oxcf.rc_mode == VPX_CBR &&
cm->frame_type != KEY_FRAME) {
if (vp9_rc_drop_frame(cpi)) {
RATE_CONTROL *const rc = &cpi->rc;
int arf_src_index = 0;
if (is_altref_enabled(cpi)) {
- if (cpi->pass == 2) {
+ if (cpi->oxcf.pass == 2) {
const GF_GROUP *const gf_group = &cpi->twopass.gf_group;
if (gf_group->update_type[gf_group->index] == ARF_UPDATE) {
arf_src_index = gf_group->arf_src_offset[gf_group->index];
static void check_src_altref(VP9_COMP *cpi) {
RATE_CONTROL *const rc = &cpi->rc;
- if (cpi->pass == 2) {
+ if (cpi->oxcf.pass == 2) {
const GF_GROUP *const gf_group = &cpi->twopass.gf_group;
rc->is_src_frame_alt_ref =
(gf_group->update_type[gf_group->index] == OVERLAY_UPDATE);
if (!cpi)
return -1;
- if (is_spatial_svc(cpi) && cpi->pass == 2) {
+ if (is_spatial_svc(cpi) && cpi->oxcf.pass == 2) {
#if CONFIG_SPATIAL_SVC
vp9_svc_lookahead_peek(cpi, cpi->lookahead, 0, 1);
#endif
} else {
*size = 0;
- if (flush && cpi->pass == 1 && !cpi->twopass.first_pass_done) {
+ if (flush && cpi->oxcf.pass == 1 && !cpi->twopass.first_pass_done) {
vp9_end_first_pass(cpi); /* get last stats packet */
cpi->twopass.first_pass_done = 1;
}
if (!cpi->use_svc && cpi->multi_arf_allowed) {
if (cm->frame_type == KEY_FRAME) {
init_buffer_indices(cpi);
- } else if (cpi->pass == 2) {
+ } else if (cpi->oxcf.pass == 2) {
const GF_GROUP *const gf_group = &cpi->twopass.gf_group;
cpi->alt_fb_idx = gf_group->arf_ref_idx[gf_group->index];
}
cpi->frame_flags = *frame_flags;
- if (cpi->pass == 2 &&
+ if (cpi->oxcf.pass == 2 &&
cm->current_video_frame == 0 &&
cpi->oxcf.allow_spatial_resampling &&
cpi->oxcf.rc_mode == VPX_VBR) {
vp9_vaq_init();
}
- if (cpi->pass == 1 &&
+ if (cpi->oxcf.pass == 1 &&
(!cpi->use_svc || is_spatial_svc(cpi))) {
const int lossless = is_lossless_requested(&cpi->oxcf);
cpi->mb.fwd_txm4x4 = lossless ? vp9_fwht4x4 : vp9_fdct4x4;
cpi->mb.itxm_add = lossless ? vp9_iwht4x4_add : vp9_idct4x4_add;
vp9_first_pass(cpi);
- } else if (cpi->pass == 2 &&
+ } else if (cpi->oxcf.pass == 2 &&
(!cpi->use_svc || is_spatial_svc(cpi))) {
Pass2Encode(cpi, size, dest, frame_flags);
} else if (cpi->use_svc) {
// Save layer specific state.
if ((cpi->svc.number_temporal_layers > 1 &&
cpi->oxcf.rc_mode == VPX_CBR) ||
- (cpi->svc.number_spatial_layers > 1 && cpi->pass == 2)) {
+ (cpi->svc.number_spatial_layers > 1 && cpi->oxcf.pass == 2)) {
vp9_save_layer_context(cpi);
}
vpx_usec_timer_mark(&cmptimer);
cpi->time_compress_data += vpx_usec_timer_elapsed(&cmptimer);
- if (cpi->b_calculate_psnr && cpi->pass != 1 && cm->show_frame)
+ if (cpi->b_calculate_psnr && cpi->oxcf.pass != 1 && cm->show_frame)
generate_psnr_packet(cpi);
#if CONFIG_INTERNAL_STATS
- if (cpi->pass != 1) {
+ if (cpi->oxcf.pass != 1) {
cpi->bytes += (int)(*size);
if (cm->show_frame) {
if (cpi->common.frame_type == KEY_FRAME) {
return rc->rate_correction_factors[KF_STD];
- } else if (cpi->pass == 2) {
+ } else if (cpi->oxcf.pass == 2) {
RATE_FACTOR_LEVEL rf_lvl =
cpi->twopass.gf_group.rf_level[cpi->twopass.gf_group.index];
return rc->rate_correction_factors[rf_lvl];
if (cpi->common.frame_type == KEY_FRAME) {
rc->rate_correction_factors[KF_STD] = factor;
- } else if (cpi->pass == 2) {
+ } else if (cpi->oxcf.pass == 2) {
RATE_FACTOR_LEVEL rf_lvl =
cpi->twopass.gf_group.rf_level[cpi->twopass.gf_group.index];
rc->rate_correction_factors[rf_lvl] = factor;
int vp9_rc_pick_q_and_bounds(const VP9_COMP *cpi,
int *bottom_index, int *top_index) {
int q;
- if (cpi->pass == 0) {
+ if (cpi->oxcf.pass == 0) {
if (cpi->oxcf.rc_mode == VPX_CBR)
q = rc_pick_q_and_bounds_one_pass_cbr(cpi, bottom_index, top_index);
else
// this frame refreshes means next frames don't unless specified by user
rc->frames_since_golden = 0;
- if (cpi->pass == 2) {
+ if (cpi->oxcf.pass == 2) {
if (!rc->source_alt_ref_pending &&
cpi->twopass.gf_group.rf_level[0] == GF_ARF_STD)
rc->source_alt_ref_active = 0;
(~VP9_LAST_FLAG & ~VP9_GOLD_FLAG & ~VP9_ALT_FLAG);
}
- if (cpi->pass == 0 && cpi->oxcf.rc_mode == VPX_CBR) {
+ if (cpi->oxcf.pass == 0 && cpi->oxcf.rc_mode == VPX_CBR) {
target = calc_iframe_target_size_one_pass_cbr(cpi);
}
} else {
cpi->ref_frame_flags &= (~VP9_ALT_FLAG);
}
- if (cpi->pass == 0 && cpi->oxcf.rc_mode == VPX_CBR) {
+ if (cpi->oxcf.pass == 0 && cpi->oxcf.rc_mode == VPX_CBR) {
target = calc_pframe_target_size_one_pass_cbr(cpi);
}
}