Commit c72be96b authored by Jim Bankoski's avatar Jim Bankoski

remove macros obfuscating mv costing

cleanup

Change-Id: I565eee40d900e0441ad211b65ac829fc5b93d94a
parent 8959c8b1
......@@ -690,10 +690,8 @@ static unsigned int pick_best_mv_ref(MACROBLOCK *x,
int max_mv = MV_MAX;
cost = vp9_cost_mv_ref_id(xd->mb_mv_ref_id_probs[ref_frame], 0) +
vp9_mv_bit_cost(&target_mv,
&mv_ref_list[0],
XMVCOST, 96,
xd->allow_high_precision_mv);
vp9_mv_bit_cost(&target_mv, &mv_ref_list[0], x->nmvjointcost,
x->mvcost, 96, xd->allow_high_precision_mv);
// Use 4 for now : for (i = 1; i < MAX_MV_REFS; ++i ) {
......@@ -714,10 +712,8 @@ static unsigned int pick_best_mv_ref(MACROBLOCK *x,
}
cost2 = vp9_cost_mv_ref_id(xd->mb_mv_ref_id_probs[ref_frame], i) +
vp9_mv_bit_cost(&target_mv,
&mv_ref_list[i],
XMVCOST, 96,
xd->allow_high_precision_mv);
vp9_mv_bit_cost(&target_mv, &mv_ref_list[i], x->nmvjointcost,
x->mvcost, 96, xd->allow_high_precision_mv);
if (cost2 < cost) {
cost = cost2;
......
......@@ -118,12 +118,14 @@ typedef struct macroblock {
int *nmvcost[2];
int nmvcosts_hp[2][MV_VALS];
int *nmvcost_hp[2];
int **mvcost;
int nmvjointsadcost[MV_JOINTS];
int nmvsadcosts[2][MV_VALS];
int *nmvsadcost[2];
int nmvsadcosts_hp[2][MV_VALS];
int *nmvsadcost_hp[2];
int **mvsadcost;
int mbmode_cost[2][MB_MODE_COUNT];
int intra_uv_mode_cost[2][MB_MODE_COUNT];
......
......@@ -394,7 +394,8 @@ static void first_pass_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
ref_mv_full.as_mv.row = ref_mv->as_mv.row >> 3;
tmp_err = cpi->diamond_search_sad(x, b, d, &ref_mv_full, &tmp_mv, step_param,
x->sadperbit16, &num00, &v_fn_ptr,
XMVCOST, ref_mv);
x->nmvjointcost,
x->mvcost, ref_mv);
if (tmp_err < INT_MAX - new_mv_mode_penalty)
tmp_err += new_mv_mode_penalty;
......@@ -417,7 +418,8 @@ static void first_pass_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
tmp_err = cpi->diamond_search_sad(x, b, d, &ref_mv_full, &tmp_mv,
step_param + n, x->sadperbit16,
&num00, &v_fn_ptr,
XMVCOST, ref_mv);
x->nmvjointcost,
x->mvcost, ref_mv);
if (tmp_err < INT_MAX - new_mv_mode_penalty)
tmp_err += new_mv_mode_penalty;
......
......@@ -56,8 +56,8 @@ static unsigned int do_16x16_motion_iteration(VP9_COMP *cpi,
step_param,
x->errorperbit,
&v_fn_ptr,
NULLMVCOST,
NULLMVCOST,
NULL, NULL,
NULL, NULL,
ref_mv);
// Try sub-pixel MC
......@@ -69,7 +69,7 @@ static unsigned int do_16x16_motion_iteration(VP9_COMP *cpi,
x, b, d,
dst_mv, ref_mv,
x->errorperbit, &v_fn_ptr,
NULLMVCOST,
NULL, NULL,
& distortion, &sse);
}
......
This diff is collapsed.
......@@ -15,13 +15,6 @@
#include "block.h"
#include "variance.h"
#define MVCOSTS mvjcost, mvcost
#define MVSADCOSTS mvjsadcost, mvsadcost
#define DEC_MVCOSTS int *mvjcost, int *mvcost[2]
#define DEC_MVSADCOSTS int *mvjsadcost, int *mvsadcost[2]
#define NULLMVCOST NULL, NULL
#define XMVCOST x->nmvjointcost, (x->e_mbd.allow_high_precision_mv?x->nmvcost_hp:x->nmvcost)
#ifdef ENTROPY_STATS
extern void init_mv_ref_counts();
extern void accum_mv_refs(MB_PREDICTION_MODE, const int near_mv_ref_cts[4]);
......@@ -33,8 +26,8 @@ extern void accum_mv_refs(MB_PREDICTION_MODE, const int near_mv_ref_cts[4]);
#define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS-1)) // Maximum size of the first step in full pel units
extern void vp9_clamp_mv_min_max(MACROBLOCK *x, int_mv *ref_mv);
extern int vp9_mv_bit_cost(int_mv *mv, int_mv *ref, DEC_MVCOSTS,
int Weight, int ishp);
extern int vp9_mv_bit_cost(int_mv *mv, int_mv *ref, int *mvjcost,
int *mvcost[2], int Weight, int ishp);
extern void vp9_init_dsmotion_compensation(MACROBLOCK *x, int stride);
extern void vp9_init3smotion_compensation(MACROBLOCK *x, int stride);
// Runs sequence of diamond searches in smaller steps for RD
......@@ -55,15 +48,14 @@ extern int vp9_hex_search
int search_param,
int error_per_bit,
const vp9_variance_fn_ptr_t *vf,
DEC_MVSADCOSTS,
DEC_MVCOSTS,
int *mvjsadcost, int *mvsadcost[2],
int *mvjcost, int *mvcost[2],
int_mv *center_mv
);
typedef int (fractional_mv_step_fp)
(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *bestmv, int_mv *ref_mv,
int error_per_bit, const vp9_variance_fn_ptr_t *vfp, DEC_MVCOSTS,
int *distortion, unsigned int *sse);
typedef int (fractional_mv_step_fp) (MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv
*bestmv, int_mv *ref_mv, int error_per_bit, const vp9_variance_fn_ptr_t *vfp,
int *mvjcost, int *mvcost[2], int *distortion, unsigned int *sse);
extern fractional_mv_step_fp vp9_find_best_sub_pixel_step_iteratively;
extern fractional_mv_step_fp vp9_find_best_sub_pixel_step;
extern fractional_mv_step_fp vp9_find_best_half_pixel_step;
......@@ -71,20 +63,23 @@ extern fractional_mv_step_fp vp9_find_best_half_pixel_step;
typedef int (*vp9_full_search_fn_t)(MACROBLOCK *x, BLOCK *b, BLOCKD *d,
int_mv *ref_mv, int sad_per_bit,
int distance, vp9_variance_fn_ptr_t *fn_ptr,
DEC_MVCOSTS, int_mv *center_mv);
int *mvjcost, int *mvcost[2],
int_mv *center_mv);
typedef int (*vp9_refining_search_fn_t)(MACROBLOCK *x, BLOCK *b, BLOCKD *d,
int_mv *ref_mv, int sad_per_bit,
int distance,
vp9_variance_fn_ptr_t *fn_ptr,
DEC_MVCOSTS, int_mv *center_mv);
int *mvjcost, int *mvcost[2],
int_mv *center_mv);
typedef int (*vp9_diamond_search_fn_t)(MACROBLOCK *x, BLOCK *b, BLOCKD *d,
int_mv *ref_mv, int_mv *best_mv,
int search_param, int sad_per_bit,
int *num00,
vp9_variance_fn_ptr_t *fn_ptr,
DEC_MVCOSTS, int_mv *center_mv);
int *mvjcost, int *mvcost[2],
int_mv *center_mv);
#if CONFIG_RUNTIME_CPU_DETECT
......
......@@ -222,7 +222,16 @@ static void init_minq_luts(void) {
}
}
static void set_mvcost(MACROBLOCK *mb) {
if (mb->e_mbd.allow_high_precision_mv) {
mb->mvcost = mb->nmvcost_hp;
mb->mvsadcost = mb->nmvsadcost_hp;
} else {
mb->mvcost = mb->nmvcost;
mb->mvsadcost = mb->nmvsadcost;
}
}
static void init_base_skip_probs(void) {
int i;
double q;
......@@ -1518,6 +1527,7 @@ void vp9_change_config(VP9_PTR ptr, VP9_CONFIG *oxcf) {
setup_features(cpi);
cpi->mb.e_mbd.allow_high_precision_mv = 0; // Default mv precision adaptation
set_mvcost(&cpi->mb);
{
int i;
......@@ -3122,6 +3132,7 @@ static void encode_frame_to_data_rate
}
/* TODO: Decide this more intelligently */
xd->allow_high_precision_mv = (Q < HIGH_PRECISION_MV_QTHRESH);
set_mvcost(&cpi->mb);
}
#if CONFIG_POSTPROC
......@@ -4028,6 +4039,8 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags,
cpi->source = NULL;
cpi->mb.e_mbd.allow_high_precision_mv = ALTREF_HIGH_PRECISION_MV;
set_mvcost(&cpi->mb);
// Should we code an alternate reference frame
if (cpi->oxcf.play_alternate &&
cpi->source_alt_ref_pending) {
......
......@@ -1912,7 +1912,7 @@ static int labels2mode(
int_mv seg_mvs[MAX_REF_FRAMES - 1],
int_mv *best_ref_mv,
int_mv *second_best_ref_mv,
DEC_MVCOSTS) {
int *mvjcost, int *mvcost[2]) {
MACROBLOCKD *const xd = &x->e_mbd;
MODE_INFO *const mic = xd->mode_info_context;
MB_MODE_INFO * mbmi = &mic->mbmi;
......@@ -1947,11 +1947,11 @@ static int labels2mode(
seg_mvs[mbmi->second_ref_frame - 1].as_int;
}
thismvcost = vp9_mv_bit_cost(this_mv, best_ref_mv, MVCOSTS,
thismvcost = vp9_mv_bit_cost(this_mv, best_ref_mv, mvjcost, mvcost,
102, xd->allow_high_precision_mv);
if (mbmi->second_ref_frame) {
thismvcost += vp9_mv_bit_cost(this_second_mv, second_best_ref_mv,
MVCOSTS, 102,
mvjcost, mvcost, 102,
xd->allow_high_precision_mv);
}
break;
......@@ -2318,7 +2318,8 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
thissme = cpi->full_search_sad(x, c, e, &mvp_full,
sadpb, 16, v_fn_ptr,
XMVCOST, bsi->ref_mv);
x->nmvjointcost, x->mvcost,
bsi->ref_mv);
if (thissme < bestsme) {
bestsme = thissme;
......@@ -2336,7 +2337,8 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
unsigned int sse;
cpi->find_fractional_mv_step(x, c, e, &mode_mv[NEW4X4],
bsi->ref_mv, x->errorperbit, v_fn_ptr,
XMVCOST, &distortion, &sse);
x->nmvjointcost, x->mvcost,
&distortion, &sse);
// safe motion search result for use in compound prediction
seg_mvs[i][mbmi->ref_frame - 1].as_int = mode_mv[NEW4X4].as_int;
......@@ -2353,7 +2355,8 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
rate = labels2mode(x, labels, i, this_mode, &mode_mv[this_mode],
&second_mode_mv[this_mode], seg_mvs[i],
bsi->ref_mv, bsi->second_ref_mv, XMVCOST);
bsi->ref_mv, bsi->second_ref_mv, x->nmvjointcost,
x->mvcost);
// Trap vectors that reach beyond the UMV borders
if (((mode_mv[this_mode].as_mv.row >> 3) < x->mv_row_min) ||
......@@ -2411,7 +2414,7 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
labels2mode(x, labels, i, mode_selected, &mode_mv[mode_selected],
&second_mode_mv[mode_selected], seg_mvs[i],
bsi->ref_mv, bsi->second_ref_mv, XMVCOST);
bsi->ref_mv, bsi->second_ref_mv, x->nmvjointcost, x->mvcost);
br += sbr;
bd += sbd;
......@@ -3244,11 +3247,11 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
return INT64_MAX;
*rate2 += vp9_mv_bit_cost(&frame_mv[NEWMV][refs[0]],
&frame_best_ref_mv[refs[0]],
XMVCOST, 96,
x->nmvjointcost, x->mvcost, 96,
x->e_mbd.allow_high_precision_mv);
*rate2 += vp9_mv_bit_cost(&frame_mv[NEWMV][refs[1]],
&frame_best_ref_mv[refs[1]],
XMVCOST, 96,
x->nmvjointcost, x->mvcost, 96,
x->e_mbd.allow_high_precision_mv);
} else {
int bestsme = INT_MAX;
......@@ -3300,14 +3303,16 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
&frame_best_ref_mv[refs[0]],
x->errorperbit,
&cpi->fn_ptr[block_size],
XMVCOST, &dis, &sse);
x->nmvjointcost, x->mvcost,
&dis, &sse);
}
d->bmi.as_mv.first.as_int = tmp_mv.as_int;
frame_mv[NEWMV][refs[0]].as_int = d->bmi.as_mv.first.as_int;
// Add the new motion vector cost to our rolling cost variable
*rate2 += vp9_mv_bit_cost(&tmp_mv, &frame_best_ref_mv[refs[0]],
XMVCOST, 96, xd->allow_high_precision_mv);
x->nmvjointcost, x->mvcost,
96, xd->allow_high_precision_mv);
}
break;
case NEARESTMV:
......
......@@ -185,7 +185,7 @@ static int temporal_filter_find_matching_mb_c
// Ignore mv costing by sending NULL pointer instead of cost arrays
bestsme = vp9_hex_search(x, b, d, &best_ref_mv1_full, &d->bmi.as_mv.first,
step_param, sadpb, &cpi->fn_ptr[BLOCK_16X16],
NULLMVCOST, NULLMVCOST,
NULL, NULL, NULL, NULL,
&best_ref_mv1);
#if ALT_REF_SUBPEL_ENABLED
......@@ -199,7 +199,7 @@ static int temporal_filter_find_matching_mb_c
&best_ref_mv1,
x->errorperbit,
&cpi->fn_ptr[BLOCK_16X16],
NULLMVCOST,
NULL, NULL,
&distortion, &sse);
}
#endif
......
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