summaryrefslogtreecommitdiff
path: root/vpx_dsp
diff options
context:
space:
mode:
authorAlex Converse <aconverse@google.com>2016-01-13 11:18:19 -0800
committerAlex Converse <aconverse@google.com>2016-01-13 11:19:06 -0800
commited3df445d99b511d3e39615a2f0a9d23c18efa3a (patch)
tree9961be7c9c7f81a536af7df12272ec8a8c06d0e9 /vpx_dsp
parentea48370a500537906d62544ca4ed75301d79e772 (diff)
downloadlibvpx-ed3df445d99b511d3e39615a2f0a9d23c18efa3a.tar
libvpx-ed3df445d99b511d3e39615a2f0a9d23c18efa3a.tar.gz
libvpx-ed3df445d99b511d3e39615a2f0a9d23c18efa3a.tar.bz2
libvpx-ed3df445d99b511d3e39615a2f0a9d23c18efa3a.zip
Revert "Merge "Change highbd variance rounding to prevent negative variance.""
This reverts commit ea48370a500537906d62544ca4ed75301d79e772, reversing changes made to 15939cb2d76c773950cda40988ede89e111872ea. The commit was insufficiently tested and causes failures. Change-Id: I623d6fc2cd3ae6fd42d0abab1f8eada465ae57a7
Diffstat (limited to 'vpx_dsp')
-rw-r--r--vpx_dsp/variance.c20
-rw-r--r--vpx_dsp/variance.h2
-rw-r--r--vpx_dsp/x86/highbd_variance_sse2.c21
3 files changed, 22 insertions, 21 deletions
diff --git a/vpx_dsp/variance.c b/vpx_dsp/variance.c
index 2d70c7b5d..e8bddb0a0 100644
--- a/vpx_dsp/variance.c
+++ b/vpx_dsp/variance.c
@@ -275,7 +275,7 @@ void vpx_comp_avg_pred_c(uint8_t *comp_pred, const uint8_t *pred,
#if CONFIG_VP9_HIGHBITDEPTH
static void highbd_variance64(const uint8_t *a8, int a_stride,
const uint8_t *b8, int b_stride,
- int w, int h, uint64_t *sse, int *sum) {
+ int w, int h, uint64_t *sse, uint64_t *sum) {
int i, j;
uint16_t *a = CONVERT_TO_SHORTPTR(a8);
@@ -298,26 +298,30 @@ static void highbd_8_variance(const uint8_t *a8, int a_stride,
const uint8_t *b8, int b_stride,
int w, int h, uint32_t *sse, int *sum) {
uint64_t sse_long = 0;
- highbd_variance64(a8, a_stride, b8, b_stride, w, h, &sse_long, sum);
+ uint64_t sum_long = 0;
+ highbd_variance64(a8, a_stride, b8, b_stride, w, h, &sse_long, &sum_long);
*sse = (uint32_t)sse_long;
+ *sum = (int)sum_long;
}
static void highbd_10_variance(const uint8_t *a8, int a_stride,
const uint8_t *b8, int b_stride,
int w, int h, uint32_t *sse, int *sum) {
uint64_t sse_long = 0;
- highbd_variance64(a8, a_stride, b8, b_stride, w, h, &sse_long, sum);
- *sse = (uint32_t)ROUND_ZERO_POWER_OF_TWO(sse_long, 4);
- *sum = ROUND_ZERO_POWER_OF_TWO(*sum, 2);
+ uint64_t sum_long = 0;
+ highbd_variance64(a8, a_stride, b8, b_stride, w, h, &sse_long, &sum_long);
+ *sse = (uint32_t)ROUND_POWER_OF_TWO(sse_long, 4);
+ *sum = (int)ROUND_POWER_OF_TWO(sum_long, 2);
}
static void highbd_12_variance(const uint8_t *a8, int a_stride,
const uint8_t *b8, int b_stride,
int w, int h, uint32_t *sse, int *sum) {
uint64_t sse_long = 0;
- highbd_variance64(a8, a_stride, b8, b_stride, w, h, &sse_long, sum);
- *sse = (uint32_t)ROUND_ZERO_POWER_OF_TWO(sse_long, 8);
- *sum = ROUND_ZERO_POWER_OF_TWO(*sum, 4);
+ uint64_t sum_long = 0;
+ highbd_variance64(a8, a_stride, b8, b_stride, w, h, &sse_long, &sum_long);
+ *sse = (uint32_t)ROUND_POWER_OF_TWO(sse_long, 8);
+ *sum = (int)ROUND_POWER_OF_TWO(sum_long, 4);
}
#define HIGHBD_VAR(W, H) \
diff --git a/vpx_dsp/variance.h b/vpx_dsp/variance.h
index fd7d30d63..cd0fd9878 100644
--- a/vpx_dsp/variance.h
+++ b/vpx_dsp/variance.h
@@ -19,8 +19,6 @@
extern "C" {
#endif
-#define ROUND_ZERO_POWER_OF_TWO(value, n) ((value) / (1 << (n)))
-
#define FILTER_BITS 7
#define FILTER_WEIGHT 128
diff --git a/vpx_dsp/x86/highbd_variance_sse2.c b/vpx_dsp/x86/highbd_variance_sse2.c
index ade5eacad..81ec5dbdb 100644
--- a/vpx_dsp/x86/highbd_variance_sse2.c
+++ b/vpx_dsp/x86/highbd_variance_sse2.c
@@ -9,7 +9,6 @@
*/
#include "./vpx_config.h"
-#include "vpx_dsp/variance.h"
#include "vpx_ports/mem.h"
typedef uint32_t (*high_variance_fn_t) (const uint16_t *src, int src_stride,
@@ -63,8 +62,8 @@ static void highbd_10_variance_sse2(const uint16_t *src, int src_stride,
sum_long += sum0;
}
}
- *sum = ROUND_ZERO_POWER_OF_TWO(sum_long, 2);
- *sse = (uint32_t)ROUND_ZERO_POWER_OF_TWO(sse_long, 4);
+ *sum = ROUND_POWER_OF_TWO(sum_long, 2);
+ *sse = (uint32_t)ROUND_POWER_OF_TWO(sse_long, 4);
}
static void highbd_12_variance_sse2(const uint16_t *src, int src_stride,
@@ -85,8 +84,8 @@ static void highbd_12_variance_sse2(const uint16_t *src, int src_stride,
sum_long += sum0;
}
}
- *sum = ROUND_ZERO_POWER_OF_TWO(sum_long, 4);
- *sse = (uint32_t)ROUND_ZERO_POWER_OF_TWO(sse_long, 8);
+ *sum = ROUND_POWER_OF_TWO(sum_long, 4);
+ *sse = (uint32_t)ROUND_POWER_OF_TWO(sse_long, 8);
}
@@ -107,7 +106,7 @@ void vpx_highbd_10_get##S##x##S##var_sse2(const uint8_t *src8, int src_stride, \
uint16_t *ref = CONVERT_TO_SHORTPTR(ref8); \
vpx_highbd_calc##S##x##S##var_sse2(src, src_stride, ref, ref_stride, \
sse, sum); \
- *sum = ROUND_ZERO_POWER_OF_TWO(*sum, 2); \
+ *sum = ROUND_POWER_OF_TWO(*sum, 2); \
*sse = ROUND_POWER_OF_TWO(*sse, 4); \
} \
\
@@ -118,7 +117,7 @@ void vpx_highbd_12_get##S##x##S##var_sse2(const uint8_t *src8, int src_stride, \
uint16_t *ref = CONVERT_TO_SHORTPTR(ref8); \
vpx_highbd_calc##S##x##S##var_sse2(src, src_stride, ref, ref_stride, \
sse, sum); \
- *sum = ROUND_ZERO_POWER_OF_TWO(*sum, 4); \
+ *sum = ROUND_POWER_OF_TWO(*sum, 4); \
*sse = ROUND_POWER_OF_TWO(*sse, 8); \
}
@@ -346,7 +345,7 @@ uint32_t vpx_highbd_10_sub_pixel_variance##w##x##h##_##opt( \
sse += sse2; \
} \
} \
- se = ROUND_ZERO_POWER_OF_TWO(se, 2); \
+ se = ROUND_POWER_OF_TWO(se, 2); \
sse = ROUND_POWER_OF_TWO(sse, 4); \
*sse_ptr = sse; \
return sse - ((cast se * se) >> (wlog2 + hlog2)); \
@@ -393,7 +392,7 @@ uint32_t vpx_highbd_12_sub_pixel_variance##w##x##h##_##opt( \
}\
} \
} \
- se = ROUND_ZERO_POWER_OF_TWO(se, 4); \
+ se = ROUND_POWER_OF_TWO(se, 4); \
sse = (uint32_t)ROUND_POWER_OF_TWO(long_sse, 8); \
*sse_ptr = sse; \
return sse - ((cast se * se) >> (wlog2 + hlog2)); \
@@ -515,7 +514,7 @@ uint32_t vpx_highbd_10_sub_pixel_avg_variance##w##x##h##_##opt( \
sse += sse2; \
} \
} \
- se = ROUND_ZERO_POWER_OF_TWO(se, 2); \
+ se = ROUND_POWER_OF_TWO(se, 2); \
sse = ROUND_POWER_OF_TWO(sse, 4); \
*sse_ptr = sse; \
return sse - ((cast se * se) >> (wlog2 + hlog2)); \
@@ -567,7 +566,7 @@ uint32_t vpx_highbd_12_sub_pixel_avg_variance##w##x##h##_##opt( \
} \
} \
} \
- se = ROUND_ZERO_POWER_OF_TWO(se, 4); \
+ se = ROUND_POWER_OF_TWO(se, 4); \
sse = (uint32_t)ROUND_POWER_OF_TWO(long_sse, 8); \
*sse_ptr = sse; \
return sse - ((cast se * se) >> (wlog2 + hlog2)); \