further clean up of errorperbit and sadperbit
this commit makes the usage errorperbit and sadperbit consistent for encoding modes and passes. Removed all different magic weight factors associated with errorperbit. Now 1/2 is used for both sadperbit16 and sadperbit4, the /2 operation is merged into initializations of the 2 variables. Tests on cif set show .23%, 0.18% and 0.19% gain by avg psnr, overall psnr and ssim respectively. Change-Id: Ifa285c3e065ce0a5a77addfc9f95aabf54ee270d
This commit is contained in:
@@ -449,7 +449,9 @@ static void first_pass_motion_search(VP8_COMP *cpi, MACROBLOCK *x,
|
|||||||
|
|
||||||
// Initial step/diamond search centred on best mv
|
// Initial step/diamond search centred on best mv
|
||||||
tmp_mv.as_int = 0;
|
tmp_mv.as_int = 0;
|
||||||
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);
|
tmp_err = cpi->diamond_search_sad(x, b, d, ref_mv, &tmp_mv, step_param,
|
||||||
|
x->sadperbit16, &num00, &v_fn_ptr,
|
||||||
|
x->mvcost, ref_mv);
|
||||||
if ( tmp_err < INT_MAX-new_mv_mode_penalty )
|
if ( tmp_err < INT_MAX-new_mv_mode_penalty )
|
||||||
tmp_err += new_mv_mode_penalty;
|
tmp_err += new_mv_mode_penalty;
|
||||||
|
|
||||||
@@ -472,7 +474,10 @@ static void first_pass_motion_search(VP8_COMP *cpi, MACROBLOCK *x,
|
|||||||
num00--;
|
num00--;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
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);
|
tmp_err = cpi->diamond_search_sad(x, b, d, ref_mv, &tmp_mv,
|
||||||
|
step_param + n, x->sadperbit16,
|
||||||
|
&num00, &v_fn_ptr, x->mvcost,
|
||||||
|
ref_mv);
|
||||||
if ( tmp_err < INT_MAX-new_mv_mode_penalty )
|
if ( tmp_err < INT_MAX-new_mv_mode_penalty )
|
||||||
tmp_err += new_mv_mode_penalty;
|
tmp_err += new_mv_mode_penalty;
|
||||||
|
|
||||||
|
|||||||
@@ -1000,7 +1000,8 @@ cal_neighbors:
|
|||||||
this_mv.as_mv.col = bc<<3;
|
this_mv.as_mv.col = bc<<3;
|
||||||
|
|
||||||
this_offset = (unsigned char *)(*(d->base_pre) + d->pre + (br * (in_what_stride)) + bc);
|
this_offset = (unsigned char *)(*(d->base_pre) + d->pre + (br * (in_what_stride)) + bc);
|
||||||
return vfp->vf(what, what_stride, this_offset, in_what_stride, &bestsad) + mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit) ;
|
return vfp->vf(what, what_stride, this_offset, in_what_stride, &bestsad)
|
||||||
|
+ mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit) ;
|
||||||
}
|
}
|
||||||
#undef CHECK_BOUNDS
|
#undef CHECK_BOUNDS
|
||||||
#undef CHECK_POINT
|
#undef CHECK_POINT
|
||||||
|
|||||||
@@ -713,7 +713,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
|
|||||||
int step_param;
|
int step_param;
|
||||||
int further_steps;
|
int further_steps;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int sadpb = x->sadperbit16/2;
|
int sadpb = x->sadperbit16;
|
||||||
|
|
||||||
int col_min;
|
int col_min;
|
||||||
int col_max;
|
int col_max;
|
||||||
@@ -817,7 +817,11 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bestsme < INT_MAX)
|
if (bestsme < INT_MAX)
|
||||||
cpi->find_fractional_mv_step(x, b, d, &d->bmi.mv, &best_ref_mv, x->errorperbit, &cpi->fn_ptr[BLOCK_16X16], cpi->mb.mvcost, &distortion2, &sse);
|
cpi->find_fractional_mv_step(x, b, d, &d->bmi.mv, &best_ref_mv,
|
||||||
|
x->errorperbit,
|
||||||
|
&cpi->fn_ptr[BLOCK_16X16],
|
||||||
|
cpi->mb.mvcost,
|
||||||
|
&distortion2,&sse);
|
||||||
|
|
||||||
mode_mv[NEWMV].as_int = d->bmi.mv.as_int;
|
mode_mv[NEWMV].as_int = d->bmi.mv.as_int;
|
||||||
|
|
||||||
|
|||||||
@@ -198,8 +198,8 @@ static int sad_per_bit4lut[QINDEX_RANGE] =
|
|||||||
|
|
||||||
void vp8cx_initialize_me_consts(VP8_COMP *cpi, int QIndex)
|
void vp8cx_initialize_me_consts(VP8_COMP *cpi, int QIndex)
|
||||||
{
|
{
|
||||||
cpi->mb.sadperbit16 = sad_per_bit16lut[QIndex];
|
cpi->mb.sadperbit16 = sad_per_bit16lut[QIndex]/2;
|
||||||
cpi->mb.sadperbit4 = sad_per_bit4lut[QIndex];
|
cpi->mb.sadperbit4 = sad_per_bit4lut[QIndex]/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vp8_initialize_rd_consts(VP8_COMP *cpi, int Qvalue)
|
void vp8_initialize_rd_consts(VP8_COMP *cpi, int Qvalue)
|
||||||
@@ -1131,7 +1131,7 @@ static void rd_check_segment(VP8_COMP *cpi, MACROBLOCK *x,
|
|||||||
further_steps = (MAX_MVSEARCH_STEPS - 1) - step_param;
|
further_steps = (MAX_MVSEARCH_STEPS - 1) - step_param;
|
||||||
|
|
||||||
{
|
{
|
||||||
int sadpb = x->sadperbit4/2;
|
int sadpb = x->sadperbit4;
|
||||||
|
|
||||||
// find first label
|
// find first label
|
||||||
n = vp8_mbsplit_offset[segmentation][i];
|
n = vp8_mbsplit_offset[segmentation][i];
|
||||||
@@ -1202,13 +1202,10 @@ static void rd_check_segment(VP8_COMP *cpi, MACROBLOCK *x,
|
|||||||
{
|
{
|
||||||
int distortion;
|
int distortion;
|
||||||
unsigned int sse;
|
unsigned int sse;
|
||||||
|
|
||||||
if (!cpi->common.full_pixel)
|
|
||||||
cpi->find_fractional_mv_step(x, c, e, &mode_mv[NEW4X4],
|
cpi->find_fractional_mv_step(x, c, e, &mode_mv[NEW4X4],
|
||||||
bsi->ref_mv, x->errorperbit / 2, v_fn_ptr, x->mvcost, &distortion, &sse);
|
bsi->ref_mv, x->errorperbit, v_fn_ptr, x->mvcost,
|
||||||
else
|
&distortion, &sse);
|
||||||
vp8_skip_fractional_mv_step(x, c, e, &mode_mv[NEW4X4],
|
|
||||||
bsi->ref_mv, x->errorperbit, v_fn_ptr, x->mvcost, &distortion, &sse);
|
|
||||||
}
|
}
|
||||||
} /* NEW4X4 */
|
} /* NEW4X4 */
|
||||||
|
|
||||||
@@ -2038,7 +2035,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
|
|||||||
int do_refine=1; /* If last step (1-away) of n-step search doesn't pick the center point as the best match,
|
int do_refine=1; /* If last step (1-away) of n-step search doesn't pick the center point as the best match,
|
||||||
we will do a final 1-away diamond refining search */
|
we will do a final 1-away diamond refining search */
|
||||||
|
|
||||||
int sadpb = x->sadperbit16/2;
|
int sadpb = x->sadperbit16;
|
||||||
|
|
||||||
int col_min = (best_ref_mv.as_mv.col - MAX_FULL_PEL_VAL) >>3;
|
int col_min = (best_ref_mv.as_mv.col - MAX_FULL_PEL_VAL) >>3;
|
||||||
int col_max = (best_ref_mv.as_mv.col + MAX_FULL_PEL_VAL) >>3;
|
int col_max = (best_ref_mv.as_mv.col + MAX_FULL_PEL_VAL) >>3;
|
||||||
@@ -2147,7 +2144,10 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
|
|||||||
{
|
{
|
||||||
int dis; /* TODO: use dis in distortion calculation later. */
|
int dis; /* TODO: use dis in distortion calculation later. */
|
||||||
unsigned int sse;
|
unsigned int sse;
|
||||||
cpi->find_fractional_mv_step(x, b, d, &d->bmi.mv, &best_ref_mv, x->errorperbit / 4, &cpi->fn_ptr[BLOCK_16X16], x->mvcost, &dis, &sse);
|
cpi->find_fractional_mv_step(x, b, d, &d->bmi.mv, &best_ref_mv,
|
||||||
|
x->errorperbit,
|
||||||
|
&cpi->fn_ptr[BLOCK_16X16],
|
||||||
|
x->mvcost, &dis, &sse);
|
||||||
}
|
}
|
||||||
|
|
||||||
mode_mv[NEWMV].as_int = d->bmi.mv.as_int;
|
mode_mv[NEWMV].as_int = d->bmi.mv.as_int;
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ static int vp8_temporal_filter_find_matching_mb_c
|
|||||||
bestsme = vp8_hex_search(x, b, d,
|
bestsme = vp8_hex_search(x, b, d,
|
||||||
&best_ref_mv1, &d->bmi.mv,
|
&best_ref_mv1, &d->bmi.mv,
|
||||||
step_param,
|
step_param,
|
||||||
sadpb/*x->errorperbit*/,
|
sadpb,
|
||||||
&num00, &cpi->fn_ptr[BLOCK_16X16],
|
&num00, &cpi->fn_ptr[BLOCK_16X16],
|
||||||
mvsadcost, mvcost, &best_ref_mv1);
|
mvsadcost, mvcost, &best_ref_mv1);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user