[NORMATIVE] Make Wiener rounding consistent w/ motion comp
BUG=aomedia:1566
Change-Id: I0a770212aa701f9ffb80756090473a76c2912dc7
diff --git a/av1/common/convolve.h b/av1/common/convolve.h
index 989baf8..f72271a 100644
--- a/av1/common/convolve.h
+++ b/av1/common/convolve.h
@@ -36,15 +36,14 @@
#if CONFIG_LOWPRECISION_BLEND
#define ROUND0_BITS 3
#define COMPOUND_ROUND1_BITS 7
+#define WIENER_ROUND0_BITS 3
#else
#define ROUND0_BITS 5
#define COMPOUND_ROUND1_BITS 0
+#define WIENER_ROUND0_BITS 5
#endif // CONFIG_LOWPRECISION_BLEND
-#define WIENER_ROUND0_BITS 5
-#define WIENER_ROUND1_BITS (FILTER_BITS * 2 - WIENER_ROUND0_BITS)
-#define WIENER_CLAMP_LIMIT(bd) \
- (1 << ((bd) + 1 + FILTER_BITS - WIENER_ROUND0_BITS))
+#define WIENER_CLAMP_LIMIT(r0, bd) (1 << ((bd) + 1 + FILTER_BITS - r0))
typedef void (*aom_convolve_fn_t)(const uint8_t *src, int src_stride,
uint8_t *dst, int dst_stride, int w, int h,
@@ -103,7 +102,7 @@
conv_params.round_1 = is_compound ? COMPOUND_ROUND1_BITS
: 2 * FILTER_BITS - conv_params.round_0;
const int intbufrange = bd + FILTER_BITS - conv_params.round_0 + 2;
- if (bd < 12) assert(intbufrange <= 16);
+ assert(IMPLIES(bd < 12, intbufrange <= 16));
if (intbufrange > 16) {
conv_params.round_0 += intbufrange - 16;
if (!is_compound) conv_params.round_1 -= intbufrange - 16;
@@ -132,7 +131,13 @@
conv_params.do_average = 0;
conv_params.is_compound = 0;
conv_params.round_0 = WIENER_ROUND0_BITS;
- conv_params.round_1 = WIENER_ROUND1_BITS;
+ conv_params.round_1 = 2 * FILTER_BITS - conv_params.round_0;
+ const int intbufrange = bd + FILTER_BITS - conv_params.round_0 + 2;
+ assert(IMPLIES(bd < 12, intbufrange <= 16));
+ if (intbufrange > 16) {
+ conv_params.round_0 += intbufrange - 16;
+ conv_params.round_1 -= intbufrange - 16;
+ }
conv_params.dst = NULL;
conv_params.dst_stride = 0;
conv_params.plane = 0;