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) ...@@ -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 #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) 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)] + // Ignore costing if mvcost is NULL
mvcost[1][(mv->as_mv.col - ref->as_mv.col) >> (ishp==0)]) if (mvcost)
* error_per_bit + 128) >> 8; 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 #else
static int mv_err_cost(int_mv *mv, int_mv *ref, int *mvcost[2], int error_per_bit) 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] + // Ignore costing if mvcost is NULL
mvcost[1][(mv->as_mv.col - ref->as_mv.col) >> 1]) if (mvcost)
* error_per_bit + 128) >> 8; 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 #endif
static int mvsad_err_cost(int_mv *mv, int_mv *ref, int *mvsadcost[2], int error_per_bit) 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. */ // Calculate sad error cost on full pixel basis.
return ((mvsadcost[0][(mv->as_mv.row - ref->as_mv.row)] + // Ignore costing if mvcost is NULL
mvsadcost[1][(mv->as_mv.col - ref->as_mv.col)]) if (mvsadcost)
* error_per_bit + 128) >> 8; 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) ...@@ -204,7 +213,7 @@ void vp8_init3smotion_compensation(MACROBLOCK *x, int stride)
#else #else
#define SP(x) (((x)&3)<<1) // convert motion vector component to offset for svf calc #define SP(x) (((x)&3)<<1) // convert motion vector component to offset for svf calc
#endif /* CONFIG_SIXTEENTH_SUBPEL_UV */ #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 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 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; #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 ...@@ -154,10 +154,6 @@ void vp8_temporal_filter_apply_c
} }
#if ALT_REF_MC_ENABLED #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 static int vp8_temporal_filter_find_matching_mb_c
( (
...@@ -179,13 +175,6 @@ 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;
int_mv best_ref_mv1_full; /* full-pixel value of 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 // Save input state
unsigned char **base_src = b->base_src; unsigned char **base_src = b->base_src;
int src = b->src; int src = b->src;
...@@ -223,18 +212,10 @@ static int vp8_temporal_filter_find_matching_mb_c ...@@ -223,18 +212,10 @@ static int vp8_temporal_filter_find_matching_mb_c
/*cpi->sf.search_method == HEX*/ /*cpi->sf.search_method == HEX*/
// TODO Check that the 16x16 vf & sdf are selected here // TODO Check that the 16x16 vf & sdf are selected here
bestsme = vp8_hex_search(x, b, d, // Ignore mv costing by sending NULL pointer instead of cost arrays
&best_ref_mv1_full, &d->bmi.as_mv.first, bestsme = vp8_hex_search(x, b, d, &best_ref_mv1_full, &d->bmi.as_mv.first,
step_param, step_param, sadpb, &cpi->fn_ptr[BLOCK_16X16],
sadpb, NULL, NULL, &best_ref_mv1);
&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);
#if ALT_REF_SUBPEL_ENABLED #if ALT_REF_SUBPEL_ENABLED
// Try sub-pixel MC? // Try sub-pixel MC?
...@@ -242,15 +223,12 @@ static int vp8_temporal_filter_find_matching_mb_c ...@@ -242,15 +223,12 @@ static int vp8_temporal_filter_find_matching_mb_c
{ {
int distortion; int distortion;
unsigned int sse; unsigned int sse;
bestsme = cpi->find_fractional_mv_step(x, b, d, // Ignore mv costing by sending NULL pointer instead of cost array
&d->bmi.as_mv.first, &best_ref_mv1, bestsme = cpi->find_fractional_mv_step(x, b, d, &d->bmi.as_mv.first,
x->errorperbit, &cpi->fn_ptr[BLOCK_16X16], &best_ref_mv1,
#if CONFIG_HIGH_PRECISION_MV x->errorperbit,
x->e_mbd.allow_high_precision_mv?mvcost_hp:mvcost, &cpi->fn_ptr[BLOCK_16X16],
#else NULL, &distortion, &sse);
mvcost,
#endif
&distortion, &sse);
} }
#endif #endif
...@@ -328,32 +306,37 @@ static void vp8_temporal_filter_iterate_c ...@@ -328,32 +306,37 @@ static void vp8_temporal_filter_iterate_c
for (frame = 0; frame < frame_count; frame++) for (frame = 0; frame < frame_count; frame++)
{ {
int err = 0;
if (cpi->frames[frame] == NULL) if (cpi->frames[frame] == NULL)
continue; continue;
mbd->block[0].bmi.as_mv.first.as_mv.row = 0; mbd->block[0].bmi.as_mv.first.as_mv.row = 0;
mbd->block[0].bmi.as_mv.first.as_mv.col = 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 #if ALT_REF_MC_ENABLED
#define THRESH_LOW 10000 #define THRESH_LOW 10000
#define THRESH_HIGH 20000 #define THRESH_HIGH 20000
// Find best match in this frame by MC // Find best match in this frame by MC
err = vp8_temporal_filter_find_matching_mb_c err = vp8_temporal_filter_find_matching_mb_c
(cpi, (cpi,
cpi->frames[alt_ref_index], cpi->frames[alt_ref_index],
cpi->frames[frame], cpi->frames[frame],
mb_y_offset, mb_y_offset,
THRESH_LOW); THRESH_LOW);
#endif #endif
// Assign higher weight to matching MB if it's error // Assign higher weight to matching MB if it's error
// score is lower. If not applying MC default behavior // score is lower. If not applying MC default behavior
// is to weight all MBs equal. // is to weight all MBs equal.
filter_weight = err<THRESH_LOW filter_weight = err<THRESH_LOW
? 2 : err<THRESH_HIGH ? 1 : 0; ? 2 : err<THRESH_HIGH ? 1 : 0;
}
if (filter_weight != 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