Merge "Auto adapt step size feature."

This commit is contained in:
Paul Wilkins 2013-06-27 02:28:41 -07:00 committed by Gerrit Code Review
commit 05ffdf2625
7 changed files with 58 additions and 23 deletions

View File

@ -754,11 +754,11 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m,
#ifdef ENTROPY_STATS
active_section = 11;
#endif
vp9_encode_mv(bc, &blockmv.as_mv, &mi->best_mv.as_mv,
vp9_encode_mv(cpi, bc, &blockmv.as_mv, &mi->best_mv.as_mv,
nmvc, xd->allow_high_precision_mv);
if (mi->ref_frame[1] > INTRA_FRAME)
vp9_encode_mv(bc,
vp9_encode_mv(cpi, bc,
&cpi->mb.partition_info->bmi[j].second_mv.as_mv,
&mi->best_second_mv.as_mv,
nmvc, xd->allow_high_precision_mv);
@ -769,12 +769,12 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m,
#ifdef ENTROPY_STATS
active_section = 5;
#endif
vp9_encode_mv(bc,
vp9_encode_mv(cpi, bc,
&mi->mv[0].as_mv, &mi->best_mv.as_mv,
nmvc, xd->allow_high_precision_mv);
if (mi->ref_frame[1] > INTRA_FRAME)
vp9_encode_mv(bc,
vp9_encode_mv(cpi, bc,
&mi->mv[1].as_mv, &mi->best_second_mv.as_mv,
nmvc, xd->allow_high_precision_mv);
}

View File

@ -591,7 +591,8 @@ void vp9_write_nmv_probs(VP9_COMP* const cpi, int usehp, vp9_writer* const bc) {
}
}
void vp9_encode_mv(vp9_writer* w, const MV* mv, const MV* ref,
void vp9_encode_mv(VP9_COMP* cpi, vp9_writer* w,
const MV* mv, const MV* ref,
const nmv_context* mvctx, int usehp) {
const MV diff = {mv->row - ref->row,
mv->col - ref->col};
@ -604,6 +605,13 @@ void vp9_encode_mv(vp9_writer* w, const MV* mv, const MV* ref,
if (mv_joint_horizontal(j))
encode_mv_component(w, diff.col, &mvctx->comps[1], usehp);
// If auto_mv_step_size is enabled and it is an arf/non shown frame
// then keep track of the largest motion vector component used.
if (cpi->sf.auto_mv_step_size && !cpi->common.show_frame) {
cpi->max_mv_magnitude = MAX((MAX(abs(mv->row), abs(mv->col)) >> 3),
cpi->max_mv_magnitude);
}
}
void vp9_build_nmv_cost_table(int *mvjoint,

View File

@ -16,7 +16,7 @@
void vp9_write_nmv_probs(VP9_COMP* const, int usehp, vp9_writer* const);
void vp9_encode_mv(vp9_writer* w, const MV* mv, const MV* ref,
void vp9_encode_mv(VP9_COMP *cpi, vp9_writer* w, const MV* mv, const MV* ref,
const nmv_context* mvctx, int usehp);
void vp9_build_nmv_cost_table(int *mvjoint,

View File

@ -41,6 +41,9 @@ void vp9_clamp_mv_min_max(MACROBLOCK *x, int_mv *ref_mv) {
int vp9_init_search_range(VP9_COMP *cpi, int size) {
int sr = 0;
// Minimum search size no matter what the passed in value.
size = MAX(16, size);
while ((size << sr) < MAX_FULL_PEL_VAL)
sr++;

View File

@ -671,6 +671,12 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
cpi->mode_chosen_counts[i] = 0;
}
// Initialize cpi->max_mv_magnitude if appropriate.
if ((cpi->common.frame_type == KEY_FRAME) || cpi->common.intra_only ||
(cpi->common.show_frame == 0)) {
cpi->max_mv_magnitude = 0;
}
// best quality defaults
sf->RD = 1;
sf->search_method = NSTEP;
@ -681,6 +687,7 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
sf->iterative_sub_pixel = 1;
sf->optimize_coefficients = !cpi->oxcf.lossless;
sf->reduce_first_step_size = 0;
sf->auto_mv_step_size = 0;
sf->max_step_search_steps = MAX_MVSEARCH_STEPS;
sf->comp_inter_joint_search_thresh = BLOCK_SIZE_AB4X4;
sf->adpative_rd_thresh = 0;
@ -716,35 +723,36 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
#else
sf->static_segmentation = 0;
#endif
sf->comp_inter_joint_search_thresh = BLOCK_SIZE_SB8X8;
sf->comp_inter_joint_search_thresh = BLOCK_SIZE_MB16X16;
sf->auto_mv_step_size = 1;
sf->use_avoid_tested_higherror = 1;
sf->adpative_rd_thresh = 1;
if (speed == 1) {
sf->comp_inter_joint_search_thresh = BLOCK_SIZE_TYPES;
sf->optimize_coefficients = 0;
sf->reduce_first_step_size = 1;
sf->use_avoid_tested_higherror = 1;
sf->adjust_thresholds_by_speed = 1;
sf->use_largest_txform = !(cpi->common.frame_type == KEY_FRAME ||
cpi->common.intra_only ||
cpi->common.show_frame == 0);
}
if (speed == 2) {
sf->comp_inter_joint_search_thresh = BLOCK_SIZE_SB8X8;
sf->adjust_thresholds_by_speed = 1;
sf->comp_inter_joint_search_thresh = BLOCK_SIZE_TYPES;
sf->reduce_first_step_size = 1;
sf->optimize_coefficients = 0;
sf->use_lastframe_partitioning = 1;
sf->reduce_first_step_size = 0;
}
if (speed == 3) {
sf->comp_inter_joint_search_thresh = BLOCK_SIZE_SB8X8;
sf->comp_inter_joint_search_thresh = BLOCK_SIZE_TYPES;
sf->partition_by_variance = 1;
sf->reduce_first_step_size = 0;
sf->reduce_first_step_size = 1;
}
if (speed == 4) {
sf->reduce_first_step_size = 0;
sf->comp_inter_joint_search_thresh = BLOCK_SIZE_SB8X8;
sf->reduce_first_step_size = 1;
sf->comp_inter_joint_search_thresh = BLOCK_SIZE_TYPES;
sf->use_one_partition_size_always = 1;
sf->always_this_block_size = BLOCK_SIZE_MB16X16;
}
if (speed == 2) {
/* if (speed == 2) {
sf->reduce_first_step_size = 0;
sf->comp_inter_joint_search_thresh = BLOCK_SIZE_SB8X8;
sf->use_partitions_less_than = 1;
@ -755,7 +763,7 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
sf->comp_inter_joint_search_thresh = BLOCK_SIZE_SB8X8;
sf->use_partitions_greater_than = 1;
sf->greater_than_block_size = BLOCK_SIZE_SB8X8;
}
}*/
break;

View File

@ -211,6 +211,7 @@ typedef struct {
int thresh_mult[MAX_MODES];
int max_step_search_steps;
int reduce_first_step_size;
int auto_mv_step_size;
int optimize_coefficients;
int search_best_filter;
int static_segmentation;
@ -472,6 +473,8 @@ typedef struct VP9_COMP {
SPEED_FEATURES sf;
int error_bins[1024];
unsigned int max_mv_magnitude;
// Data used for real time conferencing mode to help determine if it would be good to update the gf
int inter_zz_count;
int gf_bad_count;

View File

@ -228,7 +228,10 @@ void vp9_initialize_rd_consts(VP9_COMP *cpi, int qindex) {
}
cpi->rd_baseline_thresh[bsize][i] = cpi->rd_threshes[bsize][i];
cpi->rd_thresh_freq_fact[bsize][i] = MAX_RD_THRESH_FREQ_FACT;
if (cpi->sf.adpative_rd_thresh)
cpi->rd_thresh_freq_fact[bsize][i] = MAX_RD_THRESH_FREQ_FACT;
else
cpi->rd_thresh_freq_fact[bsize][i] = BASE_RD_THRESH_FREQ_FACT;
}
}
} else {
@ -248,7 +251,11 @@ void vp9_initialize_rd_consts(VP9_COMP *cpi, int qindex) {
cpi->rd_threshes[bsize][i] = INT_MAX;
}
cpi->rd_baseline_thresh[bsize][i] = cpi->rd_threshes[bsize][i];
cpi->rd_thresh_freq_fact[bsize][i] = MAX_RD_THRESH_FREQ_FACT;
if (cpi->sf.adpative_rd_thresh)
cpi->rd_thresh_freq_fact[bsize][i] = MAX_RD_THRESH_FREQ_FACT;
else
cpi->rd_thresh_freq_fact[bsize][i] = BASE_RD_THRESH_FREQ_FACT;
}
}
}
@ -2023,8 +2030,14 @@ static void single_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
vp9_clamp_mv_min_max(x, &ref_mv);
step_param = vp9_init_search_range(
cpi, MIN(cpi->common.width, cpi->common.height));
// Work out the size of the first step in the mv step search.
// 0 here is maximum length first step. 1 is MAX >> 1 etc.
if (cpi->sf.auto_mv_step_size && cpi->common.show_frame) {
step_param = vp9_init_search_range(cpi, cpi->max_mv_magnitude);
} else {
step_param = vp9_init_search_range(
cpi, MIN(cpi->common.width, cpi->common.height));
}
// mvp_full.as_int = ref_mv[0].as_int;
mvp_full.as_int =