2 * Copyright 2011 The LibYuv Project Authors. All rights reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #ifndef UNIT_TEST_UNIT_TEST_H_ // NOLINT
12 #define UNIT_TEST_UNIT_TEST_H_
18 #include <sys/resource.h>
21 #include <gtest/gtest.h>
23 #include "libyuv/basic_types.h"
25 static __inline int Abs(int v) {
26 return v >= 0 ? v : -v;
31 #define align_buffer_page_end(var, size) \
34 var##_mem = reinterpret_cast<uint8*>(malloc((((size) + 4095) & ~4095) + \
36 var = var##_mem + (-(size) & 4095) + OFFBY;
38 #define free_aligned_buffer_page_end(var) \
43 static inline double get_time() {
45 QueryPerformanceCounter(&t);
46 QueryPerformanceFrequency(&f);
47 return static_cast<double>(t.QuadPart) / static_cast<double>(f.QuadPart);
53 static inline double get_time() {
56 gettimeofday(&t, &tzp);
57 return t.tv_sec + t.tv_usec * 1e-6;
61 static inline void MemRandomize(uint8* dst, int len) {
63 for (i = 0; i < len - 1; i += 2) {
64 *reinterpret_cast<uint16*>(dst) = random();
67 for (; i < len; ++i) {
72 class libyuvTest : public ::testing::Test {
76 const int rotate_max_w_;
77 const int rotate_max_h_;
79 int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
80 int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
81 int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
82 int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
83 int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
86 #endif // UNIT_TEST_UNIT_TEST_H_ NOLINT