michael@0: /* michael@0: * Copyright 2011 The LibYuv Project Authors. All rights reserved. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license michael@0: * that can be found in the LICENSE file in the root of the source michael@0: * tree. An additional intellectual property rights grant can be found michael@0: * in the file PATENTS. All contributing project authors may michael@0: * be found in the AUTHORS file in the root of the source tree. michael@0: */ michael@0: michael@0: #ifndef UNIT_TEST_UNIT_TEST_H_ // NOLINT michael@0: #define UNIT_TEST_UNIT_TEST_H_ michael@0: michael@0: #ifdef WIN32 michael@0: #include michael@0: #else michael@0: #include michael@0: #include michael@0: #endif michael@0: michael@0: #include michael@0: michael@0: #include "libyuv/basic_types.h" michael@0: michael@0: static __inline int Abs(int v) { michael@0: return v >= 0 ? v : -v; michael@0: } michael@0: michael@0: #define align_buffer_page_end(var, size) \ michael@0: uint8* var; \ michael@0: uint8* var##_mem; \ michael@0: var##_mem = reinterpret_cast(malloc(((size) + 4095) & ~4095)); \ michael@0: var = var##_mem + (-(size) & 4095); michael@0: michael@0: #define free_aligned_buffer_page_end(var) \ michael@0: free(var##_mem); \ michael@0: var = 0; michael@0: michael@0: #ifdef WIN32 michael@0: static inline double get_time() { michael@0: LARGE_INTEGER t, f; michael@0: QueryPerformanceCounter(&t); michael@0: QueryPerformanceFrequency(&f); michael@0: return static_cast(t.QuadPart) / static_cast(f.QuadPart); michael@0: } michael@0: michael@0: #define random rand michael@0: #define srandom srand michael@0: #else michael@0: static inline double get_time() { michael@0: struct timeval t; michael@0: struct timezone tzp; michael@0: gettimeofday(&t, &tzp); michael@0: return t.tv_sec + t.tv_usec * 1e-6; michael@0: } michael@0: #endif michael@0: michael@0: static inline void MemRandomize(uint8* dst, int len) { michael@0: int i; michael@0: for (i = 0; i < len - 1; i += 2) { michael@0: *reinterpret_cast(dst) = random(); michael@0: dst += 2; michael@0: } michael@0: for (; i < len; ++i) { michael@0: *dst++ = random(); michael@0: } michael@0: } michael@0: michael@0: class libyuvTest : public ::testing::Test { michael@0: protected: michael@0: libyuvTest(); michael@0: michael@0: const int rotate_max_w_; michael@0: const int rotate_max_h_; michael@0: michael@0: int benchmark_iterations_; // Default 1. Use 1000 for benchmarking. michael@0: int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA. michael@0: int benchmark_height_; // Default 720. Use 360 for benchmarking VGA. michael@0: int benchmark_pixels_div256_; // Total pixels to benchmark / 256. michael@0: int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280. michael@0: }; michael@0: michael@0: #endif // UNIT_TEST_UNIT_TEST_H_ NOLINT