Commit db25485e authored by Frank Barchard's avatar Frank Barchard Committed by Commit Bot

Move compare functions into a unittest class

BUG=None
TEST=LibYUVCompareTest.*
R=jkellander@chromium.org

Change-Id: I3131ca73020f855ead08255d09aa7a846bf0d556
Reviewed-on: https://chromium-review.googlesource.com/540064
Commit-Queue: Frank Barchard <fbarchard@google.com>
Reviewed-by: 's avatarHenrik Kjellander <kjellander@chromium.org>
parent 9e920b9c
Name: libyuv
URL: http://code.google.com/p/libyuv/
Version: 1660
Version: 1661
License: BSD
License File: LICENSE
......
......@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_
#define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 1660
#define LIBYUV_VERSION 1661
#endif // INCLUDE_LIBYUV_VERSION_H_
......@@ -32,7 +32,7 @@ static uint32 ReferenceHashDjb2(const uint8* src, uint64 count, uint32 seed) {
return hash;
}
TEST_F(LibYUVBaseTest, Djb2_Test) {
TEST_F(LibYUVCompareTest, Djb2_Test) {
const int kMaxTest = benchmark_width_ * benchmark_height_;
align_buffer_page_end(src_a, kMaxTest);
align_buffer_page_end(src_b, kMaxTest);
......@@ -117,7 +117,7 @@ TEST_F(LibYUVBaseTest, Djb2_Test) {
free_aligned_buffer_page_end(src_b);
}
TEST_F(LibYUVBaseTest, BenchmarkDjb2_Opt) {
TEST_F(LibYUVCompareTest, BenchmarkDjb2_Opt) {
const int kMaxTest = benchmark_width_ * benchmark_height_;
align_buffer_page_end(src_a, kMaxTest);
......@@ -133,7 +133,7 @@ TEST_F(LibYUVBaseTest, BenchmarkDjb2_Opt) {
free_aligned_buffer_page_end(src_a);
}
TEST_F(LibYUVBaseTest, BenchmarkDjb2_Unaligned) {
TEST_F(LibYUVCompareTest, BenchmarkDjb2_Unaligned) {
const int kMaxTest = benchmark_width_ * benchmark_height_;
align_buffer_page_end(src_a, kMaxTest + 1);
for (int i = 0; i < kMaxTest; ++i) {
......@@ -148,7 +148,7 @@ TEST_F(LibYUVBaseTest, BenchmarkDjb2_Unaligned) {
free_aligned_buffer_page_end(src_a);
}
TEST_F(LibYUVBaseTest, BenchmarkARGBDetect_Opt) {
TEST_F(LibYUVCompareTest, BenchmarkARGBDetect_Opt) {
uint32 fourcc;
const int kMaxTest = benchmark_width_ * benchmark_height_ * 4;
align_buffer_page_end(src_a, kMaxTest);
......@@ -176,7 +176,7 @@ TEST_F(LibYUVBaseTest, BenchmarkARGBDetect_Opt) {
free_aligned_buffer_page_end(src_a);
}
TEST_F(LibYUVBaseTest, BenchmarkARGBDetect_Unaligned) {
TEST_F(LibYUVCompareTest, BenchmarkARGBDetect_Unaligned) {
uint32 fourcc;
const int kMaxTest = benchmark_width_ * benchmark_height_ * 4 + 1;
align_buffer_page_end(src_a, kMaxTest);
......@@ -204,7 +204,7 @@ TEST_F(LibYUVBaseTest, BenchmarkARGBDetect_Unaligned) {
free_aligned_buffer_page_end(src_a);
}
TEST_F(LibYUVBaseTest, BenchmarkHammingDistance_Opt) {
TEST_F(LibYUVCompareTest, BenchmarkHammingDistance_Opt) {
const int kMaxWidth = 4096 * 3;
align_buffer_page_end(src_a, kMaxWidth);
align_buffer_page_end(src_b, kMaxWidth);
......@@ -242,7 +242,7 @@ TEST_F(LibYUVBaseTest, BenchmarkHammingDistance_Opt) {
free_aligned_buffer_page_end(src_b);
}
TEST_F(LibYUVBaseTest, BenchmarkHammingDistance_C) {
TEST_F(LibYUVCompareTest, BenchmarkHammingDistance_C) {
const int kMaxWidth = 4096 * 3;
align_buffer_page_end(src_a, kMaxWidth);
align_buffer_page_end(src_b, kMaxWidth);
......@@ -274,7 +274,7 @@ TEST_F(LibYUVBaseTest, BenchmarkHammingDistance_C) {
free_aligned_buffer_page_end(src_b);
}
TEST_F(LibYUVBaseTest, BenchmarkHammingDistance) {
TEST_F(LibYUVCompareTest, BenchmarkHammingDistance) {
const int kMaxWidth = 4096 * 3;
align_buffer_page_end(src_a, kMaxWidth);
align_buffer_page_end(src_b, kMaxWidth);
......@@ -305,7 +305,7 @@ TEST_F(LibYUVBaseTest, BenchmarkHammingDistance) {
free_aligned_buffer_page_end(src_b);
}
TEST_F(LibYUVBaseTest, BenchmarkSumSquareError_Opt) {
TEST_F(LibYUVCompareTest, BenchmarkSumSquareError_Opt) {
const int kMaxWidth = 4096 * 3;
align_buffer_page_end(src_a, kMaxWidth);
align_buffer_page_end(src_b, kMaxWidth);
......@@ -337,7 +337,7 @@ TEST_F(LibYUVBaseTest, BenchmarkSumSquareError_Opt) {
free_aligned_buffer_page_end(src_b);
}
TEST_F(LibYUVBaseTest, SumSquareError) {
TEST_F(LibYUVCompareTest, SumSquareError) {
const int kMaxWidth = 4096 * 3;
align_buffer_page_end(src_a, kMaxWidth);
align_buffer_page_end(src_b, kMaxWidth);
......@@ -377,7 +377,7 @@ TEST_F(LibYUVBaseTest, SumSquareError) {
free_aligned_buffer_page_end(src_b);
}
TEST_F(LibYUVBaseTest, BenchmarkPsnr_Opt) {
TEST_F(LibYUVCompareTest, BenchmarkPsnr_Opt) {
align_buffer_page_end(src_a, benchmark_width_ * benchmark_height_);
align_buffer_page_end(src_b, benchmark_width_ * benchmark_height_);
for (int i = 0; i < benchmark_width_ * benchmark_height_; ++i) {
......@@ -401,7 +401,7 @@ TEST_F(LibYUVBaseTest, BenchmarkPsnr_Opt) {
free_aligned_buffer_page_end(src_b);
}
TEST_F(LibYUVBaseTest, BenchmarkPsnr_Unaligned) {
TEST_F(LibYUVCompareTest, BenchmarkPsnr_Unaligned) {
align_buffer_page_end(src_a, benchmark_width_ * benchmark_height_ + 1);
align_buffer_page_end(src_b, benchmark_width_ * benchmark_height_);
for (int i = 0; i < benchmark_width_ * benchmark_height_; ++i) {
......@@ -425,7 +425,7 @@ TEST_F(LibYUVBaseTest, BenchmarkPsnr_Unaligned) {
free_aligned_buffer_page_end(src_b);
}
TEST_F(LibYUVBaseTest, Psnr) {
TEST_F(LibYUVCompareTest, Psnr) {
const int kSrcWidth = benchmark_width_;
const int kSrcHeight = benchmark_height_;
const int b = 128;
......@@ -502,7 +502,7 @@ TEST_F(LibYUVBaseTest, Psnr) {
free_aligned_buffer_page_end(src_b);
}
TEST_F(LibYUVBaseTest, DISABLED_BenchmarkSsim_Opt) {
TEST_F(LibYUVCompareTest, DISABLED_BenchmarkSsim_Opt) {
align_buffer_page_end(src_a, benchmark_width_ * benchmark_height_);
align_buffer_page_end(src_b, benchmark_width_ * benchmark_height_);
for (int i = 0; i < benchmark_width_ * benchmark_height_; ++i) {
......@@ -526,7 +526,7 @@ TEST_F(LibYUVBaseTest, DISABLED_BenchmarkSsim_Opt) {
free_aligned_buffer_page_end(src_b);
}
TEST_F(LibYUVBaseTest, Ssim) {
TEST_F(LibYUVCompareTest, Ssim) {
const int kSrcWidth = benchmark_width_;
const int kSrcHeight = benchmark_height_;
const int b = 128;
......
......@@ -399,6 +399,65 @@ LibYUVBaseTest::LibYUVBaseTest()
1280.0);
}
LibYUVCompareTest::LibYUVCompareTest()
: benchmark_iterations_(BENCHMARK_ITERATIONS),
benchmark_width_(128),
benchmark_height_(72),
disable_cpu_flags_(1),
benchmark_cpu_info_(-1) {
const char* repeat = getenv("LIBYUV_REPEAT");
if (repeat) {
benchmark_iterations_ = atoi(repeat); // NOLINT
}
if (FLAGS_libyuv_repeat) {
benchmark_iterations_ = FLAGS_libyuv_repeat;
}
if (benchmark_iterations_ > 1) {
benchmark_width_ = 1280;
benchmark_height_ = 720;
}
const char* width = getenv("LIBYUV_WIDTH");
if (width) {
benchmark_width_ = atoi(width); // NOLINT
}
if (FLAGS_libyuv_width) {
benchmark_width_ = FLAGS_libyuv_width;
}
const char* height = getenv("LIBYUV_HEIGHT");
if (height) {
benchmark_height_ = atoi(height); // NOLINT
}
if (FLAGS_libyuv_height) {
benchmark_height_ = FLAGS_libyuv_height;
}
const char* cpu_flags = getenv("LIBYUV_FLAGS");
if (cpu_flags) {
disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
}
if (FLAGS_libyuv_flags) {
disable_cpu_flags_ = FLAGS_libyuv_flags;
}
const char* cpu_info = getenv("LIBYUV_CPU_INFO");
if (cpu_info) {
benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT
}
if (FLAGS_libyuv_cpu_info) {
benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
}
benchmark_pixels_div256_ =
static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) *
static_cast<double>(benchmark_iterations_) +
255.0) /
256.0);
benchmark_pixels_div1280_ =
static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) *
static_cast<double>(benchmark_iterations_) +
1279.0) /
1280.0);
}
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
#ifdef LIBYUV_USE_GFLAGS
......
......@@ -70,9 +70,8 @@ static inline bool SizeValid(int src_width,
uint8* var; \
uint8* var##_mem; \
var##_mem = reinterpret_cast<uint8*>(malloc(((size) + 4095 + 63) & ~4095)); \
var = (uint8*)((intptr_t)(var##_mem + (((size) + 4095 + 63) & ~4095) - \
(size)) & \
~63);
var = (uint8*)((intptr_t)(var##_mem + (((size) + 4095 + 63) & /* NOLINT */ \
~4095) - (size)) & ~63);
#define free_aligned_buffer_page_end(var) \
free(var##_mem); \
......@@ -199,4 +198,17 @@ class LibYUVBaseTest : public ::testing::Test {
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
};
class LibYUVCompareTest : public ::testing::Test {
protected:
LibYUVCompareTest();
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
};
#endif // UNIT_TEST_UNIT_TEST_H_ NOLINT
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment