Use full-pixel MV in mvsadcost calculation
MV sad cost error is only used in full-pixel motion search, which only need full-pixel resolution instead of quarter-pixel resolution. This change reduced mvsadcost table size, and removed unneccessary pamameter passing since this table is constant once it is generated. Change-Id: I9f931e55f6abc3c99011321f1dfb2f3562e6f6b0
This commit is contained in:
parent
534ea700bd
commit
3d6815817c
@ -18,6 +18,8 @@ enum
|
||||
{
|
||||
mv_max = 1023, /* max absolute value of a MV component */
|
||||
MVvals = (2 * mv_max) + 1, /* # possible values "" */
|
||||
mvfp_max = 255, /* max absolute value of a full pixel MV component */
|
||||
MVfpvals = (2 * mvfp_max) +1, /* # possible full pixel MV values */
|
||||
|
||||
mvlong_width = 10, /* Large MVs have 9 bit magnitudes */
|
||||
mvnum_short = 8, /* magnitudes 0 through 7 */
|
||||
|
@ -86,7 +86,7 @@ typedef struct
|
||||
|
||||
int mvcosts[2][MVvals+1];
|
||||
int *mvcost[2];
|
||||
int mvsadcosts[2][MVvals+1];
|
||||
int mvsadcosts[2][MVfpvals+1];
|
||||
int *mvsadcost[2];
|
||||
int mbmode_cost[2][MB_MODE_COUNT];
|
||||
int intra_uv_mode_cost[2][MB_MODE_COUNT];
|
||||
|
@ -979,7 +979,7 @@ void vp8_encode_frame(VP8_COMP *cpi)
|
||||
}
|
||||
|
||||
if (flag[0] || flag[1])
|
||||
vp8_build_component_cost_table(cpi->mb.mvcost, cpi->mb.mvsadcost, (const MV_CONTEXT *) cm->fc.mvc, flag);
|
||||
vp8_build_component_cost_table(cpi->mb.mvcost, (const MV_CONTEXT *) cm->fc.mvc, flag);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -134,31 +134,14 @@ static unsigned int cost_mvcomponent(const int v, const struct mv_context *mvc)
|
||||
|
||||
return cost; // + vp8_cost_bit( p [MVPsign], v < 0);
|
||||
}
|
||||
//#define M_LOG2_E 0.693147180559945309417
|
||||
//#define log2f(x) (log (x) / (float) M_LOG2_E)
|
||||
|
||||
void vp8_build_component_cost_table(int *mvcost[2], int *mvsadcost[2], const MV_CONTEXT *mvc, int mvc_flag[2])
|
||||
void vp8_build_component_cost_table(int *mvcost[2], const MV_CONTEXT *mvc, int mvc_flag[2])
|
||||
{
|
||||
int i = 1; //-mv_max;
|
||||
unsigned int cost0 = 0;
|
||||
unsigned int cost1 = 0;
|
||||
|
||||
vp8_clear_system_state();
|
||||
#if 0
|
||||
mvsadcost [0] [0] = 300;
|
||||
mvsadcost [1] [0] = 300;
|
||||
|
||||
do
|
||||
{
|
||||
double z = 256 * (2 * (log2f(2 * i) + .6));
|
||||
mvsadcost [0][i] = (int) z;
|
||||
mvsadcost [1][i] = (int) z;
|
||||
mvsadcost [0][-i] = (int) z;
|
||||
mvsadcost [1][-i] = (int) z;
|
||||
}
|
||||
while (++i <= mv_max);
|
||||
|
||||
#endif
|
||||
|
||||
i = 1;
|
||||
|
||||
@ -193,16 +176,6 @@ void vp8_build_component_cost_table(int *mvcost[2], int *mvsadcost[2], const MV_
|
||||
}
|
||||
while (++i <= mv_max);
|
||||
}
|
||||
|
||||
/*
|
||||
i=-mv_max;
|
||||
do
|
||||
{
|
||||
mvcost [0] [i] = cost_mvcomponent( i, mvc[0]);
|
||||
mvcost [1] [i] = cost_mvcomponent( i, mvc[1]);
|
||||
}
|
||||
while( ++i <= mv_max);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@ -436,7 +409,7 @@ void vp8_write_mvprobs(VP8_COMP *cpi)
|
||||
);
|
||||
|
||||
if (flags[0] || flags[1])
|
||||
vp8_build_component_cost_table(cpi->mb.mvcost, cpi->mb.mvsadcost, (const MV_CONTEXT *) cpi->common.fc.mvc, flags);
|
||||
vp8_build_component_cost_table(cpi->mb.mvcost, (const MV_CONTEXT *) cpi->common.fc.mvc, flags);
|
||||
|
||||
#ifdef ENTROPY_STATS
|
||||
active_section = 5;
|
||||
|
@ -16,6 +16,6 @@
|
||||
|
||||
void vp8_write_mvprobs(VP8_COMP *);
|
||||
void vp8_encode_motion_vector(vp8_writer *, const MV *, const MV_CONTEXT *);
|
||||
void vp8_build_component_cost_table(int *mvcost[2], int *mvsadcost[2], const MV_CONTEXT *mvc, int mvc_flag[2]);
|
||||
void vp8_build_component_cost_table(int *mvcost[2], const MV_CONTEXT *mvc, int mvc_flag[2]);
|
||||
|
||||
#endif
|
||||
|
@ -319,8 +319,8 @@ static void setup_mbby_copy(MACROBLOCK *mbdst, MACROBLOCK *mbsrc)
|
||||
vpx_memcpy(z->mvcosts, x->mvcosts, sizeof(x->mvcosts));
|
||||
z->mvcost[0] = &z->mvcosts[0][mv_max+1];
|
||||
z->mvcost[1] = &z->mvcosts[1][mv_max+1];
|
||||
z->mvsadcost[0] = &z->mvsadcosts[0][mv_max+1];
|
||||
z->mvsadcost[1] = &z->mvsadcosts[1][mv_max+1];
|
||||
z->mvsadcost[0] = &z->mvsadcosts[0][mvfp_max+1];
|
||||
z->mvsadcost[1] = &z->mvsadcosts[1][mvfp_max+1];
|
||||
|
||||
|
||||
vpx_memcpy(z->token_costs, x->token_costs, sizeof(x->token_costs));
|
||||
|
@ -446,7 +446,7 @@ static void first_pass_motion_search(VP8_COMP *cpi, MACROBLOCK *x, MV *ref_mv, M
|
||||
xd->pre.y_buffer = recon_buffer->y_buffer + recon_yoffset;
|
||||
|
||||
// Initial step/diamond search centred on best mv
|
||||
tmp_err = cpi->diamond_search_sad(x, b, d, ref_mv, &tmp_mv, step_param, x->errorperbit, &num00, &v_fn_ptr, x->mvsadcost, x->mvcost, ref_mv);
|
||||
tmp_err = cpi->diamond_search_sad(x, b, d, ref_mv, &tmp_mv, step_param, x->errorperbit, &num00, &v_fn_ptr, x->mvcost, ref_mv);
|
||||
if ( tmp_err < INT_MAX-new_mv_mode_penalty )
|
||||
tmp_err += new_mv_mode_penalty;
|
||||
|
||||
@ -469,7 +469,7 @@ static void first_pass_motion_search(VP8_COMP *cpi, MACROBLOCK *x, MV *ref_mv, M
|
||||
num00--;
|
||||
else
|
||||
{
|
||||
tmp_err = cpi->diamond_search_sad(x, b, d, ref_mv, &tmp_mv, step_param + n, x->errorperbit, &num00, &v_fn_ptr, x->mvsadcost, x->mvcost, ref_mv);
|
||||
tmp_err = cpi->diamond_search_sad(x, b, d, ref_mv, &tmp_mv, step_param + n, x->errorperbit, &num00, &v_fn_ptr, x->mvcost, ref_mv);
|
||||
if ( tmp_err < INT_MAX-new_mv_mode_penalty )
|
||||
tmp_err += new_mv_mode_penalty;
|
||||
|
||||
@ -540,7 +540,7 @@ void vp8_first_pass(VP8_COMP *cpi)
|
||||
int flag[2] = {1, 1};
|
||||
vp8_initialize_rd_consts(cpi, vp8_dc_quant(cm->base_qindex, cm->y1dc_delta_q));
|
||||
vpx_memcpy(cm->fc.mvc, vp8_default_mv_context, sizeof(vp8_default_mv_context));
|
||||
vp8_build_component_cost_table(cpi->mb.mvcost, cpi->mb.mvsadcost, (const MV_CONTEXT *) cm->fc.mvc, flag);
|
||||
vp8_build_component_cost_table(cpi->mb.mvcost, (const MV_CONTEXT *) cm->fc.mvc, flag);
|
||||
}
|
||||
|
||||
// for each macroblock row in image
|
||||
|
@ -54,6 +54,11 @@ static int mv_err_cost(MV *mv, MV *ref, int *mvcost[2], int error_per_bit)
|
||||
//return (vp8_mv_bit_cost(mv, ref, mvcost, 128) * error_per_bit + 128) >> 8;
|
||||
}
|
||||
|
||||
static int mvsad_err_cost(MV *mv, MV *ref, int *mvsadcost[2], int error_per_bit)
|
||||
{
|
||||
/* Calculate sad error cost on full pixel basis. */
|
||||
return ((mvsadcost[0][(mv->row - ref->row)] + mvsadcost[1][(mv->col - ref->col)]) * error_per_bit + 128) >> 8;
|
||||
}
|
||||
|
||||
static int mv_bits(MV *mv, MV *ref, int *mvcost[2])
|
||||
{
|
||||
@ -753,7 +758,7 @@ int vp8_find_best_half_pixel_step(MACROBLOCK *mb, BLOCK *b, BLOCKD *d, MV *bestm
|
||||
}
|
||||
|
||||
|
||||
#define MVC(r,c) (((mvsadcost[0][((r)<<2)-rr] + mvsadcost[1][((c)<<2) - rc]) * error_per_bit + 128 )>>8 ) // estimated cost of a motion vector (r,c)
|
||||
#define MVC(r,c) (((mvsadcost[0][r-rr] + mvsadcost[1][c-rc]) * error_per_bit + 128 )>>8 ) // estimated cost of a motion vector (r,c)
|
||||
#define PRE(r,c) (*(d->base_pre) + d->pre + (r) * d->pre_stride + (c)) // pointer to predictor base of a motionvector
|
||||
#define DIST(r,c,v) vfp->sdf( src,src_stride,PRE(r,c),d->pre_stride, v) // returns sad error score.
|
||||
#define ERR(r,c,v) (MVC(r,c)+DIST(r,c,v)) // returns distortion + motion vector cost
|
||||
@ -801,8 +806,8 @@ int vp8_hex_search
|
||||
|
||||
if (br > x->mv_row_max) br = x->mv_row_max;
|
||||
|
||||
rr >>= 1;
|
||||
rc >>= 1;
|
||||
rr >>= 3;
|
||||
rc >>= 3;
|
||||
|
||||
besterr = ERR(br, bc, thiserr);
|
||||
|
||||
@ -915,7 +920,6 @@ int vp8_diamond_search_sad
|
||||
int error_per_bit,
|
||||
int *num00,
|
||||
vp8_variance_fn_ptr_t *fn_ptr,
|
||||
int *mvsadcost[2],
|
||||
int *mvcost[2],
|
||||
MV *center_mv
|
||||
)
|
||||
@ -944,8 +948,16 @@ int vp8_diamond_search_sad
|
||||
unsigned char *check_here;
|
||||
int thissad;
|
||||
|
||||
int *mvsadcost[2] = {x->mvsadcost[0], x->mvsadcost[1]};
|
||||
MV fcenter_mv;
|
||||
fcenter_mv.row = center_mv->row >> 3;
|
||||
fcenter_mv.col = center_mv->col >> 3;
|
||||
|
||||
*num00 = 0;
|
||||
|
||||
best_mv->row = ref_row;
|
||||
best_mv->col = ref_col;
|
||||
|
||||
// Work out the start point for the search
|
||||
in_what = (unsigned char *)(*(d->base_pre) + d->pre + (ref_row * (d->pre_stride)) + ref_col);
|
||||
best_address = in_what;
|
||||
@ -955,7 +967,7 @@ int vp8_diamond_search_sad
|
||||
(ref_row > x->mv_row_min) && (ref_row < x->mv_row_max))
|
||||
{
|
||||
// Check the starting position
|
||||
bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride, 0x7fffffff) + mv_err_cost(ref_mv, center_mv, mvsadcost, error_per_bit);
|
||||
bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride, 0x7fffffff) + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, error_per_bit);
|
||||
}
|
||||
|
||||
// search_param determines the length of the initial step and hence the number of iterations
|
||||
@ -964,8 +976,6 @@ int vp8_diamond_search_sad
|
||||
tot_steps = (x->ss_count / x->searches_per_step) - search_param;
|
||||
|
||||
i = 1;
|
||||
best_mv->row = ref_row;
|
||||
best_mv->col = ref_col;
|
||||
|
||||
for (step = 0; step < tot_steps ; step++)
|
||||
{
|
||||
@ -984,9 +994,9 @@ int vp8_diamond_search_sad
|
||||
|
||||
if (thissad < bestsad)
|
||||
{
|
||||
this_mv.row = this_row_offset << 3;
|
||||
this_mv.col = this_col_offset << 3;
|
||||
thissad += mv_err_cost(&this_mv, center_mv, mvsadcost, error_per_bit);
|
||||
this_mv.row = this_row_offset;
|
||||
this_mv.col = this_col_offset;
|
||||
thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, error_per_bit);
|
||||
|
||||
if (thissad < bestsad)
|
||||
{
|
||||
@ -1031,7 +1041,6 @@ int vp8_diamond_search_sadx4
|
||||
int error_per_bit,
|
||||
int *num00,
|
||||
vp8_variance_fn_ptr_t *fn_ptr,
|
||||
int *mvsadcost[2],
|
||||
int *mvcost[2],
|
||||
MV *center_mv
|
||||
)
|
||||
@ -1060,7 +1069,14 @@ int vp8_diamond_search_sadx4
|
||||
unsigned char *check_here;
|
||||
unsigned int thissad;
|
||||
|
||||
int *mvsadcost[2] = {x->mvsadcost[0], x->mvsadcost[1]};
|
||||
MV fcenter_mv;
|
||||
fcenter_mv.row = center_mv->row >> 3;
|
||||
fcenter_mv.col = center_mv->col >> 3;
|
||||
|
||||
*num00 = 0;
|
||||
best_mv->row = ref_row;
|
||||
best_mv->col = ref_col;
|
||||
|
||||
// Work out the start point for the search
|
||||
in_what = (unsigned char *)(*(d->base_pre) + d->pre + (ref_row * (d->pre_stride)) + ref_col);
|
||||
@ -1071,7 +1087,7 @@ int vp8_diamond_search_sadx4
|
||||
(ref_row > x->mv_row_min) && (ref_row < x->mv_row_max))
|
||||
{
|
||||
// Check the starting position
|
||||
bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride, 0x7fffffff) + mv_err_cost(ref_mv, center_mv, mvsadcost, error_per_bit);
|
||||
bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride, 0x7fffffff) + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, error_per_bit);
|
||||
}
|
||||
|
||||
// search_param determines the length of the initial step and hence the number of iterations
|
||||
@ -1080,8 +1096,6 @@ int vp8_diamond_search_sadx4
|
||||
tot_steps = (x->ss_count / x->searches_per_step) - search_param;
|
||||
|
||||
i = 1;
|
||||
best_mv->row = ref_row;
|
||||
best_mv->col = ref_col;
|
||||
|
||||
for (step = 0; step < tot_steps ; step++)
|
||||
{
|
||||
@ -1111,9 +1125,9 @@ int vp8_diamond_search_sadx4
|
||||
{
|
||||
if (sad_array[t] < bestsad)
|
||||
{
|
||||
this_mv.row = (best_mv->row + ss[i].mv.row) << 3;
|
||||
this_mv.col = (best_mv->col + ss[i].mv.col) << 3;
|
||||
sad_array[t] += mv_err_cost(&this_mv, center_mv, mvsadcost, error_per_bit);
|
||||
this_mv.row = best_mv->row + ss[i].mv.row;
|
||||
this_mv.col = best_mv->col + ss[i].mv.col;
|
||||
sad_array[t] += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, error_per_bit);
|
||||
|
||||
if (sad_array[t] < bestsad)
|
||||
{
|
||||
@ -1140,9 +1154,9 @@ int vp8_diamond_search_sadx4
|
||||
|
||||
if (thissad < bestsad)
|
||||
{
|
||||
this_mv.row = this_row_offset << 3;
|
||||
this_mv.col = this_col_offset << 3;
|
||||
thissad += mv_err_cost(&this_mv, center_mv, mvsadcost, error_per_bit);
|
||||
this_mv.row = this_row_offset;
|
||||
this_mv.col = this_col_offset;
|
||||
thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, error_per_bit);
|
||||
|
||||
if (thissad < bestsad)
|
||||
{
|
||||
@ -1178,7 +1192,7 @@ int vp8_diamond_search_sadx4
|
||||
|
||||
|
||||
#if !(CONFIG_REALTIME_ONLY)
|
||||
int vp8_full_search_sad(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int error_per_bit, int distance, vp8_variance_fn_ptr_t *fn_ptr, int *mvcost[2], int *mvsadcost[2], MV *center_mv)
|
||||
int vp8_full_search_sad(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int error_per_bit, int distance, vp8_variance_fn_ptr_t *fn_ptr, int *mvcost[2], MV *center_mv)
|
||||
{
|
||||
unsigned char *what = (*(b->base_src) + b->src);
|
||||
int what_stride = b->src_stride;
|
||||
@ -1202,6 +1216,11 @@ int vp8_full_search_sad(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int erro
|
||||
int col_min = ref_col - distance;
|
||||
int col_max = ref_col + distance;
|
||||
|
||||
int *mvsadcost[2] = {x->mvsadcost[0], x->mvsadcost[1]};
|
||||
MV fcenter_mv;
|
||||
fcenter_mv.row = center_mv->row >> 3;
|
||||
fcenter_mv.col = center_mv->col >> 3;
|
||||
|
||||
// Work out the mid point for the search
|
||||
in_what = *(d->base_pre) + d->pre;
|
||||
bestaddress = in_what + (ref_row * d->pre_stride) + ref_col;
|
||||
@ -1216,7 +1235,7 @@ int vp8_full_search_sad(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int erro
|
||||
// Baseline value at the centre
|
||||
|
||||
//bestsad = fn_ptr->sf( what,what_stride,bestaddress,in_what_stride) + (int)sqrt(mv_err_cost(ref_mv,ref_mv, mvcost,error_per_bit*14));
|
||||
bestsad = fn_ptr->sdf(what, what_stride, bestaddress, in_what_stride, 0x7fffffff) + mv_err_cost(ref_mv, center_mv, mvsadcost, error_per_bit);
|
||||
bestsad = fn_ptr->sdf(what, what_stride, bestaddress, in_what_stride, 0x7fffffff) + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, error_per_bit);
|
||||
}
|
||||
|
||||
// Apply further limits to prevent us looking using vectors that stretch beyiond the UMV border
|
||||
@ -1234,17 +1253,17 @@ int vp8_full_search_sad(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int erro
|
||||
|
||||
for (r = row_min; r < row_max ; r++)
|
||||
{
|
||||
this_mv.row = r << 3;
|
||||
this_mv.row = r;
|
||||
check_here = r * mv_stride + in_what + col_min;
|
||||
|
||||
for (c = col_min; c < col_max; c++)
|
||||
{
|
||||
thissad = fn_ptr->sdf(what, what_stride, check_here , in_what_stride, bestsad);
|
||||
|
||||
this_mv.col = c << 3;
|
||||
this_mv.col = c;
|
||||
//thissad += (int)sqrt(mv_err_cost(&this_mv,ref_mv, mvcost,error_per_bit*14));
|
||||
//thissad += error_per_bit * mv_bits_sadcost[mv_bits(&this_mv, ref_mv, mvcost)];
|
||||
thissad += mv_err_cost(&this_mv, center_mv, mvsadcost, error_per_bit); //mv_bits(error_per_bit, &this_mv, ref_mv, mvsadcost);
|
||||
thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, error_per_bit); //mv_bits(error_per_bit, &this_mv, ref_mv, mvsadcost);
|
||||
|
||||
if (thissad < bestsad)
|
||||
{
|
||||
@ -1268,7 +1287,7 @@ int vp8_full_search_sad(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int erro
|
||||
return INT_MAX;
|
||||
}
|
||||
|
||||
int vp8_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int error_per_bit, int distance, vp8_variance_fn_ptr_t *fn_ptr, int *mvcost[2], int *mvsadcost[2], MV *center_mv)
|
||||
int vp8_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int error_per_bit, int distance, vp8_variance_fn_ptr_t *fn_ptr, int *mvcost[2], MV *center_mv)
|
||||
{
|
||||
unsigned char *what = (*(b->base_src) + b->src);
|
||||
int what_stride = b->src_stride;
|
||||
@ -1294,6 +1313,11 @@ int vp8_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int er
|
||||
|
||||
unsigned int sad_array[3];
|
||||
|
||||
int *mvsadcost[2] = {x->mvsadcost[0], x->mvsadcost[1]};
|
||||
MV fcenter_mv;
|
||||
fcenter_mv.row = center_mv->row >> 3;
|
||||
fcenter_mv.col = center_mv->col >> 3;
|
||||
|
||||
// Work out the mid point for the search
|
||||
in_what = *(d->base_pre) + d->pre;
|
||||
bestaddress = in_what + (ref_row * d->pre_stride) + ref_col;
|
||||
@ -1306,7 +1330,7 @@ int vp8_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int er
|
||||
(ref_row > x->mv_row_min) && (ref_row < x->mv_row_max))
|
||||
{
|
||||
// Baseline value at the centre
|
||||
bestsad = fn_ptr->sdf(what, what_stride, bestaddress, in_what_stride, 0x7fffffff) + mv_err_cost(ref_mv, center_mv, mvsadcost, error_per_bit);
|
||||
bestsad = fn_ptr->sdf(what, what_stride, bestaddress, in_what_stride, 0x7fffffff) + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, error_per_bit);
|
||||
}
|
||||
|
||||
// Apply further limits to prevent us looking using vectors that stretch beyiond the UMV border
|
||||
@ -1324,7 +1348,7 @@ int vp8_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int er
|
||||
|
||||
for (r = row_min; r < row_max ; r++)
|
||||
{
|
||||
this_mv.row = r << 3;
|
||||
this_mv.row = r;
|
||||
check_here = r * mv_stride + in_what + col_min;
|
||||
c = col_min;
|
||||
|
||||
@ -1340,8 +1364,8 @@ int vp8_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int er
|
||||
|
||||
if (thissad < bestsad)
|
||||
{
|
||||
this_mv.col = c << 3;
|
||||
thissad += mv_err_cost(&this_mv, center_mv, mvsadcost, error_per_bit);
|
||||
this_mv.col = c;
|
||||
thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, error_per_bit);
|
||||
|
||||
if (thissad < bestsad)
|
||||
{
|
||||
@ -1363,8 +1387,8 @@ int vp8_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int er
|
||||
|
||||
if (thissad < bestsad)
|
||||
{
|
||||
this_mv.col = c << 3;
|
||||
thissad += mv_err_cost(&this_mv, center_mv, mvsadcost, error_per_bit);
|
||||
this_mv.col = c;
|
||||
thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, error_per_bit);
|
||||
|
||||
if (thissad < bestsad)
|
||||
{
|
||||
@ -1391,7 +1415,7 @@ int vp8_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int er
|
||||
return INT_MAX;
|
||||
}
|
||||
|
||||
int vp8_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int error_per_bit, int distance, vp8_variance_fn_ptr_t *fn_ptr, int *mvcost[2], int *mvsadcost[2], MV *center_mv)
|
||||
int vp8_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int error_per_bit, int distance, vp8_variance_fn_ptr_t *fn_ptr, int *mvcost[2], MV *center_mv)
|
||||
{
|
||||
unsigned char *what = (*(b->base_src) + b->src);
|
||||
int what_stride = b->src_stride;
|
||||
@ -1418,6 +1442,11 @@ int vp8_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int er
|
||||
DECLARE_ALIGNED_ARRAY(16, unsigned short, sad_array8, 8);
|
||||
unsigned int sad_array[3];
|
||||
|
||||
int *mvsadcost[2] = {x->mvsadcost[0], x->mvsadcost[1]};
|
||||
MV fcenter_mv;
|
||||
fcenter_mv.row = center_mv->row >> 3;
|
||||
fcenter_mv.col = center_mv->col >> 3;
|
||||
|
||||
// Work out the mid point for the search
|
||||
in_what = *(d->base_pre) + d->pre;
|
||||
bestaddress = in_what + (ref_row * d->pre_stride) + ref_col;
|
||||
@ -1430,7 +1459,7 @@ int vp8_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int er
|
||||
(ref_row > x->mv_row_min) && (ref_row < x->mv_row_max))
|
||||
{
|
||||
// Baseline value at the centre
|
||||
bestsad = fn_ptr->sdf(what, what_stride, bestaddress, in_what_stride, 0x7fffffff) + mv_err_cost(ref_mv, center_mv, mvsadcost, error_per_bit);
|
||||
bestsad = fn_ptr->sdf(what, what_stride, bestaddress, in_what_stride, 0x7fffffff) + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, error_per_bit);
|
||||
}
|
||||
|
||||
// Apply further limits to prevent us looking using vectors that stretch beyiond the UMV border
|
||||
@ -1448,7 +1477,7 @@ int vp8_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int er
|
||||
|
||||
for (r = row_min; r < row_max ; r++)
|
||||
{
|
||||
this_mv.row = r << 3;
|
||||
this_mv.row = r;
|
||||
check_here = r * mv_stride + in_what + col_min;
|
||||
c = col_min;
|
||||
|
||||
@ -1464,8 +1493,8 @@ int vp8_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int er
|
||||
|
||||
if (thissad < bestsad)
|
||||
{
|
||||
this_mv.col = c << 3;
|
||||
thissad += mv_err_cost(&this_mv, center_mv, mvsadcost, error_per_bit);
|
||||
this_mv.col = c;
|
||||
thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, error_per_bit);
|
||||
|
||||
if (thissad < bestsad)
|
||||
{
|
||||
@ -1493,8 +1522,8 @@ int vp8_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int er
|
||||
|
||||
if (thissad < bestsad)
|
||||
{
|
||||
this_mv.col = c << 3;
|
||||
thissad += mv_err_cost(&this_mv, center_mv, mvsadcost, error_per_bit);
|
||||
this_mv.col = c;
|
||||
thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, error_per_bit);
|
||||
|
||||
if (thissad < bestsad)
|
||||
{
|
||||
@ -1516,8 +1545,8 @@ int vp8_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int er
|
||||
|
||||
if (thissad < bestsad)
|
||||
{
|
||||
this_mv.col = c << 3;
|
||||
thissad += mv_err_cost(&this_mv, center_mv, mvsadcost, error_per_bit);
|
||||
this_mv.col = c;
|
||||
thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, error_per_bit);
|
||||
|
||||
if (thissad < bestsad)
|
||||
{
|
||||
|
@ -66,7 +66,6 @@ extern fractional_mv_step_fp vp8_skip_fractional_mv_step;
|
||||
int distance, \
|
||||
vp8_variance_fn_ptr_t *fn_ptr, \
|
||||
int *mvcost[2], \
|
||||
int *mvsadcost[2], \
|
||||
MV *center_mv \
|
||||
)
|
||||
|
||||
@ -82,7 +81,6 @@ extern fractional_mv_step_fp vp8_skip_fractional_mv_step;
|
||||
int error_per_bit, \
|
||||
int *num00, \
|
||||
vp8_variance_fn_ptr_t *fn_ptr, \
|
||||
int *mvsadcost[2], \
|
||||
int *mvcost[2], \
|
||||
MV *center_mv \
|
||||
)
|
||||
|
@ -1797,13 +1797,13 @@ static void cal_mvsadcosts(int *mvsadcost[2])
|
||||
|
||||
do
|
||||
{
|
||||
double z = 256 * (2 * (log2f(2 * i) + .6));
|
||||
double z = 256 * (2 * (log2f(8 * i) + .6));
|
||||
mvsadcost [0][i] = (int) z;
|
||||
mvsadcost [1][i] = (int) z;
|
||||
mvsadcost [0][-i] = (int) z;
|
||||
mvsadcost [1][-i] = (int) z;
|
||||
}
|
||||
while (++i <= mv_max);
|
||||
while (++i <= mvfp_max);
|
||||
}
|
||||
|
||||
VP8_PTR vp8_create_compressor(VP8_CONFIG *oxcf)
|
||||
@ -2000,8 +2000,8 @@ VP8_PTR vp8_create_compressor(VP8_CONFIG *oxcf)
|
||||
|
||||
cpi->mb.mvcost[0] = &cpi->mb.mvcosts[0][mv_max+1];
|
||||
cpi->mb.mvcost[1] = &cpi->mb.mvcosts[1][mv_max+1];
|
||||
cpi->mb.mvsadcost[0] = &cpi->mb.mvsadcosts[0][mv_max+1];
|
||||
cpi->mb.mvsadcost[1] = &cpi->mb.mvsadcosts[1][mv_max+1];
|
||||
cpi->mb.mvsadcost[0] = &cpi->mb.mvsadcosts[0][mvfp_max+1];
|
||||
cpi->mb.mvsadcost[1] = &cpi->mb.mvsadcosts[1][mvfp_max+1];
|
||||
|
||||
cal_mvsadcosts(cpi->mb.mvsadcost);
|
||||
|
||||
|
@ -738,7 +738,7 @@ int vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int rec
|
||||
}
|
||||
else
|
||||
{
|
||||
bestsme = cpi->diamond_search_sad(x, b, d, &mvp, &d->bmi.mv.as_mv, step_param, sadpb / 2/*x->errorperbit*/, &num00, &cpi->fn_ptr[BLOCK_16X16], x->mvsadcost, x->mvcost, &best_ref_mv); //sadpb < 9
|
||||
bestsme = cpi->diamond_search_sad(x, b, d, &mvp, &d->bmi.mv.as_mv, step_param, sadpb / 2/*x->errorperbit*/, &num00, &cpi->fn_ptr[BLOCK_16X16], x->mvcost, &best_ref_mv); //sadpb < 9
|
||||
mode_mv[NEWMV].row = d->bmi.mv.as_mv.row;
|
||||
mode_mv[NEWMV].col = d->bmi.mv.as_mv.col;
|
||||
|
||||
@ -757,7 +757,7 @@ int vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int rec
|
||||
num00--;
|
||||
else
|
||||
{
|
||||
thissme = cpi->diamond_search_sad(x, b, d, &mvp, &d->bmi.mv.as_mv, step_param + n, sadpb / 4/*x->errorperbit*/, &num00, &cpi->fn_ptr[BLOCK_16X16], x->mvsadcost, x->mvcost, &best_ref_mv); //sadpb = 9
|
||||
thissme = cpi->diamond_search_sad(x, b, d, &mvp, &d->bmi.mv.as_mv, step_param + n, sadpb / 4/*x->errorperbit*/, &num00, &cpi->fn_ptr[BLOCK_16X16], x->mvcost, &best_ref_mv); //sadpb = 9
|
||||
|
||||
if (thissme < bestsme)
|
||||
{
|
||||
|
@ -310,7 +310,7 @@ void vp8_setup_key_frame(VP8_COMP *cpi)
|
||||
vpx_memcpy(cpi->common.fc.mvc, vp8_default_mv_context, sizeof(vp8_default_mv_context));
|
||||
{
|
||||
int flag[2] = {1, 1};
|
||||
vp8_build_component_cost_table(cpi->mb.mvcost, cpi->mb.mvsadcost, (const MV_CONTEXT *) cpi->common.fc.mvc, flag);
|
||||
vp8_build_component_cost_table(cpi->mb.mvcost, (const MV_CONTEXT *) cpi->common.fc.mvc, flag);
|
||||
}
|
||||
|
||||
vpx_memset(cpi->common.fc.pre_mvc, 0, sizeof(cpi->common.fc.pre_mvc)); //initialize pre_mvc to all zero.
|
||||
|
@ -1159,7 +1159,7 @@ static void rd_check_segment(VP8_COMP *cpi, MACROBLOCK *x,
|
||||
{
|
||||
bestsme = cpi->diamond_search_sad(x, c, e, bsi->mvp,
|
||||
&mode_mv[NEW4X4], step_param,
|
||||
sadpb / 2, &num00, v_fn_ptr, x->mvsadcost, x->mvcost, bsi->ref_mv);
|
||||
sadpb / 2, &num00, v_fn_ptr, x->mvcost, bsi->ref_mv);
|
||||
|
||||
n = num00;
|
||||
num00 = 0;
|
||||
@ -1174,7 +1174,7 @@ static void rd_check_segment(VP8_COMP *cpi, MACROBLOCK *x,
|
||||
{
|
||||
thissme = cpi->diamond_search_sad(x, c, e, bsi->mvp,
|
||||
&temp_mv, step_param + n,
|
||||
sadpb / 2, &num00, v_fn_ptr, x->mvsadcost, x->mvcost, bsi->ref_mv);
|
||||
sadpb / 2, &num00, v_fn_ptr, x->mvcost, bsi->ref_mv);
|
||||
|
||||
if (thissme < bestsme)
|
||||
{
|
||||
@ -1192,7 +1192,7 @@ static void rd_check_segment(VP8_COMP *cpi, MACROBLOCK *x,
|
||||
if ((cpi->compressor_speed == 0) && (bestsme >> sseshift) > 4000)
|
||||
{
|
||||
thissme = cpi->full_search_sad(x, c, e, bsi->mvp,
|
||||
sadpb / 4, 16, v_fn_ptr, x->mvcost, x->mvsadcost,bsi->ref_mv);
|
||||
sadpb / 4, 16, v_fn_ptr, x->mvcost, bsi->ref_mv);
|
||||
|
||||
if (thissme < bestsme)
|
||||
{
|
||||
@ -2102,7 +2102,7 @@ int vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
|
||||
}
|
||||
else
|
||||
{
|
||||
bestsme = cpi->diamond_search_sad(x, b, d, &mvp, &d->bmi.mv.as_mv, step_param, sadpb / 2/*x->errorperbit*/, &num00, &cpi->fn_ptr[BLOCK_16X16], x->mvsadcost, x->mvcost, &best_ref_mv); //sadpb < 9
|
||||
bestsme = cpi->diamond_search_sad(x, b, d, &mvp, &d->bmi.mv.as_mv, step_param, sadpb / 2/*x->errorperbit*/, &num00, &cpi->fn_ptr[BLOCK_16X16], x->mvcost, &best_ref_mv); //sadpb < 9
|
||||
mode_mv[NEWMV].row = d->bmi.mv.as_mv.row;
|
||||
mode_mv[NEWMV].col = d->bmi.mv.as_mv.col;
|
||||
|
||||
@ -2121,7 +2121,7 @@ int vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
|
||||
num00--;
|
||||
else
|
||||
{
|
||||
thissme = cpi->diamond_search_sad(x, b, d, &mvp, &d->bmi.mv.as_mv, step_param + n, sadpb / 4/*x->errorperbit*/, &num00, &cpi->fn_ptr[BLOCK_16X16], x->mvsadcost, x->mvcost, &best_ref_mv); //sadpb = 9
|
||||
thissme = cpi->diamond_search_sad(x, b, d, &mvp, &d->bmi.mv.as_mv, step_param + n, sadpb / 4/*x->errorperbit*/, &num00, &cpi->fn_ptr[BLOCK_16X16], x->mvcost, &best_ref_mv); //sadpb = 9
|
||||
|
||||
if (thissme < bestsme)
|
||||
{
|
||||
@ -2167,7 +2167,7 @@ int vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
|
||||
|
||||
{
|
||||
int sadpb = x->sadperbit16 >> 2;
|
||||
thissme = cpi->full_search_sad(x, b, d, &full_mvp, sadpb, search_range, &cpi->fn_ptr[BLOCK_16X16], x->mvcost, x->mvsadcost,&best_ref_mv);
|
||||
thissme = cpi->full_search_sad(x, b, d, &full_mvp, sadpb, search_range, &cpi->fn_ptr[BLOCK_16X16], x->mvcost, &best_ref_mv);
|
||||
}
|
||||
|
||||
// Barrier threshold to initiating full search
|
||||
|
@ -195,63 +195,14 @@ static int vp8_temporal_filter_find_matching_mb_c
|
||||
further_steps = 0;
|
||||
}
|
||||
|
||||
if (1/*cpi->sf.search_method == HEX*/)
|
||||
{
|
||||
// TODO Check that the 16x16 vf & sdf are selected here
|
||||
bestsme = vp8_hex_search(x, b, d,
|
||||
&best_ref_mv1, &d->bmi.mv.as_mv,
|
||||
step_param,
|
||||
sadpb/*x->errorperbit*/,
|
||||
&num00, &cpi->fn_ptr[BLOCK_16X16],
|
||||
mvsadcost, mvcost, &best_ref_mv1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int mv_x, mv_y;
|
||||
|
||||
bestsme = cpi->diamond_search_sad(x, b, d,
|
||||
&best_ref_mv1, &d->bmi.mv.as_mv,
|
||||
step_param,
|
||||
sadpb / 2/*x->errorperbit*/,
|
||||
&num00, &cpi->fn_ptr[BLOCK_16X16],
|
||||
mvsadcost, mvcost, &best_ref_mv1); //sadpb < 9
|
||||
|
||||
// Further step/diamond searches as necessary
|
||||
n = 0;
|
||||
//further_steps = (cpi->sf.max_step_search_steps - 1) - step_param;
|
||||
|
||||
n = num00;
|
||||
num00 = 0;
|
||||
|
||||
while (n < further_steps)
|
||||
{
|
||||
n++;
|
||||
|
||||
if (num00)
|
||||
num00--;
|
||||
else
|
||||
{
|
||||
thissme = cpi->diamond_search_sad(x, b, d,
|
||||
&best_ref_mv1, &d->bmi.mv.as_mv,
|
||||
step_param + n,
|
||||
sadpb / 4/*x->errorperbit*/,
|
||||
&num00, &cpi->fn_ptr[BLOCK_16X16],
|
||||
mvsadcost, mvcost, &best_ref_mv1); //sadpb = 9
|
||||
|
||||
if (thissme < bestsme)
|
||||
{
|
||||
bestsme = thissme;
|
||||
mv_y = d->bmi.mv.as_mv.row;
|
||||
mv_x = d->bmi.mv.as_mv.col;
|
||||
}
|
||||
else
|
||||
{
|
||||
d->bmi.mv.as_mv.row = mv_y;
|
||||
d->bmi.mv.as_mv.col = mv_x;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*cpi->sf.search_method == HEX*/
|
||||
// TODO Check that the 16x16 vf & sdf are selected here
|
||||
bestsme = vp8_hex_search(x, b, d,
|
||||
&best_ref_mv1, &d->bmi.mv.as_mv,
|
||||
step_param,
|
||||
sadpb/*x->errorperbit*/,
|
||||
&num00, &cpi->fn_ptr[BLOCK_16X16],
|
||||
mvsadcost, mvcost, &best_ref_mv1);
|
||||
|
||||
#if ALT_REF_SUBPEL_ENABLED
|
||||
// Try sub-pixel MC?
|
||||
|
Loading…
x
Reference in New Issue
Block a user