• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2011 The LibYuv Project Authors. All rights reserved.
3  *
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.
9  */
10 
11 #ifndef UNIT_TEST_UNIT_TEST_H_
12 #define UNIT_TEST_UNIT_TEST_H_
13 
14 #include <gtest/gtest.h>
15 
16 #define align_buffer_16(var, size)                                             \
17   uint8* var;                                                                  \
18   uint8* var##_mem;                                                            \
19   var##_mem = reinterpret_cast<uint8*>(malloc((size) + 15));                   \
20   var = reinterpret_cast<uint8*>                                               \
21         ((reinterpret_cast<intptr_t>(var##_mem) + 15) & ~15);
22 
23 #define free_aligned_buffer_16(var) \
24   free(var##_mem);  \
25   var = 0;
26 
27 
28 #define align_buffer_page_end(var, size)                                       \
29   uint8* var;                                                                  \
30   uint8* var##_mem;                                                            \
31   var##_mem = reinterpret_cast<uint8*>(malloc(((size) + 4095) & ~4095));       \
32   var = var##_mem + (-(size) & 4095);
33 
34 #define free_aligned_buffer_page_end(var) \
35   free(var##_mem);  \
36   var = 0;
37 
38 #ifdef WIN32
39 #include <windows.h>
get_time()40 static inline double get_time() {
41   LARGE_INTEGER t, f;
42   QueryPerformanceCounter(&t);
43   QueryPerformanceFrequency(&f);
44   return static_cast<double>(t.QuadPart) / static_cast<double>(f.QuadPart);
45 }
46 
47 #define random rand
48 #define srandom srand
49 #else
50 
51 #include <sys/time.h>
52 #include <sys/resource.h>
53 
get_time()54 static inline double get_time() {
55   struct timeval t;
56   struct timezone tzp;
57   gettimeofday(&t, &tzp);
58   return t.tv_sec + t.tv_usec * 1e-6;
59 }
60 #endif
61 
62 class libyuvTest : public ::testing::Test {
63  protected:
64   libyuvTest();
65 
66   const int rotate_max_w_;
67   const int rotate_max_h_;
68 
69   int benchmark_iterations_;
70   const int benchmark_width_;
71   const int benchmark_height_;
72 };
73 
74 #endif  // UNIT_TEST_UNIT_TEST_H_
75