Commit 393440db authored by Adrian Grange's avatar Adrian Grange
Browse files

Removed MV costing from ARNR filtering

The ARNR filter uses a motion compensated temporal filter,
but the motion estimation implementation accounts for the
cost of the mv in its decision making process. The ARNR
filter uses a dummy cost table initialized to 0 as a way
to ignore the mv costs (which are irrelevant to the filter).

This CL modifies the ARNR filter implementation to so that
the mv costing is ignored without the requirement for
dummy tables.

Change-Id: I0dd9620c3b70682f938b2a70912c11d4d7c9284c
parent a16608ab
......@@ -45,26 +45,35 @@ int vp8_mv_bit_cost(int_mv *mv, int_mv *ref, int *mvcost[2], int Weight)
#if CONFIG_HIGH_PRECISION_MV
static int mv_err_cost(int_mv *mv, int_mv *ref, int *mvcost[2], int error_per_bit, int ishp)
{
return ((mvcost[0][(mv->as_mv.row - ref->as_mv.row) >> (ishp==0)] +
mvcost[1][(mv->as_mv.col - ref->as_mv.col) >> (ishp==0)])
* error_per_bit + 128) >> 8;
// Ignore costing if mvcost is NULL
if (mvcost)
return ((mvcost[0][(mv->as_mv.row - ref->as_mv.row) >> (ishp==0)] +
mvcost[1][(mv->as_mv.col - ref->as_mv.col) >> (ishp==0)])
* error_per_bit + 128) >> 8;
return 0;
}
#else
static int mv_err_cost(int_mv *mv, int_mv *ref, int *mvcost[2], int error_per_bit)
{
return ((mvcost[0][(mv->as_mv.row - ref->as_mv.row) >> 1] +
mvcost[1][(mv->as_mv.col - ref->as_mv.col) >> 1])
* error_per_bit + 128) >> 8;
// Ignore costing if mvcost is NULL
if (mvcost)
return ((mvcost[0][(mv->as_mv.row - ref->as_mv.row) >> 1] +
mvcost[1][(mv->as_mv.col - ref->as_mv.col) >> 1])
* error_per_bit + 128) >> 8;
return 0;
}
#endif
static int mvsad_err_cost(int_mv *mv, int_mv *ref, int *mvsadcost[2], int error_per_bit)
{
/* Calculate sad error cost on full pixel basis. */
return ((mvsadcost[0][(mv->as_mv.row - ref->as_mv.row)] +
mvsadcost[1][(mv->as_mv.col - ref->as_mv.col)])
* error_per_bit + 128) >> 8;
// Calculate sad error cost on full pixel basis.
// Ignore costing if mvcost is NULL
if (mvsadcost)
return ((mvsadcost[0][(mv->as_mv.row - ref->as_mv.row)] +
mvsadcost[1][(mv->as_mv.col - ref->as_mv.col)])
* error_per_bit + 128) >> 8;
return 0;
}
......@@ -204,7 +213,7 @@ void vp8_init3smotion_compensation(MACROBLOCK *x, int stride)
#else
#define SP(x) (((x)&3)<<1) // convert motion vector component to offset for svf calc
#endif /* CONFIG_SIXTEENTH_SUBPEL_UV */
#define MVC(r,c) (((mvcost[0][(r)-rr] + mvcost[1][(c)-rc]) * error_per_bit + 128 )>>8 ) // estimated cost of a motion vector (r,c)
#define MVC(r,c) (mvcost ? ((mvcost[0][(r)-rr] + mvcost[1][(c)-rc]) * error_per_bit + 128 )>>8 : 0) // estimated cost of a motion vector (r,c)
#define DIST(r,c) vfp->svf( PRE(r,c), y_stride, SP(c),SP(r), z,b->src_stride,&sse) // returns subpixel variance error function.
#define ERR(r,c) (MVC(r,c)+DIST(r,c)) // returns distortion + motion vector cost
#define IFMVCV(r,c,s,e) if ( c >= minc && c <= maxc && r >= minr && r <= maxr) s else e;
......
......@@ -154,10 +154,6 @@ void vp8_temporal_filter_apply_c
}
#if ALT_REF_MC_ENABLED
static int dummy_cost[2*mv_max+1];
#if CONFIG_HIGH_PRECISION_MV
static int dummy_cost_hp[2*mv_max_hp+1];
#endif
static int vp8_temporal_filter_find_matching_mb_c
(
......@@ -179,13 +175,6 @@ static int vp8_temporal_filter_find_matching_mb_c
int_mv best_ref_mv1;
int_mv best_ref_mv1_full; /* full-pixel value of best_ref_mv1 */
int *mvcost[2] = { &dummy_cost[mv_max+1], &dummy_cost[mv_max+1] };
int *mvsadcost[2] = { &dummy_cost[mv_max+1], &dummy_cost[mv_max+1] };
#if CONFIG_HIGH_PRECISION_MV
int *mvcost_hp[2] = { &dummy_cost_hp[mv_max_hp+1], &dummy_cost_hp[mv_max_hp+1] };
int *mvsadcost_hp[2] = { &dummy_cost_hp[mv_max_hp+1], &dummy_cost_hp[mv_max_hp+1] };
#endif
// Save input state
unsigned char **base_src = b->base_src;
int src = b->src;
......@@ -223,18 +212,10 @@ static int vp8_temporal_filter_find_matching_mb_c
/*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_full, &d->bmi.as_mv.first,
step_param,
sadpb,
&cpi->fn_ptr[BLOCK_16X16],
#if CONFIG_HIGH_PRECISION_MV
x->e_mbd.allow_high_precision_mv?mvsadcost_hp:mvsadcost,
x->e_mbd.allow_high_precision_mv?mvcost_hp:mvcost,
#else
mvsadcost, mvcost,
#endif
&best_ref_mv1);
// Ignore mv costing by sending NULL pointer instead of cost arrays
bestsme = vp8_hex_search(x, b, d, &best_ref_mv1_full, &d->bmi.as_mv.first,
step_param, sadpb, &cpi->fn_ptr[BLOCK_16X16],
NULL, NULL, &best_ref_mv1);
#if ALT_REF_SUBPEL_ENABLED
// Try sub-pixel MC?
......@@ -242,15 +223,12 @@ static int vp8_temporal_filter_find_matching_mb_c
{
int distortion;
unsigned int sse;
bestsme = cpi->find_fractional_mv_step(x, b, d,
&d->bmi.as_mv.first, &best_ref_mv1,
x->errorperbit, &cpi->fn_ptr[BLOCK_16X16],
#if CONFIG_HIGH_PRECISION_MV
x->e_mbd.allow_high_precision_mv?mvcost_hp:mvcost,
#else
mvcost,
#endif
&distortion, &sse);
// Ignore mv costing by sending NULL pointer instead of cost array
bestsme = cpi->find_fractional_mv_step(x, b, d, &d->bmi.as_mv.first,
&best_ref_mv1,
x->errorperbit,
&cpi->fn_ptr[BLOCK_16X16],
NULL, &distortion, &sse);
}
#endif
......@@ -328,32 +306,37 @@ static void vp8_temporal_filter_iterate_c
for (frame = 0; frame < frame_count; frame++)
{
int err = 0;
if (cpi->frames[frame] == NULL)
continue;
mbd->block[0].bmi.as_mv.first.as_mv.row = 0;
mbd->block[0].bmi.as_mv.first.as_mv.col = 0;
if (frame == alt_ref_index)
{
filter_weight = 2;
}
else
{
int err = 0;
#if ALT_REF_MC_ENABLED
#define THRESH_LOW 10000
#define THRESH_HIGH 20000
// Find best match in this frame by MC
err = vp8_temporal_filter_find_matching_mb_c
(cpi,
cpi->frames[alt_ref_index],
cpi->frames[frame],
mb_y_offset,
THRESH_LOW);
// Find best match in this frame by MC
err = vp8_temporal_filter_find_matching_mb_c
(cpi,
cpi->frames[alt_ref_index],
cpi->frames[frame],
mb_y_offset,
THRESH_LOW);
#endif
// Assign higher weight to matching MB if it's error
// score is lower. If not applying MC default behavior
// is to weight all MBs equal.
filter_weight = err<THRESH_LOW
? 2 : err<THRESH_HIGH ? 1 : 0;
// Assign higher weight to matching MB if it's error
// score is lower. If not applying MC default behavior
// is to weight all MBs equal.
filter_weight = err<THRESH_LOW
? 2 : err<THRESH_HIGH ? 1 : 0;
}
if (filter_weight != 0)
{
......
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