Test DJB2 hash with half the buffer same.

BUG=none
TEST=libyuvTest.BenchmakDjb2_Test
Review URL: https://webrtc-codereview.appspot.com/1446004

git-svn-id: http://libyuv.googlecode.com/svn/trunk@689 16f28f9a-4ce2-e073-06de-1de4eb20be90
This commit is contained in:
fbarchard@google.com 2013-05-08 23:05:08 +00:00
parent f6108da7d0
commit 6a34ee200e
4 changed files with 50 additions and 2 deletions

View File

@ -1,6 +1,6 @@
Name: libyuv
URL: http://code.google.com/p/libyuv/
Version: 687
Version: 688
License: BSD
License File: LICENSE

View File

@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 687
#define LIBYUV_VERSION 688
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT

View File

@ -30,6 +30,50 @@ static uint32 ReferenceHashDjb2(const uint8* src, uint64 count, uint32 seed) {
return hash;
}
TEST_F(libyuvTest, Djb2_Test) {
const int kMaxTest = benchmark_width_ * benchmark_height_;
align_buffer_64(src_a, kMaxTest)
align_buffer_64(src_b, kMaxTest)
for (int i = 0; i < kMaxTest; ++i) {
src_a[i] = (random() & 0xff);
src_b[i] = (random() & 0xff);
}
// Compare different buffers. Expect hash is different.
uint32 h1 = HashDjb2(src_a, kMaxTest, 5381);
uint32 h2 = HashDjb2(src_b, kMaxTest, 5381);
EXPECT_NE(h1, h2);
// Make last half same. Expect hash is different.
memcpy(src_a + kMaxTest / 2, src_b + kMaxTest / 2, kMaxTest / 2);
h1 = HashDjb2(src_a, kMaxTest, 5381);
h2 = HashDjb2(src_b, kMaxTest, 5381);
EXPECT_NE(h1, h2);
// Make first half same. Expect hash is different.
memcpy(src_a + kMaxTest / 2, src_a, kMaxTest / 2);
memcpy(src_b + kMaxTest / 2, src_b, kMaxTest / 2);
memcpy(src_a, src_b, kMaxTest / 2);
h1 = HashDjb2(src_a, kMaxTest, 5381);
h2 = HashDjb2(src_b, kMaxTest, 5381);
EXPECT_NE(h1, h2);
// Make same. Expect hash is same.
memcpy(src_a, src_b, kMaxTest);
h1 = HashDjb2(src_a, kMaxTest, 5381);
h2 = HashDjb2(src_b, kMaxTest, 5381);
EXPECT_EQ(h1, h2);
// Mask seed different. Expect hash is different.
memcpy(src_a, src_b, kMaxTest);
h1 = HashDjb2(src_a, kMaxTest, 5381);
h2 = HashDjb2(src_b, kMaxTest, 1234);
EXPECT_NE(h1, h2);
free_aligned_buffer_64(src_a)
free_aligned_buffer_64(src_b)
}
TEST_F(libyuvTest, BenchmakDjb2_Opt) {
const int kMaxTest = benchmark_width_ * benchmark_height_;
align_buffer_64(src_a, kMaxTest)

View File

@ -1,2 +1,6 @@
psnr: psnr.cc ssim.cc psnr_main.cc
ifeq ($(CXX),icl)
$(CXX) /arch:SSE2 /Ox /openmp psnr.cc ssim.cc psnr_main.cc
else
$(CXX) -msse2 -O3 -fopenmp -static -o psnr psnr.cc ssim.cc psnr_main.cc -Wl,--strip-all
endif