ref: 393440db89fbc5718d6005285a1a7229ccddaec9
parent: a16608aba040957e269ec1e7905c72140cb721b6
author: Adrian Grange <agrange@google.com>
date: Thu Apr 26 06:37:52 EDT 2012
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
--- a/vp8/encoder/mcomp.c
+++ b/vp8/encoder/mcomp.c
@@ -45,16 +45,22 @@
#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
@@ -61,10 +67,13 @@
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 @@
#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;
--- a/vp8/encoder/temporal_filter.c
+++ b/vp8/encoder/temporal_filter.c
@@ -154,10 +154,6 @@
}
#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 @@
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 @@
/*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 @@
{
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,8 +306,6 @@
for (frame = 0; frame < frame_count; frame++)
{
- int err = 0;
-
if (cpi->frames[frame] == NULL)
continue;
@@ -336,24 +312,31 @@
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)
{
--
⑨