OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. | 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef UNIT_TEST_UNIT_TEST_H_ // NOLINT | 11 #ifndef UNIT_TEST_UNIT_TEST_H_ // NOLINT |
12 #define UNIT_TEST_UNIT_TEST_H_ | 12 #define UNIT_TEST_UNIT_TEST_H_ |
13 | 13 |
14 #ifdef WIN32 | 14 #ifdef WIN32 |
15 #include <windows.h> | 15 #include <windows.h> |
16 #else | 16 #else |
17 #include <sys/time.h> | 17 #include <sys/time.h> |
18 #include <sys/resource.h> | 18 #include <sys/resource.h> |
19 #endif | 19 #endif |
20 | 20 |
21 #include <gtest/gtest.h> | 21 #include <gtest/gtest.h> |
22 | 22 |
23 #include "libyuv/basic_types.h" | 23 #include "libyuv/basic_types.h" |
24 | 24 |
| 25 #ifndef SIMD_ALIGNED |
| 26 #if defined(_MSC_VER) && !defined(__CLR_VER) |
| 27 #define SIMD_ALIGNED(var) __declspec(align(16)) var |
| 28 #elif defined(__GNUC__) && !defined(__pnacl__) |
| 29 #define SIMD_ALIGNED(var) var __attribute__((aligned(16))) |
| 30 #else |
| 31 #define SIMD_ALIGNED(var) var |
| 32 #endif |
| 33 #endif |
| 34 |
25 static __inline int Abs(int v) { | 35 static __inline int Abs(int v) { |
26 return v >= 0 ? v : -v; | 36 return v >= 0 ? v : -v; |
27 } | 37 } |
28 | 38 |
29 #define OFFBY 0 | 39 #define OFFBY 0 |
30 | 40 |
31 // Scaling uses 16.16 fixed point to step thru the source image, so a | 41 // Scaling uses 16.16 fixed point to step thru the source image, so a |
32 // maximum size of 32767.999 can be expressed. 32768 is valid because | 42 // maximum size of 32767.999 can be expressed. 32768 is valid because |
33 // the step is 1 beyond the image but not used. | 43 // the step is 1 beyond the image but not used. |
34 // Destination size is mainly constrained by valid scale step not the | 44 // Destination size is mainly constrained by valid scale step not the |
35 // absolute size, so it may be possible to relax the destination size | 45 // absolute size, so it may be possible to relax the destination size |
36 // constraint. | 46 // constraint. |
37 // Source size is unconstrained for most specialized scalers. e.g. | 47 // Source size is unconstrained for most specialized scalers. e.g. |
38 // An image of 65536 scaled to half size would be valid. The test | 48 // An image of 65536 scaled to half size would be valid. The test |
39 // could be relaxed for special scale factors. | 49 // could be relaxed for special scale factors. |
40 // If this test is removed, the scaling function should gracefully | 50 // If this test is removed, the scaling function should gracefully |
41 // fail with a return code. The test could be changed to know that | 51 // fail with a return code. The test could be changed to know that |
42 // libyuv failed in a controlled way. | 52 // libyuv failed in a controlled way. |
43 | 53 |
44 static const int kMaxWidth = 32768; | 54 static const int kMaxWidth = 32768; |
45 static const int kMaxHeight = 32768; | 55 static const int kMaxHeight = 32768; |
46 | 56 |
47 static inline bool SizeValid(int src_width, int src_height, | 57 static inline bool SizeValid(int src_width, int src_height, |
48 int dst_width, int dst_height) { | 58 int dst_width, int dst_height) { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 int benchmark_iterations_; // Default 1. Use 1000 for benchmarking. | 180 int benchmark_iterations_; // Default 1. Use 1000 for benchmarking. |
171 int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA. | 181 int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA. |
172 int benchmark_height_; // Default 720. Use 360 for benchmarking VGA. | 182 int benchmark_height_; // Default 720. Use 360 for benchmarking VGA. |
173 int benchmark_pixels_div256_; // Total pixels to benchmark / 256. | 183 int benchmark_pixels_div256_; // Total pixels to benchmark / 256. |
174 int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280. | 184 int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280. |
175 int disable_cpu_flags_; // Default 1. Use -1 for benchmarking. | 185 int disable_cpu_flags_; // Default 1. Use -1 for benchmarking. |
176 int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD. | 186 int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD. |
177 }; | 187 }; |
178 | 188 |
179 #endif // UNIT_TEST_UNIT_TEST_H_ NOLINT | 189 #endif // UNIT_TEST_UNIT_TEST_H_ NOLINT |
OLD | NEW |