diff options
author | Yi Luo <luoyi@google.com> | 2016-04-04 09:44:56 -0700 |
---|---|---|
committer | Yi Luo <luoyi@google.com> | 2016-04-05 09:27:03 -0700 |
commit | 4bdc7d1c886ca359f6631b75bf08a59794f07823 (patch) | |
tree | 83e48446d866a55d8373251b1b022e651d84e6e7 /test | |
parent | 89b1c9d4bec12e96307942a3dfb9a1397276141d (diff) | |
download | libvpx-4bdc7d1c886ca359f6631b75bf08a59794f07823.tar libvpx-4bdc7d1c886ca359f6631b75bf08a59794f07823.tar.gz libvpx-4bdc7d1c886ca359f6631b75bf08a59794f07823.tar.bz2 libvpx-4bdc7d1c886ca359f6631b75bf08a59794f07823.zip |
Fix high bit depth mask and variance reference function
- Use arithmetic AND (&) instead of logical AND (&&) to
generate correct testing input.
- Fix variance reference function to be consistent with
our codebase implementation.
- Refer to the following issue:
https://bugs.chromium.org/p/webm/issues/detail?id=1166
Change-Id: I8c1ebb03e22dc9e1dcd96bdf935fc126cee71307
Diffstat (limited to 'test')
-rw-r--r-- | test/variance_test.cc | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/test/variance_test.cc b/test/variance_test.cc index 6f50f78f2..a9ca07cf4 100644 --- a/test/variance_test.cc +++ b/test/variance_test.cc @@ -74,6 +74,10 @@ static unsigned int mb_ss_ref(const int16_t *src) { return res; } +/* Note: + * Our codebase calculates the "diff" value in the variance algorithm by + * (src - ref). + */ static uint32_t variance_ref(const uint8_t *src, const uint8_t *ref, int l2w, int l2h, int src_stride_coeff, int ref_stride_coeff, uint32_t *sse_ptr, @@ -87,14 +91,14 @@ static uint32_t variance_ref(const uint8_t *src, const uint8_t *ref, for (int x = 0; x < w; x++) { int diff; if (!use_high_bit_depth_) { - diff = ref[w * y * ref_stride_coeff + x] - - src[w * y * src_stride_coeff + x]; + diff = src[w * y * src_stride_coeff + x] - + ref[w * y * ref_stride_coeff + x]; se += diff; sse += diff * diff; #if CONFIG_VP9_HIGHBITDEPTH } else { - diff = CONVERT_TO_SHORTPTR(ref)[w * y * ref_stride_coeff + x] - - CONVERT_TO_SHORTPTR(src)[w * y * src_stride_coeff + x]; + diff = CONVERT_TO_SHORTPTR(src)[w * y * src_stride_coeff + x] - + CONVERT_TO_SHORTPTR(ref)[w * y * ref_stride_coeff + x]; se += diff; sse += diff * diff; #endif // CONFIG_VP9_HIGHBITDEPTH @@ -309,15 +313,15 @@ template<typename VarianceFunctionType> void VarianceTest<VarianceFunctionType>::RefTest() { for (int i = 0; i < 10; ++i) { for (int j = 0; j < block_size_; j++) { - if (!use_high_bit_depth_) { - src_[j] = rnd_.Rand8(); - ref_[j] = rnd_.Rand8(); + if (!use_high_bit_depth_) { + src_[j] = rnd_.Rand8(); + ref_[j] = rnd_.Rand8(); #if CONFIG_VP9_HIGHBITDEPTH - } else { - CONVERT_TO_SHORTPTR(src_)[j] = rnd_.Rand16() && mask_; - CONVERT_TO_SHORTPTR(ref_)[j] = rnd_.Rand16() && mask_; + } else { + CONVERT_TO_SHORTPTR(src_)[j] = rnd_.Rand16() & mask_; + CONVERT_TO_SHORTPTR(ref_)[j] = rnd_.Rand16() & mask_; #endif // CONFIG_VP9_HIGHBITDEPTH - } + } } unsigned int sse1, sse2; unsigned int var1; @@ -328,8 +332,10 @@ void VarianceTest<VarianceFunctionType>::RefTest() { log2height_, stride_coeff, stride_coeff, &sse2, use_high_bit_depth_, bit_depth_); - EXPECT_EQ(sse1, sse2); - EXPECT_EQ(var1, var2); + EXPECT_EQ(sse1, sse2) + << "Error at test index: " << i; + EXPECT_EQ(var1, var2) + << "Error at test index: " << i; } } @@ -346,8 +352,8 @@ void VarianceTest<VarianceFunctionType>::RefStrideTest() { ref_[ref_ind] = rnd_.Rand8(); #if CONFIG_VP9_HIGHBITDEPTH } else { - CONVERT_TO_SHORTPTR(src_)[src_ind] = rnd_.Rand16() && mask_; - CONVERT_TO_SHORTPTR(ref_)[ref_ind] = rnd_.Rand16() && mask_; + CONVERT_TO_SHORTPTR(src_)[src_ind] = rnd_.Rand16() & mask_; + CONVERT_TO_SHORTPTR(ref_)[ref_ind] = rnd_.Rand16() & mask_; #endif // CONFIG_VP9_HIGHBITDEPTH } } @@ -361,8 +367,10 @@ void VarianceTest<VarianceFunctionType>::RefStrideTest() { log2height_, src_stride_coeff, ref_stride_coeff, &sse2, use_high_bit_depth_, bit_depth_); - EXPECT_EQ(sse1, sse2); - EXPECT_EQ(var1, var2); + EXPECT_EQ(sse1, sse2) + << "Error at test index: " << i; + EXPECT_EQ(var1, var2) + << "Error at test index: " << i; } } |