Use variance metric for integral projection vector match This commit replaces the SAD with variance as metric for the integral projection vector match. It improves the search accuracy in the presence of slight light change. The average speed -6 compression performance for rtc set is improved by 1.7%. No speed changes are observed for the test clips. Change-Id: I71c1d27e42de2aa429fb3564e6549bba1c7d6d4d
diff --git a/vp9/encoder/vp9_avg.c b/vp9/encoder/vp9_avg.c index 8d6cf06..50c8bca 100644 --- a/vp9/encoder/vp9_avg.c +++ b/vp9/encoder/vp9_avg.c
@@ -37,6 +37,7 @@ hbuf[idx] = 0; for (i = 0; i < height; ++i) hbuf[idx] += ref[i * ref_stride]; + hbuf[idx] /= 32; ++ref; } } @@ -46,16 +47,23 @@ int16_t sum = 0; for (idx = 0; idx < width; ++idx) sum += ref[idx]; - return sum; + return sum / 32; } -int vp9_vector_sad_c(int16_t const *ref, int16_t const *src, - const int width) { +int vp9_vector_var_c(int16_t const *ref, int16_t const *src, + const int bwl) { int i; - int this_sad = 0; - for (i = 0; i < width; ++i) - this_sad += abs(ref[i] - src[i]); - return this_sad; + int width = 4 << bwl; + int sse = 0, mean = 0, var; + + for (i = 0; i < width; ++i) { + int diff = ref[i] - src[i]; + mean += diff; + sse += diff * diff; + } + + var = sse - ((mean * mean) >> (bwl + 2)); + return var; } #if CONFIG_VP9_HIGHBITDEPTH