react-native-vision-camera-spoof-detector 1.0.22 → 1.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/README.md +442 -442
  2. package/android/.gradle/9.2.0/checksums/checksums.lock +0 -0
  3. package/android/.gradle/9.2.0/fileHashes/fileHashes.bin +0 -0
  4. package/android/.gradle/9.2.0/fileHashes/fileHashes.lock +0 -0
  5. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  6. package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
  7. package/android/build/reports/problems/problems-report.html +659 -0
  8. package/android/build.gradle +12 -4
  9. package/android/src/main/cpp/CMakeLists.txt +101 -94
  10. package/android/src/main/cpp/libyuv/.clang-format +6 -6
  11. package/android/src/main/cpp/libyuv/.gn +40 -40
  12. package/android/src/main/cpp/libyuv/.vpython3 +410 -410
  13. package/android/src/main/cpp/libyuv/AUTHORS +7 -7
  14. package/android/src/main/cpp/libyuv/Android.bp +202 -202
  15. package/android/src/main/cpp/libyuv/Android.mk +106 -106
  16. package/android/src/main/cpp/libyuv/BUILD.gn +490 -490
  17. package/android/src/main/cpp/libyuv/CM_linux_packages.cmake +70 -70
  18. package/android/src/main/cpp/libyuv/CMakeLists.txt +259 -252
  19. package/android/src/main/cpp/libyuv/DEPS +935 -935
  20. package/android/src/main/cpp/libyuv/DIR_METADATA +3 -3
  21. package/android/src/main/cpp/libyuv/LICENSE +29 -29
  22. package/android/src/main/cpp/libyuv/OWNERS +11 -11
  23. package/android/src/main/cpp/libyuv/PATENTS +23 -23
  24. package/android/src/main/cpp/libyuv/PRESUBMIT.py +65 -65
  25. package/android/src/main/cpp/libyuv/README.chromium +11 -11
  26. package/android/src/main/cpp/libyuv/README.md +19 -19
  27. package/android/src/main/cpp/libyuv/build_overrides/build.gni +60 -60
  28. package/android/src/main/cpp/libyuv/build_overrides/gtest.gni +19 -19
  29. package/android/src/main/cpp/libyuv/build_overrides/partition_alloc.gni +17 -17
  30. package/android/src/main/cpp/libyuv/codereview.settings +5 -5
  31. package/android/src/main/cpp/libyuv/docs/deprecated_builds.md +409 -409
  32. package/android/src/main/cpp/libyuv/docs/environment_variables.md +64 -64
  33. package/android/src/main/cpp/libyuv/docs/feature_detection.md +108 -108
  34. package/android/src/main/cpp/libyuv/docs/filtering.md +196 -196
  35. package/android/src/main/cpp/libyuv/docs/formats.md +208 -208
  36. package/android/src/main/cpp/libyuv/docs/getting_started.md +296 -296
  37. package/android/src/main/cpp/libyuv/docs/rotation.md +107 -107
  38. package/android/src/main/cpp/libyuv/download_vs_toolchain.py +29 -29
  39. package/android/src/main/cpp/libyuv/include/libyuv/basic_types.h +68 -68
  40. package/android/src/main/cpp/libyuv/include/libyuv/compare.h +111 -111
  41. package/android/src/main/cpp/libyuv/include/libyuv/compare_row.h +112 -112
  42. package/android/src/main/cpp/libyuv/include/libyuv/convert.h +1117 -1117
  43. package/android/src/main/cpp/libyuv/include/libyuv/convert_argb.h +2335 -2335
  44. package/android/src/main/cpp/libyuv/include/libyuv/convert_from.h +203 -203
  45. package/android/src/main/cpp/libyuv/include/libyuv/convert_from_argb.h +394 -394
  46. package/android/src/main/cpp/libyuv/include/libyuv/cpu_id.h +147 -147
  47. package/android/src/main/cpp/libyuv/include/libyuv/cpu_support.h +99 -99
  48. package/android/src/main/cpp/libyuv/include/libyuv/loongson_intrinsics.h +1949 -1949
  49. package/android/src/main/cpp/libyuv/include/libyuv/mjpeg_decoder.h +195 -195
  50. package/android/src/main/cpp/libyuv/include/libyuv/planar_functions.h +1131 -1131
  51. package/android/src/main/cpp/libyuv/include/libyuv/rotate.h +296 -296
  52. package/android/src/main/cpp/libyuv/include/libyuv/rotate_argb.h +37 -37
  53. package/android/src/main/cpp/libyuv/include/libyuv/rotate_row.h +265 -265
  54. package/android/src/main/cpp/libyuv/include/libyuv/row.h +6738 -6738
  55. package/android/src/main/cpp/libyuv/include/libyuv/row_sve.h +2154 -2154
  56. package/android/src/main/cpp/libyuv/include/libyuv/scale.h +336 -336
  57. package/android/src/main/cpp/libyuv/include/libyuv/scale_argb.h +76 -76
  58. package/android/src/main/cpp/libyuv/include/libyuv/scale_rgb.h +42 -42
  59. package/android/src/main/cpp/libyuv/include/libyuv/scale_row.h +1726 -1726
  60. package/android/src/main/cpp/libyuv/include/libyuv/scale_uv.h +51 -51
  61. package/android/src/main/cpp/libyuv/include/libyuv/version.h +16 -16
  62. package/android/src/main/cpp/libyuv/include/libyuv/video_common.h +222 -222
  63. package/android/src/main/cpp/libyuv/include/libyuv.h +33 -33
  64. package/android/src/main/cpp/libyuv/infra/config/OWNERS +3 -3
  65. package/android/src/main/cpp/libyuv/infra/config/PRESUBMIT.py +17 -17
  66. package/android/src/main/cpp/libyuv/infra/config/README.md +2 -2
  67. package/android/src/main/cpp/libyuv/infra/config/codereview.settings +6 -6
  68. package/android/src/main/cpp/libyuv/infra/config/commit-queue.cfg +144 -144
  69. package/android/src/main/cpp/libyuv/infra/config/cr-buildbucket.cfg +1185 -1185
  70. package/android/src/main/cpp/libyuv/infra/config/luci-logdog.cfg +9 -9
  71. package/android/src/main/cpp/libyuv/infra/config/luci-milo.cfg +246 -246
  72. package/android/src/main/cpp/libyuv/infra/config/luci-scheduler.cfg +385 -385
  73. package/android/src/main/cpp/libyuv/infra/config/main.star +402 -402
  74. package/android/src/main/cpp/libyuv/infra/config/project.cfg +16 -16
  75. package/android/src/main/cpp/libyuv/infra/config/realms.cfg +111 -111
  76. package/android/src/main/cpp/libyuv/libyuv.gni +34 -34
  77. package/android/src/main/cpp/libyuv/libyuv.gyp +149 -149
  78. package/android/src/main/cpp/libyuv/libyuv.gypi +87 -87
  79. package/android/src/main/cpp/libyuv/linux.mk +96 -96
  80. package/android/src/main/cpp/libyuv/public.mk +13 -13
  81. package/android/src/main/cpp/libyuv/pylintrc +49 -49
  82. package/android/src/main/cpp/libyuv/riscv_script/prepare_toolchain_qemu.sh +74 -74
  83. package/android/src/main/cpp/libyuv/riscv_script/riscv-clang.cmake +56 -56
  84. package/android/src/main/cpp/libyuv/riscv_script/run_qemu.sh +15 -15
  85. package/android/src/main/cpp/libyuv/source/compare.cc +435 -435
  86. package/android/src/main/cpp/libyuv/source/compare_common.cc +74 -74
  87. package/android/src/main/cpp/libyuv/source/compare_gcc.cc +362 -362
  88. package/android/src/main/cpp/libyuv/source/compare_neon.cc +96 -96
  89. package/android/src/main/cpp/libyuv/source/compare_neon64.cc +223 -223
  90. package/android/src/main/cpp/libyuv/source/compare_win.cc +241 -241
  91. package/android/src/main/cpp/libyuv/source/convert.cc +4746 -4746
  92. package/android/src/main/cpp/libyuv/source/convert_argb.cc +9179 -9179
  93. package/android/src/main/cpp/libyuv/source/convert_from.cc +866 -866
  94. package/android/src/main/cpp/libyuv/source/convert_from_argb.cc +3671 -3671
  95. package/android/src/main/cpp/libyuv/source/convert_jpeg.cc +602 -602
  96. package/android/src/main/cpp/libyuv/source/convert_to_argb.cc +391 -391
  97. package/android/src/main/cpp/libyuv/source/convert_to_i420.cc +288 -288
  98. package/android/src/main/cpp/libyuv/source/cpu_id.cc +496 -496
  99. package/android/src/main/cpp/libyuv/source/mjpeg_decoder.cc +580 -580
  100. package/android/src/main/cpp/libyuv/source/mjpeg_validate.cc +71 -71
  101. package/android/src/main/cpp/libyuv/source/planar_functions.cc +5663 -5663
  102. package/android/src/main/cpp/libyuv/source/rotate.cc +1241 -1241
  103. package/android/src/main/cpp/libyuv/source/rotate_any.cc +76 -76
  104. package/android/src/main/cpp/libyuv/source/rotate_argb.cc +259 -259
  105. package/android/src/main/cpp/libyuv/source/rotate_common.cc +208 -208
  106. package/android/src/main/cpp/libyuv/source/rotate_gcc.cc +505 -505
  107. package/android/src/main/cpp/libyuv/source/rotate_lsx.cc +233 -233
  108. package/android/src/main/cpp/libyuv/source/rotate_neon.cc +219 -219
  109. package/android/src/main/cpp/libyuv/source/rotate_neon64.cc +273 -273
  110. package/android/src/main/cpp/libyuv/source/rotate_sme.cc +174 -174
  111. package/android/src/main/cpp/libyuv/source/rotate_win.cc +253 -253
  112. package/android/src/main/cpp/libyuv/source/row_any.cc +2519 -2519
  113. package/android/src/main/cpp/libyuv/source/row_common.cc +4461 -4461
  114. package/android/src/main/cpp/libyuv/source/row_gcc.cc +9570 -9570
  115. package/android/src/main/cpp/libyuv/source/row_lasx.cc +2343 -2343
  116. package/android/src/main/cpp/libyuv/source/row_lsx.cc +3030 -3030
  117. package/android/src/main/cpp/libyuv/source/row_neon.cc +4026 -4026
  118. package/android/src/main/cpp/libyuv/source/row_neon64.cc +5617 -5617
  119. package/android/src/main/cpp/libyuv/source/row_rvv.cc +2599 -2599
  120. package/android/src/main/cpp/libyuv/source/row_sme.cc +1183 -1183
  121. package/android/src/main/cpp/libyuv/source/row_sve.cc +1088 -1088
  122. package/android/src/main/cpp/libyuv/source/row_win.cc +6453 -6453
  123. package/android/src/main/cpp/libyuv/source/scale.cc +2710 -2710
  124. package/android/src/main/cpp/libyuv/source/scale_any.cc +991 -991
  125. package/android/src/main/cpp/libyuv/source/scale_argb.cc +1158 -1158
  126. package/android/src/main/cpp/libyuv/source/scale_common.cc +1977 -1977
  127. package/android/src/main/cpp/libyuv/source/scale_gcc.cc +2947 -2947
  128. package/android/src/main/cpp/libyuv/source/scale_lsx.cc +739 -739
  129. package/android/src/main/cpp/libyuv/source/scale_neon.cc +1449 -1449
  130. package/android/src/main/cpp/libyuv/source/scale_neon64.cc +1552 -1552
  131. package/android/src/main/cpp/libyuv/source/scale_rgb.cc +82 -82
  132. package/android/src/main/cpp/libyuv/source/scale_rvv.cc +1971 -1971
  133. package/android/src/main/cpp/libyuv/source/scale_sme.cc +555 -555
  134. package/android/src/main/cpp/libyuv/source/scale_uv.cc +1159 -1159
  135. package/android/src/main/cpp/libyuv/source/scale_win.cc +1392 -1392
  136. package/android/src/main/cpp/libyuv/source/test.sh +35 -35
  137. package/android/src/main/cpp/libyuv/source/video_common.cc +62 -62
  138. package/android/src/main/cpp/libyuv/tools_libyuv/OWNERS +4 -4
  139. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/roll_deps.py +931 -931
  140. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/roll_deps_test.py +164 -164
  141. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS +21 -21
  142. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.new +13 -13
  143. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.old +13 -13
  144. package/android/src/main/cpp/libyuv/tools_libyuv/get_landmines.py +38 -38
  145. package/android/src/main/cpp/libyuv/tools_libyuv/msan/OWNERS +3 -3
  146. package/android/src/main/cpp/libyuv/tools_libyuv/msan/blacklist.txt +9 -9
  147. package/android/src/main/cpp/libyuv/tools_libyuv/ubsan/OWNERS +3 -3
  148. package/android/src/main/cpp/libyuv/tools_libyuv/ubsan/blacklist.txt +15 -15
  149. package/android/src/main/cpp/libyuv/tools_libyuv/ubsan/vptr_blacklist.txt +25 -25
  150. package/android/src/main/cpp/libyuv/unit_test/basictypes_test.cc +43 -43
  151. package/android/src/main/cpp/libyuv/unit_test/color_test.cc +848 -848
  152. package/android/src/main/cpp/libyuv/unit_test/compare_test.cc +739 -739
  153. package/android/src/main/cpp/libyuv/unit_test/convert_argb_test.cc +2867 -2867
  154. package/android/src/main/cpp/libyuv/unit_test/convert_test.cc +2133 -2133
  155. package/android/src/main/cpp/libyuv/unit_test/cpu_test.cc +427 -427
  156. package/android/src/main/cpp/libyuv/unit_test/cpu_thread_test.cc +63 -63
  157. package/android/src/main/cpp/libyuv/unit_test/math_test.cc +160 -160
  158. package/android/src/main/cpp/libyuv/unit_test/planar_test.cc +4731 -4731
  159. package/android/src/main/cpp/libyuv/unit_test/rotate_argb_test.cc +334 -334
  160. package/android/src/main/cpp/libyuv/unit_test/rotate_test.cc +962 -962
  161. package/android/src/main/cpp/libyuv/unit_test/scale_argb_test.cc +590 -590
  162. package/android/src/main/cpp/libyuv/unit_test/scale_plane_test.cc +465 -465
  163. package/android/src/main/cpp/libyuv/unit_test/scale_rgb_test.cc +280 -280
  164. package/android/src/main/cpp/libyuv/unit_test/scale_test.cc +1135 -1135
  165. package/android/src/main/cpp/libyuv/unit_test/scale_uv_test.cc +249 -249
  166. package/android/src/main/cpp/libyuv/unit_test/testdata/arm_v7.txt +12 -12
  167. package/android/src/main/cpp/libyuv/unit_test/testdata/mips.txt +7 -7
  168. package/android/src/main/cpp/libyuv/unit_test/testdata/mips_loongson2k.txt +5 -5
  169. package/android/src/main/cpp/libyuv/unit_test/testdata/mips_loongson3.txt +10 -10
  170. package/android/src/main/cpp/libyuv/unit_test/testdata/mips_loongson_mmi.txt +7 -7
  171. package/android/src/main/cpp/libyuv/unit_test/testdata/riscv64.txt +3 -3
  172. package/android/src/main/cpp/libyuv/unit_test/testdata/riscv64_rvv.txt +3 -3
  173. package/android/src/main/cpp/libyuv/unit_test/testdata/riscv64_rvv_zvfh.txt +3 -3
  174. package/android/src/main/cpp/libyuv/unit_test/testdata/tegra3.txt +23 -23
  175. package/android/src/main/cpp/libyuv/unit_test/unit_test.cc +581 -581
  176. package/android/src/main/cpp/libyuv/unit_test/unit_test.h +232 -232
  177. package/android/src/main/cpp/libyuv/unit_test/video_common_test.cc +112 -112
  178. package/android/src/main/cpp/libyuv/util/Makefile +9 -9
  179. package/android/src/main/cpp/libyuv/util/color.cc +120 -120
  180. package/android/src/main/cpp/libyuv/util/compare.cc +67 -67
  181. package/android/src/main/cpp/libyuv/util/cpuid.c +211 -211
  182. package/android/src/main/cpp/libyuv/util/i444tonv12_eg.cc +27 -27
  183. package/android/src/main/cpp/libyuv/util/psnr.cc +291 -291
  184. package/android/src/main/cpp/libyuv/util/psnr.h +47 -47
  185. package/android/src/main/cpp/libyuv/util/psnr_main.cc +620 -620
  186. package/android/src/main/cpp/libyuv/util/ssim.cc +364 -364
  187. package/android/src/main/cpp/libyuv/util/ssim.h +38 -38
  188. package/android/src/main/cpp/libyuv/util/yuvconstants.c +114 -114
  189. package/android/src/main/cpp/libyuv/util/yuvconvert.cc +367 -367
  190. package/android/src/main/cpp/libyuv/winarm.mk +47 -47
  191. package/index.js +17 -1
  192. package/ios/FaceAntiSpoofFrameProcessor.swift +283 -0
  193. package/ios/FaceAntiSpoofJSI.h +12 -0
  194. package/ios/FaceAntiSpoofJSI.mm +92 -0
  195. package/ios/FaceAntiSpoofManager.swift +63 -0
  196. package/ios/FaceAntiSpoofModule.m +191 -0
  197. package/ios/FaceAntiSpoofPluginRegister.m +42 -0
  198. package/ios/models/FaceAntiSpoofing.tflite +0 -0
  199. package/ios/models/model_spec.json +16 -0
  200. package/package.json +87 -86
  201. package/.gitignore +0 -27
  202. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  203. package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  204. package/android/.gradle/8.9/gc.properties +0 -0
  205. /package/android/.gradle/{8.9 → 9.2.0}/fileChanges/last-build.bin +0 -0
  206. /package/android/.gradle/{8.9/dependencies-accessors → 9.2.0}/gc.properties +0 -0
@@ -1,581 +1,581 @@
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
- #include "../unit_test/unit_test.h"
12
-
13
- #include <stdlib.h> // For getenv()
14
-
15
- #include <cstring>
16
-
17
- #ifdef LIBYUV_USE_ABSL_FLAGS
18
- #include "absl/flags/flag.h"
19
- #include "absl/flags/parse.h"
20
- #endif
21
- #include "libyuv/cpu_id.h"
22
-
23
- unsigned int fastrand_seed = 0xfb;
24
-
25
- #ifdef LIBYUV_USE_ABSL_FLAGS
26
- ABSL_FLAG(int32_t, libyuv_width, 0, "width of test image.");
27
- ABSL_FLAG(int32_t, libyuv_height, 0, "height of test image.");
28
- ABSL_FLAG(int32_t, libyuv_repeat, 0, "number of times to repeat test.");
29
- ABSL_FLAG(int32_t,
30
- libyuv_flags,
31
- 0,
32
- "cpu flags for reference code. 1 = C, -1 = SIMD");
33
- ABSL_FLAG(int32_t,
34
- libyuv_cpu_info,
35
- 0,
36
- "cpu flags for benchmark code. 1 = C, -1 = SIMD");
37
- #else
38
- // Disable command line parameters if absl/flags disabled.
39
- static const int32_t FLAGS_libyuv_width = 0;
40
- static const int32_t FLAGS_libyuv_height = 0;
41
- static const int32_t FLAGS_libyuv_repeat = 0;
42
- static const int32_t FLAGS_libyuv_flags = 0;
43
- static const int32_t FLAGS_libyuv_cpu_info = 0;
44
- #endif
45
-
46
- #ifdef LIBYUV_USE_ABSL_FLAGS
47
- #define LIBYUV_GET_FLAG(f) absl::GetFlag(f)
48
- #else
49
- #define LIBYUV_GET_FLAG(f) f
50
- #endif
51
-
52
- // Test environment variable for disabling CPU features. Any non-zero value
53
- // to disable. Zero ignored to make it easy to set the variable on/off.
54
- #if !defined(__native_client__) && !defined(_M_ARM)
55
- static LIBYUV_BOOL TestEnv(const char* name) {
56
- const char* var = getenv(name);
57
- if (var) {
58
- if (var[0] != '0') {
59
- return LIBYUV_TRUE;
60
- }
61
- }
62
- return LIBYUV_FALSE;
63
- }
64
- #else // nacl does not support getenv().
65
- static LIBYUV_BOOL TestEnv(const char*) {
66
- return LIBYUV_FALSE;
67
- }
68
- #endif
69
-
70
- static int TestCpuEnv(int cpu_info) {
71
- #if defined(__arm__) || defined(__aarch64__)
72
- if (TestEnv("LIBYUV_DISABLE_NEON")) {
73
- cpu_info &= ~libyuv::kCpuHasNEON;
74
- }
75
- #endif
76
- #if defined(__aarch64__)
77
- if (TestEnv("LIBYUV_DISABLE_NEON_DOTPROD")) {
78
- cpu_info &= ~libyuv::kCpuHasNeonDotProd;
79
- }
80
- if (TestEnv("LIBYUV_DISABLE_NEON_I8MM")) {
81
- cpu_info &= ~libyuv::kCpuHasNeonI8MM;
82
- }
83
- if (TestEnv("LIBYUV_DISABLE_SVE")) {
84
- cpu_info &= ~libyuv::kCpuHasSVE;
85
- }
86
- if (TestEnv("LIBYUV_DISABLE_SVE2")) {
87
- cpu_info &= ~libyuv::kCpuHasSVE2;
88
- }
89
- if (TestEnv("LIBYUV_DISABLE_SME")) {
90
- cpu_info &= ~libyuv::kCpuHasSME;
91
- }
92
- #endif
93
- #if defined(__longarch__) && defined(__linux__)
94
- if (TestEnv("LIBYUV_DISABLE_LSX")) {
95
- cpu_info &= ~libyuv::kCpuHasLSX;
96
- }
97
- if (TestEnv("LIBYUV_DISABLE_LASX")) {
98
- cpu_info &= ~libyuv::kCpuHasLASX;
99
- }
100
- #endif
101
- #if defined(__riscv) && defined(__linux__)
102
- if (TestEnv("LIBYUV_DISABLE_RVV")) {
103
- cpu_info &= ~libyuv::kCpuHasRVV;
104
- }
105
- #endif
106
- #if !defined(__pnacl__) && !defined(__CLR_VER) && \
107
- (defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || \
108
- defined(_M_IX86))
109
- if (TestEnv("LIBYUV_DISABLE_X86")) {
110
- cpu_info &= ~libyuv::kCpuHasX86;
111
- }
112
- if (TestEnv("LIBYUV_DISABLE_SSE2")) {
113
- cpu_info &= ~libyuv::kCpuHasSSE2;
114
- }
115
- if (TestEnv("LIBYUV_DISABLE_SSSE3")) {
116
- cpu_info &= ~libyuv::kCpuHasSSSE3;
117
- }
118
- if (TestEnv("LIBYUV_DISABLE_SSE41")) {
119
- cpu_info &= ~libyuv::kCpuHasSSE41;
120
- }
121
- if (TestEnv("LIBYUV_DISABLE_SSE42")) {
122
- cpu_info &= ~libyuv::kCpuHasSSE42;
123
- }
124
- if (TestEnv("LIBYUV_DISABLE_AVX")) {
125
- cpu_info &= ~libyuv::kCpuHasAVX;
126
- }
127
- if (TestEnv("LIBYUV_DISABLE_AVX2")) {
128
- cpu_info &= ~libyuv::kCpuHasAVX2;
129
- }
130
- if (TestEnv("LIBYUV_DISABLE_ERMS")) {
131
- cpu_info &= ~libyuv::kCpuHasERMS;
132
- }
133
- if (TestEnv("LIBYUV_DISABLE_FMA3")) {
134
- cpu_info &= ~libyuv::kCpuHasFMA3;
135
- }
136
- if (TestEnv("LIBYUV_DISABLE_F16C")) {
137
- cpu_info &= ~libyuv::kCpuHasF16C;
138
- }
139
- if (TestEnv("LIBYUV_DISABLE_AVX512BW")) {
140
- cpu_info &= ~libyuv::kCpuHasAVX512BW;
141
- }
142
- if (TestEnv("LIBYUV_DISABLE_AVX512VL")) {
143
- cpu_info &= ~libyuv::kCpuHasAVX512VL;
144
- }
145
- if (TestEnv("LIBYUV_DISABLE_AVX512VNNI")) {
146
- cpu_info &= ~libyuv::kCpuHasAVX512VNNI;
147
- }
148
- if (TestEnv("LIBYUV_DISABLE_AVX512VBMI")) {
149
- cpu_info &= ~libyuv::kCpuHasAVX512VBMI;
150
- }
151
- if (TestEnv("LIBYUV_DISABLE_AVX512VBMI2")) {
152
- cpu_info &= ~libyuv::kCpuHasAVX512VBMI2;
153
- }
154
- if (TestEnv("LIBYUV_DISABLE_AVX512VBITALG")) {
155
- cpu_info &= ~libyuv::kCpuHasAVX512VBITALG;
156
- }
157
- if (TestEnv("LIBYUV_DISABLE_AVX10")) {
158
- cpu_info &= ~libyuv::kCpuHasAVX10;
159
- }
160
- if (TestEnv("LIBYUV_DISABLE_AVX10_2")) {
161
- cpu_info &= ~libyuv::kCpuHasAVX10_2;
162
- }
163
- if (TestEnv("LIBYUV_DISABLE_AVXVNNI")) {
164
- cpu_info &= ~libyuv::kCpuHasAVXVNNI;
165
- }
166
- if (TestEnv("LIBYUV_DISABLE_AVXVNNIINT8")) {
167
- cpu_info &= ~libyuv::kCpuHasAVXVNNIINT8;
168
- }
169
- if (TestEnv("LIBYUV_DISABLE_AMXINT8")) {
170
- cpu_info &= ~libyuv::kCpuHasAMXINT8;
171
- }
172
- #endif
173
- if (TestEnv("LIBYUV_DISABLE_ASM")) {
174
- cpu_info = libyuv::kCpuInitialized;
175
- }
176
- return cpu_info;
177
- }
178
-
179
- // For quicker unittests, default is 128 x 72. But when benchmarking,
180
- // default to 720p. Allow size to specify.
181
- // Set flags to -1 for benchmarking to avoid slower C code.
182
-
183
- LibYUVConvertTest::LibYUVConvertTest()
184
- : benchmark_iterations_(1),
185
- benchmark_width_(128),
186
- benchmark_height_(72),
187
- disable_cpu_flags_(1),
188
- benchmark_cpu_info_(-1) {
189
- const char* repeat = getenv("LIBYUV_REPEAT");
190
- if (repeat) {
191
- benchmark_iterations_ = atoi(repeat); // NOLINT
192
- }
193
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_repeat)) {
194
- benchmark_iterations_ = LIBYUV_GET_FLAG(FLAGS_libyuv_repeat);
195
- }
196
- if (benchmark_iterations_ > 1) {
197
- benchmark_width_ = 1280;
198
- benchmark_height_ = 720;
199
- }
200
- const char* width = getenv("LIBYUV_WIDTH");
201
- if (width) {
202
- benchmark_width_ = atoi(width); // NOLINT
203
- }
204
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_width)) {
205
- benchmark_width_ = LIBYUV_GET_FLAG(FLAGS_libyuv_width);
206
- }
207
- const char* height = getenv("LIBYUV_HEIGHT");
208
- if (height) {
209
- benchmark_height_ = atoi(height); // NOLINT
210
- }
211
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_height)) {
212
- benchmark_height_ = LIBYUV_GET_FLAG(FLAGS_libyuv_height);
213
- }
214
- const char* cpu_flags = getenv("LIBYUV_FLAGS");
215
- if (cpu_flags) {
216
- disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
217
- }
218
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_flags)) {
219
- disable_cpu_flags_ = LIBYUV_GET_FLAG(FLAGS_libyuv_flags);
220
- }
221
- const char* cpu_info = getenv("LIBYUV_CPU_INFO");
222
- if (cpu_info) {
223
- benchmark_cpu_info_ = atoi(cpu_info); // NOLINT
224
- }
225
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info)) {
226
- benchmark_cpu_info_ = LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info);
227
- }
228
- disable_cpu_flags_ = TestCpuEnv(disable_cpu_flags_);
229
- benchmark_cpu_info_ = TestCpuEnv(benchmark_cpu_info_);
230
- libyuv::MaskCpuFlags(benchmark_cpu_info_);
231
- benchmark_pixels_div1280_ =
232
- static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
233
- static_cast<double>(Abs(benchmark_height_)) *
234
- static_cast<double>(benchmark_iterations_) +
235
- 1279.0) /
236
- 1280.0);
237
- }
238
-
239
- LibYUVColorTest::LibYUVColorTest()
240
- : benchmark_iterations_(1),
241
- benchmark_width_(128),
242
- benchmark_height_(72),
243
- disable_cpu_flags_(1),
244
- benchmark_cpu_info_(-1) {
245
- const char* repeat = getenv("LIBYUV_REPEAT");
246
- if (repeat) {
247
- benchmark_iterations_ = atoi(repeat); // NOLINT
248
- }
249
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_repeat)) {
250
- benchmark_iterations_ = LIBYUV_GET_FLAG(FLAGS_libyuv_repeat);
251
- }
252
- if (benchmark_iterations_ > 1) {
253
- benchmark_width_ = 1280;
254
- benchmark_height_ = 720;
255
- }
256
- const char* width = getenv("LIBYUV_WIDTH");
257
- if (width) {
258
- benchmark_width_ = atoi(width); // NOLINT
259
- }
260
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_width)) {
261
- benchmark_width_ = LIBYUV_GET_FLAG(FLAGS_libyuv_width);
262
- }
263
- const char* height = getenv("LIBYUV_HEIGHT");
264
- if (height) {
265
- benchmark_height_ = atoi(height); // NOLINT
266
- }
267
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_height)) {
268
- benchmark_height_ = LIBYUV_GET_FLAG(FLAGS_libyuv_height);
269
- }
270
- const char* cpu_flags = getenv("LIBYUV_FLAGS");
271
- if (cpu_flags) {
272
- disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
273
- }
274
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_flags)) {
275
- disable_cpu_flags_ = LIBYUV_GET_FLAG(FLAGS_libyuv_flags);
276
- }
277
- const char* cpu_info = getenv("LIBYUV_CPU_INFO");
278
- if (cpu_info) {
279
- benchmark_cpu_info_ = atoi(cpu_info); // NOLINT
280
- }
281
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info)) {
282
- benchmark_cpu_info_ = LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info);
283
- }
284
- disable_cpu_flags_ = TestCpuEnv(disable_cpu_flags_);
285
- benchmark_cpu_info_ = TestCpuEnv(benchmark_cpu_info_);
286
- libyuv::MaskCpuFlags(benchmark_cpu_info_);
287
- benchmark_pixels_div1280_ =
288
- static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
289
- static_cast<double>(Abs(benchmark_height_)) *
290
- static_cast<double>(benchmark_iterations_) +
291
- 1279.0) /
292
- 1280.0);
293
- }
294
-
295
- LibYUVScaleTest::LibYUVScaleTest()
296
- : benchmark_iterations_(1),
297
- benchmark_width_(128),
298
- benchmark_height_(72),
299
- disable_cpu_flags_(1),
300
- benchmark_cpu_info_(-1) {
301
- const char* repeat = getenv("LIBYUV_REPEAT");
302
- if (repeat) {
303
- benchmark_iterations_ = atoi(repeat); // NOLINT
304
- }
305
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_repeat)) {
306
- benchmark_iterations_ = LIBYUV_GET_FLAG(FLAGS_libyuv_repeat);
307
- }
308
- if (benchmark_iterations_ > 1) {
309
- benchmark_width_ = 1280;
310
- benchmark_height_ = 720;
311
- }
312
- const char* width = getenv("LIBYUV_WIDTH");
313
- if (width) {
314
- benchmark_width_ = atoi(width); // NOLINT
315
- }
316
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_width)) {
317
- benchmark_width_ = LIBYUV_GET_FLAG(FLAGS_libyuv_width);
318
- }
319
- const char* height = getenv("LIBYUV_HEIGHT");
320
- if (height) {
321
- benchmark_height_ = atoi(height); // NOLINT
322
- }
323
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_height)) {
324
- benchmark_height_ = LIBYUV_GET_FLAG(FLAGS_libyuv_height);
325
- }
326
- const char* cpu_flags = getenv("LIBYUV_FLAGS");
327
- if (cpu_flags) {
328
- disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
329
- }
330
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_flags)) {
331
- disable_cpu_flags_ = LIBYUV_GET_FLAG(FLAGS_libyuv_flags);
332
- }
333
- const char* cpu_info = getenv("LIBYUV_CPU_INFO");
334
- if (cpu_info) {
335
- benchmark_cpu_info_ = atoi(cpu_info); // NOLINT
336
- }
337
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info)) {
338
- benchmark_cpu_info_ = LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info);
339
- }
340
- disable_cpu_flags_ = TestCpuEnv(disable_cpu_flags_);
341
- benchmark_cpu_info_ = TestCpuEnv(benchmark_cpu_info_);
342
- libyuv::MaskCpuFlags(benchmark_cpu_info_);
343
- benchmark_pixels_div1280_ =
344
- static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
345
- static_cast<double>(Abs(benchmark_height_)) *
346
- static_cast<double>(benchmark_iterations_) +
347
- 1279.0) /
348
- 1280.0);
349
- }
350
-
351
- LibYUVRotateTest::LibYUVRotateTest()
352
- : benchmark_iterations_(1),
353
- benchmark_width_(128),
354
- benchmark_height_(72),
355
- disable_cpu_flags_(1),
356
- benchmark_cpu_info_(-1) {
357
- const char* repeat = getenv("LIBYUV_REPEAT");
358
- if (repeat) {
359
- benchmark_iterations_ = atoi(repeat); // NOLINT
360
- }
361
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_repeat)) {
362
- benchmark_iterations_ = LIBYUV_GET_FLAG(FLAGS_libyuv_repeat);
363
- }
364
- if (benchmark_iterations_ > 1) {
365
- benchmark_width_ = 1280;
366
- benchmark_height_ = 720;
367
- }
368
- const char* width = getenv("LIBYUV_WIDTH");
369
- if (width) {
370
- benchmark_width_ = atoi(width); // NOLINT
371
- }
372
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_width)) {
373
- benchmark_width_ = LIBYUV_GET_FLAG(FLAGS_libyuv_width);
374
- }
375
- const char* height = getenv("LIBYUV_HEIGHT");
376
- if (height) {
377
- benchmark_height_ = atoi(height); // NOLINT
378
- }
379
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_height)) {
380
- benchmark_height_ = LIBYUV_GET_FLAG(FLAGS_libyuv_height);
381
- }
382
- const char* cpu_flags = getenv("LIBYUV_FLAGS");
383
- if (cpu_flags) {
384
- disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
385
- }
386
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_flags)) {
387
- disable_cpu_flags_ = LIBYUV_GET_FLAG(FLAGS_libyuv_flags);
388
- }
389
- const char* cpu_info = getenv("LIBYUV_CPU_INFO");
390
- if (cpu_info) {
391
- benchmark_cpu_info_ = atoi(cpu_info); // NOLINT
392
- }
393
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info)) {
394
- benchmark_cpu_info_ = LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info);
395
- }
396
- disable_cpu_flags_ = TestCpuEnv(disable_cpu_flags_);
397
- benchmark_cpu_info_ = TestCpuEnv(benchmark_cpu_info_);
398
- libyuv::MaskCpuFlags(benchmark_cpu_info_);
399
- benchmark_pixels_div1280_ =
400
- static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
401
- static_cast<double>(Abs(benchmark_height_)) *
402
- static_cast<double>(benchmark_iterations_) +
403
- 1279.0) /
404
- 1280.0);
405
- }
406
-
407
- LibYUVPlanarTest::LibYUVPlanarTest()
408
- : benchmark_iterations_(1),
409
- benchmark_width_(128),
410
- benchmark_height_(72),
411
- disable_cpu_flags_(1),
412
- benchmark_cpu_info_(-1) {
413
- const char* repeat = getenv("LIBYUV_REPEAT");
414
- if (repeat) {
415
- benchmark_iterations_ = atoi(repeat); // NOLINT
416
- }
417
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_repeat)) {
418
- benchmark_iterations_ = LIBYUV_GET_FLAG(FLAGS_libyuv_repeat);
419
- }
420
- if (benchmark_iterations_ > 1) {
421
- benchmark_width_ = 1280;
422
- benchmark_height_ = 720;
423
- }
424
- const char* width = getenv("LIBYUV_WIDTH");
425
- if (width) {
426
- benchmark_width_ = atoi(width); // NOLINT
427
- }
428
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_width)) {
429
- benchmark_width_ = LIBYUV_GET_FLAG(FLAGS_libyuv_width);
430
- }
431
- const char* height = getenv("LIBYUV_HEIGHT");
432
- if (height) {
433
- benchmark_height_ = atoi(height); // NOLINT
434
- }
435
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_height)) {
436
- benchmark_height_ = LIBYUV_GET_FLAG(FLAGS_libyuv_height);
437
- }
438
- const char* cpu_flags = getenv("LIBYUV_FLAGS");
439
- if (cpu_flags) {
440
- disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
441
- }
442
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_flags)) {
443
- disable_cpu_flags_ = LIBYUV_GET_FLAG(FLAGS_libyuv_flags);
444
- }
445
- const char* cpu_info = getenv("LIBYUV_CPU_INFO");
446
- if (cpu_info) {
447
- benchmark_cpu_info_ = atoi(cpu_info); // NOLINT
448
- }
449
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info)) {
450
- benchmark_cpu_info_ = LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info);
451
- }
452
- disable_cpu_flags_ = TestCpuEnv(disable_cpu_flags_);
453
- benchmark_cpu_info_ = TestCpuEnv(benchmark_cpu_info_);
454
- libyuv::MaskCpuFlags(benchmark_cpu_info_);
455
- benchmark_pixels_div1280_ =
456
- static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
457
- static_cast<double>(Abs(benchmark_height_)) *
458
- static_cast<double>(benchmark_iterations_) +
459
- 1279.0) /
460
- 1280.0);
461
- }
462
-
463
- LibYUVBaseTest::LibYUVBaseTest()
464
- : benchmark_iterations_(1),
465
- benchmark_width_(128),
466
- benchmark_height_(72),
467
- disable_cpu_flags_(1),
468
- benchmark_cpu_info_(-1) {
469
- const char* repeat = getenv("LIBYUV_REPEAT");
470
- if (repeat) {
471
- benchmark_iterations_ = atoi(repeat); // NOLINT
472
- }
473
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_repeat)) {
474
- benchmark_iterations_ = LIBYUV_GET_FLAG(FLAGS_libyuv_repeat);
475
- }
476
- if (benchmark_iterations_ > 1) {
477
- benchmark_width_ = 1280;
478
- benchmark_height_ = 720;
479
- }
480
- const char* width = getenv("LIBYUV_WIDTH");
481
- if (width) {
482
- benchmark_width_ = atoi(width); // NOLINT
483
- }
484
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_width)) {
485
- benchmark_width_ = LIBYUV_GET_FLAG(FLAGS_libyuv_width);
486
- }
487
- const char* height = getenv("LIBYUV_HEIGHT");
488
- if (height) {
489
- benchmark_height_ = atoi(height); // NOLINT
490
- }
491
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_height)) {
492
- benchmark_height_ = LIBYUV_GET_FLAG(FLAGS_libyuv_height);
493
- }
494
- const char* cpu_flags = getenv("LIBYUV_FLAGS");
495
- if (cpu_flags) {
496
- disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
497
- }
498
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_flags)) {
499
- disable_cpu_flags_ = LIBYUV_GET_FLAG(FLAGS_libyuv_flags);
500
- }
501
- const char* cpu_info = getenv("LIBYUV_CPU_INFO");
502
- if (cpu_info) {
503
- benchmark_cpu_info_ = atoi(cpu_info); // NOLINT
504
- }
505
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info)) {
506
- benchmark_cpu_info_ = LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info);
507
- }
508
- disable_cpu_flags_ = TestCpuEnv(disable_cpu_flags_);
509
- benchmark_cpu_info_ = TestCpuEnv(benchmark_cpu_info_);
510
- libyuv::MaskCpuFlags(benchmark_cpu_info_);
511
- benchmark_pixels_div1280_ =
512
- static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
513
- static_cast<double>(Abs(benchmark_height_)) *
514
- static_cast<double>(benchmark_iterations_) +
515
- 1279.0) /
516
- 1280.0);
517
- }
518
-
519
- LibYUVCompareTest::LibYUVCompareTest()
520
- : benchmark_iterations_(1),
521
- benchmark_width_(128),
522
- benchmark_height_(72),
523
- disable_cpu_flags_(1),
524
- benchmark_cpu_info_(-1) {
525
- const char* repeat = getenv("LIBYUV_REPEAT");
526
- if (repeat) {
527
- benchmark_iterations_ = atoi(repeat); // NOLINT
528
- }
529
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_repeat)) {
530
- benchmark_iterations_ = LIBYUV_GET_FLAG(FLAGS_libyuv_repeat);
531
- }
532
- if (benchmark_iterations_ > 1) {
533
- benchmark_width_ = 1280;
534
- benchmark_height_ = 720;
535
- }
536
- const char* width = getenv("LIBYUV_WIDTH");
537
- if (width) {
538
- benchmark_width_ = atoi(width); // NOLINT
539
- }
540
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_width)) {
541
- benchmark_width_ = LIBYUV_GET_FLAG(FLAGS_libyuv_width);
542
- }
543
- const char* height = getenv("LIBYUV_HEIGHT");
544
- if (height) {
545
- benchmark_height_ = atoi(height); // NOLINT
546
- }
547
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_height)) {
548
- benchmark_height_ = LIBYUV_GET_FLAG(FLAGS_libyuv_height);
549
- }
550
- const char* cpu_flags = getenv("LIBYUV_FLAGS");
551
- if (cpu_flags) {
552
- disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
553
- }
554
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_flags)) {
555
- disable_cpu_flags_ = LIBYUV_GET_FLAG(FLAGS_libyuv_flags);
556
- }
557
- const char* cpu_info = getenv("LIBYUV_CPU_INFO");
558
- if (cpu_info) {
559
- benchmark_cpu_info_ = atoi(cpu_info); // NOLINT
560
- }
561
- if (LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info)) {
562
- benchmark_cpu_info_ = LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info);
563
- }
564
- disable_cpu_flags_ = TestCpuEnv(disable_cpu_flags_);
565
- benchmark_cpu_info_ = TestCpuEnv(benchmark_cpu_info_);
566
- libyuv::MaskCpuFlags(benchmark_cpu_info_);
567
- benchmark_pixels_div1280_ =
568
- static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
569
- static_cast<double>(Abs(benchmark_height_)) *
570
- static_cast<double>(benchmark_iterations_) +
571
- 1279.0) /
572
- 1280.0);
573
- }
574
-
575
- int main(int argc, char** argv) {
576
- ::testing::InitGoogleTest(&argc, argv);
577
- #ifdef LIBYUV_USE_ABSL_FLAGS
578
- absl::ParseCommandLine(argc, argv);
579
- #endif
580
- return RUN_ALL_TESTS();
581
- }
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
+ #include "../unit_test/unit_test.h"
12
+
13
+ #include <stdlib.h> // For getenv()
14
+
15
+ #include <cstring>
16
+
17
+ #ifdef LIBYUV_USE_ABSL_FLAGS
18
+ #include "absl/flags/flag.h"
19
+ #include "absl/flags/parse.h"
20
+ #endif
21
+ #include "libyuv/cpu_id.h"
22
+
23
+ unsigned int fastrand_seed = 0xfb;
24
+
25
+ #ifdef LIBYUV_USE_ABSL_FLAGS
26
+ ABSL_FLAG(int32_t, libyuv_width, 0, "width of test image.");
27
+ ABSL_FLAG(int32_t, libyuv_height, 0, "height of test image.");
28
+ ABSL_FLAG(int32_t, libyuv_repeat, 0, "number of times to repeat test.");
29
+ ABSL_FLAG(int32_t,
30
+ libyuv_flags,
31
+ 0,
32
+ "cpu flags for reference code. 1 = C, -1 = SIMD");
33
+ ABSL_FLAG(int32_t,
34
+ libyuv_cpu_info,
35
+ 0,
36
+ "cpu flags for benchmark code. 1 = C, -1 = SIMD");
37
+ #else
38
+ // Disable command line parameters if absl/flags disabled.
39
+ static const int32_t FLAGS_libyuv_width = 0;
40
+ static const int32_t FLAGS_libyuv_height = 0;
41
+ static const int32_t FLAGS_libyuv_repeat = 0;
42
+ static const int32_t FLAGS_libyuv_flags = 0;
43
+ static const int32_t FLAGS_libyuv_cpu_info = 0;
44
+ #endif
45
+
46
+ #ifdef LIBYUV_USE_ABSL_FLAGS
47
+ #define LIBYUV_GET_FLAG(f) absl::GetFlag(f)
48
+ #else
49
+ #define LIBYUV_GET_FLAG(f) f
50
+ #endif
51
+
52
+ // Test environment variable for disabling CPU features. Any non-zero value
53
+ // to disable. Zero ignored to make it easy to set the variable on/off.
54
+ #if !defined(__native_client__) && !defined(_M_ARM)
55
+ static LIBYUV_BOOL TestEnv(const char* name) {
56
+ const char* var = getenv(name);
57
+ if (var) {
58
+ if (var[0] != '0') {
59
+ return LIBYUV_TRUE;
60
+ }
61
+ }
62
+ return LIBYUV_FALSE;
63
+ }
64
+ #else // nacl does not support getenv().
65
+ static LIBYUV_BOOL TestEnv(const char*) {
66
+ return LIBYUV_FALSE;
67
+ }
68
+ #endif
69
+
70
+ static int TestCpuEnv(int cpu_info) {
71
+ #if defined(__arm__) || defined(__aarch64__)
72
+ if (TestEnv("LIBYUV_DISABLE_NEON")) {
73
+ cpu_info &= ~libyuv::kCpuHasNEON;
74
+ }
75
+ #endif
76
+ #if defined(__aarch64__)
77
+ if (TestEnv("LIBYUV_DISABLE_NEON_DOTPROD")) {
78
+ cpu_info &= ~libyuv::kCpuHasNeonDotProd;
79
+ }
80
+ if (TestEnv("LIBYUV_DISABLE_NEON_I8MM")) {
81
+ cpu_info &= ~libyuv::kCpuHasNeonI8MM;
82
+ }
83
+ if (TestEnv("LIBYUV_DISABLE_SVE")) {
84
+ cpu_info &= ~libyuv::kCpuHasSVE;
85
+ }
86
+ if (TestEnv("LIBYUV_DISABLE_SVE2")) {
87
+ cpu_info &= ~libyuv::kCpuHasSVE2;
88
+ }
89
+ if (TestEnv("LIBYUV_DISABLE_SME")) {
90
+ cpu_info &= ~libyuv::kCpuHasSME;
91
+ }
92
+ #endif
93
+ #if defined(__longarch__) && defined(__linux__)
94
+ if (TestEnv("LIBYUV_DISABLE_LSX")) {
95
+ cpu_info &= ~libyuv::kCpuHasLSX;
96
+ }
97
+ if (TestEnv("LIBYUV_DISABLE_LASX")) {
98
+ cpu_info &= ~libyuv::kCpuHasLASX;
99
+ }
100
+ #endif
101
+ #if defined(__riscv) && defined(__linux__)
102
+ if (TestEnv("LIBYUV_DISABLE_RVV")) {
103
+ cpu_info &= ~libyuv::kCpuHasRVV;
104
+ }
105
+ #endif
106
+ #if !defined(__pnacl__) && !defined(__CLR_VER) && \
107
+ (defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || \
108
+ defined(_M_IX86))
109
+ if (TestEnv("LIBYUV_DISABLE_X86")) {
110
+ cpu_info &= ~libyuv::kCpuHasX86;
111
+ }
112
+ if (TestEnv("LIBYUV_DISABLE_SSE2")) {
113
+ cpu_info &= ~libyuv::kCpuHasSSE2;
114
+ }
115
+ if (TestEnv("LIBYUV_DISABLE_SSSE3")) {
116
+ cpu_info &= ~libyuv::kCpuHasSSSE3;
117
+ }
118
+ if (TestEnv("LIBYUV_DISABLE_SSE41")) {
119
+ cpu_info &= ~libyuv::kCpuHasSSE41;
120
+ }
121
+ if (TestEnv("LIBYUV_DISABLE_SSE42")) {
122
+ cpu_info &= ~libyuv::kCpuHasSSE42;
123
+ }
124
+ if (TestEnv("LIBYUV_DISABLE_AVX")) {
125
+ cpu_info &= ~libyuv::kCpuHasAVX;
126
+ }
127
+ if (TestEnv("LIBYUV_DISABLE_AVX2")) {
128
+ cpu_info &= ~libyuv::kCpuHasAVX2;
129
+ }
130
+ if (TestEnv("LIBYUV_DISABLE_ERMS")) {
131
+ cpu_info &= ~libyuv::kCpuHasERMS;
132
+ }
133
+ if (TestEnv("LIBYUV_DISABLE_FMA3")) {
134
+ cpu_info &= ~libyuv::kCpuHasFMA3;
135
+ }
136
+ if (TestEnv("LIBYUV_DISABLE_F16C")) {
137
+ cpu_info &= ~libyuv::kCpuHasF16C;
138
+ }
139
+ if (TestEnv("LIBYUV_DISABLE_AVX512BW")) {
140
+ cpu_info &= ~libyuv::kCpuHasAVX512BW;
141
+ }
142
+ if (TestEnv("LIBYUV_DISABLE_AVX512VL")) {
143
+ cpu_info &= ~libyuv::kCpuHasAVX512VL;
144
+ }
145
+ if (TestEnv("LIBYUV_DISABLE_AVX512VNNI")) {
146
+ cpu_info &= ~libyuv::kCpuHasAVX512VNNI;
147
+ }
148
+ if (TestEnv("LIBYUV_DISABLE_AVX512VBMI")) {
149
+ cpu_info &= ~libyuv::kCpuHasAVX512VBMI;
150
+ }
151
+ if (TestEnv("LIBYUV_DISABLE_AVX512VBMI2")) {
152
+ cpu_info &= ~libyuv::kCpuHasAVX512VBMI2;
153
+ }
154
+ if (TestEnv("LIBYUV_DISABLE_AVX512VBITALG")) {
155
+ cpu_info &= ~libyuv::kCpuHasAVX512VBITALG;
156
+ }
157
+ if (TestEnv("LIBYUV_DISABLE_AVX10")) {
158
+ cpu_info &= ~libyuv::kCpuHasAVX10;
159
+ }
160
+ if (TestEnv("LIBYUV_DISABLE_AVX10_2")) {
161
+ cpu_info &= ~libyuv::kCpuHasAVX10_2;
162
+ }
163
+ if (TestEnv("LIBYUV_DISABLE_AVXVNNI")) {
164
+ cpu_info &= ~libyuv::kCpuHasAVXVNNI;
165
+ }
166
+ if (TestEnv("LIBYUV_DISABLE_AVXVNNIINT8")) {
167
+ cpu_info &= ~libyuv::kCpuHasAVXVNNIINT8;
168
+ }
169
+ if (TestEnv("LIBYUV_DISABLE_AMXINT8")) {
170
+ cpu_info &= ~libyuv::kCpuHasAMXINT8;
171
+ }
172
+ #endif
173
+ if (TestEnv("LIBYUV_DISABLE_ASM")) {
174
+ cpu_info = libyuv::kCpuInitialized;
175
+ }
176
+ return cpu_info;
177
+ }
178
+
179
+ // For quicker unittests, default is 128 x 72. But when benchmarking,
180
+ // default to 720p. Allow size to specify.
181
+ // Set flags to -1 for benchmarking to avoid slower C code.
182
+
183
+ LibYUVConvertTest::LibYUVConvertTest()
184
+ : benchmark_iterations_(1),
185
+ benchmark_width_(128),
186
+ benchmark_height_(72),
187
+ disable_cpu_flags_(1),
188
+ benchmark_cpu_info_(-1) {
189
+ const char* repeat = getenv("LIBYUV_REPEAT");
190
+ if (repeat) {
191
+ benchmark_iterations_ = atoi(repeat); // NOLINT
192
+ }
193
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_repeat)) {
194
+ benchmark_iterations_ = LIBYUV_GET_FLAG(FLAGS_libyuv_repeat);
195
+ }
196
+ if (benchmark_iterations_ > 1) {
197
+ benchmark_width_ = 1280;
198
+ benchmark_height_ = 720;
199
+ }
200
+ const char* width = getenv("LIBYUV_WIDTH");
201
+ if (width) {
202
+ benchmark_width_ = atoi(width); // NOLINT
203
+ }
204
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_width)) {
205
+ benchmark_width_ = LIBYUV_GET_FLAG(FLAGS_libyuv_width);
206
+ }
207
+ const char* height = getenv("LIBYUV_HEIGHT");
208
+ if (height) {
209
+ benchmark_height_ = atoi(height); // NOLINT
210
+ }
211
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_height)) {
212
+ benchmark_height_ = LIBYUV_GET_FLAG(FLAGS_libyuv_height);
213
+ }
214
+ const char* cpu_flags = getenv("LIBYUV_FLAGS");
215
+ if (cpu_flags) {
216
+ disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
217
+ }
218
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_flags)) {
219
+ disable_cpu_flags_ = LIBYUV_GET_FLAG(FLAGS_libyuv_flags);
220
+ }
221
+ const char* cpu_info = getenv("LIBYUV_CPU_INFO");
222
+ if (cpu_info) {
223
+ benchmark_cpu_info_ = atoi(cpu_info); // NOLINT
224
+ }
225
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info)) {
226
+ benchmark_cpu_info_ = LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info);
227
+ }
228
+ disable_cpu_flags_ = TestCpuEnv(disable_cpu_flags_);
229
+ benchmark_cpu_info_ = TestCpuEnv(benchmark_cpu_info_);
230
+ libyuv::MaskCpuFlags(benchmark_cpu_info_);
231
+ benchmark_pixels_div1280_ =
232
+ static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
233
+ static_cast<double>(Abs(benchmark_height_)) *
234
+ static_cast<double>(benchmark_iterations_) +
235
+ 1279.0) /
236
+ 1280.0);
237
+ }
238
+
239
+ LibYUVColorTest::LibYUVColorTest()
240
+ : benchmark_iterations_(1),
241
+ benchmark_width_(128),
242
+ benchmark_height_(72),
243
+ disable_cpu_flags_(1),
244
+ benchmark_cpu_info_(-1) {
245
+ const char* repeat = getenv("LIBYUV_REPEAT");
246
+ if (repeat) {
247
+ benchmark_iterations_ = atoi(repeat); // NOLINT
248
+ }
249
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_repeat)) {
250
+ benchmark_iterations_ = LIBYUV_GET_FLAG(FLAGS_libyuv_repeat);
251
+ }
252
+ if (benchmark_iterations_ > 1) {
253
+ benchmark_width_ = 1280;
254
+ benchmark_height_ = 720;
255
+ }
256
+ const char* width = getenv("LIBYUV_WIDTH");
257
+ if (width) {
258
+ benchmark_width_ = atoi(width); // NOLINT
259
+ }
260
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_width)) {
261
+ benchmark_width_ = LIBYUV_GET_FLAG(FLAGS_libyuv_width);
262
+ }
263
+ const char* height = getenv("LIBYUV_HEIGHT");
264
+ if (height) {
265
+ benchmark_height_ = atoi(height); // NOLINT
266
+ }
267
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_height)) {
268
+ benchmark_height_ = LIBYUV_GET_FLAG(FLAGS_libyuv_height);
269
+ }
270
+ const char* cpu_flags = getenv("LIBYUV_FLAGS");
271
+ if (cpu_flags) {
272
+ disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
273
+ }
274
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_flags)) {
275
+ disable_cpu_flags_ = LIBYUV_GET_FLAG(FLAGS_libyuv_flags);
276
+ }
277
+ const char* cpu_info = getenv("LIBYUV_CPU_INFO");
278
+ if (cpu_info) {
279
+ benchmark_cpu_info_ = atoi(cpu_info); // NOLINT
280
+ }
281
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info)) {
282
+ benchmark_cpu_info_ = LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info);
283
+ }
284
+ disable_cpu_flags_ = TestCpuEnv(disable_cpu_flags_);
285
+ benchmark_cpu_info_ = TestCpuEnv(benchmark_cpu_info_);
286
+ libyuv::MaskCpuFlags(benchmark_cpu_info_);
287
+ benchmark_pixels_div1280_ =
288
+ static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
289
+ static_cast<double>(Abs(benchmark_height_)) *
290
+ static_cast<double>(benchmark_iterations_) +
291
+ 1279.0) /
292
+ 1280.0);
293
+ }
294
+
295
+ LibYUVScaleTest::LibYUVScaleTest()
296
+ : benchmark_iterations_(1),
297
+ benchmark_width_(128),
298
+ benchmark_height_(72),
299
+ disable_cpu_flags_(1),
300
+ benchmark_cpu_info_(-1) {
301
+ const char* repeat = getenv("LIBYUV_REPEAT");
302
+ if (repeat) {
303
+ benchmark_iterations_ = atoi(repeat); // NOLINT
304
+ }
305
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_repeat)) {
306
+ benchmark_iterations_ = LIBYUV_GET_FLAG(FLAGS_libyuv_repeat);
307
+ }
308
+ if (benchmark_iterations_ > 1) {
309
+ benchmark_width_ = 1280;
310
+ benchmark_height_ = 720;
311
+ }
312
+ const char* width = getenv("LIBYUV_WIDTH");
313
+ if (width) {
314
+ benchmark_width_ = atoi(width); // NOLINT
315
+ }
316
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_width)) {
317
+ benchmark_width_ = LIBYUV_GET_FLAG(FLAGS_libyuv_width);
318
+ }
319
+ const char* height = getenv("LIBYUV_HEIGHT");
320
+ if (height) {
321
+ benchmark_height_ = atoi(height); // NOLINT
322
+ }
323
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_height)) {
324
+ benchmark_height_ = LIBYUV_GET_FLAG(FLAGS_libyuv_height);
325
+ }
326
+ const char* cpu_flags = getenv("LIBYUV_FLAGS");
327
+ if (cpu_flags) {
328
+ disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
329
+ }
330
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_flags)) {
331
+ disable_cpu_flags_ = LIBYUV_GET_FLAG(FLAGS_libyuv_flags);
332
+ }
333
+ const char* cpu_info = getenv("LIBYUV_CPU_INFO");
334
+ if (cpu_info) {
335
+ benchmark_cpu_info_ = atoi(cpu_info); // NOLINT
336
+ }
337
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info)) {
338
+ benchmark_cpu_info_ = LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info);
339
+ }
340
+ disable_cpu_flags_ = TestCpuEnv(disable_cpu_flags_);
341
+ benchmark_cpu_info_ = TestCpuEnv(benchmark_cpu_info_);
342
+ libyuv::MaskCpuFlags(benchmark_cpu_info_);
343
+ benchmark_pixels_div1280_ =
344
+ static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
345
+ static_cast<double>(Abs(benchmark_height_)) *
346
+ static_cast<double>(benchmark_iterations_) +
347
+ 1279.0) /
348
+ 1280.0);
349
+ }
350
+
351
+ LibYUVRotateTest::LibYUVRotateTest()
352
+ : benchmark_iterations_(1),
353
+ benchmark_width_(128),
354
+ benchmark_height_(72),
355
+ disable_cpu_flags_(1),
356
+ benchmark_cpu_info_(-1) {
357
+ const char* repeat = getenv("LIBYUV_REPEAT");
358
+ if (repeat) {
359
+ benchmark_iterations_ = atoi(repeat); // NOLINT
360
+ }
361
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_repeat)) {
362
+ benchmark_iterations_ = LIBYUV_GET_FLAG(FLAGS_libyuv_repeat);
363
+ }
364
+ if (benchmark_iterations_ > 1) {
365
+ benchmark_width_ = 1280;
366
+ benchmark_height_ = 720;
367
+ }
368
+ const char* width = getenv("LIBYUV_WIDTH");
369
+ if (width) {
370
+ benchmark_width_ = atoi(width); // NOLINT
371
+ }
372
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_width)) {
373
+ benchmark_width_ = LIBYUV_GET_FLAG(FLAGS_libyuv_width);
374
+ }
375
+ const char* height = getenv("LIBYUV_HEIGHT");
376
+ if (height) {
377
+ benchmark_height_ = atoi(height); // NOLINT
378
+ }
379
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_height)) {
380
+ benchmark_height_ = LIBYUV_GET_FLAG(FLAGS_libyuv_height);
381
+ }
382
+ const char* cpu_flags = getenv("LIBYUV_FLAGS");
383
+ if (cpu_flags) {
384
+ disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
385
+ }
386
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_flags)) {
387
+ disable_cpu_flags_ = LIBYUV_GET_FLAG(FLAGS_libyuv_flags);
388
+ }
389
+ const char* cpu_info = getenv("LIBYUV_CPU_INFO");
390
+ if (cpu_info) {
391
+ benchmark_cpu_info_ = atoi(cpu_info); // NOLINT
392
+ }
393
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info)) {
394
+ benchmark_cpu_info_ = LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info);
395
+ }
396
+ disable_cpu_flags_ = TestCpuEnv(disable_cpu_flags_);
397
+ benchmark_cpu_info_ = TestCpuEnv(benchmark_cpu_info_);
398
+ libyuv::MaskCpuFlags(benchmark_cpu_info_);
399
+ benchmark_pixels_div1280_ =
400
+ static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
401
+ static_cast<double>(Abs(benchmark_height_)) *
402
+ static_cast<double>(benchmark_iterations_) +
403
+ 1279.0) /
404
+ 1280.0);
405
+ }
406
+
407
+ LibYUVPlanarTest::LibYUVPlanarTest()
408
+ : benchmark_iterations_(1),
409
+ benchmark_width_(128),
410
+ benchmark_height_(72),
411
+ disable_cpu_flags_(1),
412
+ benchmark_cpu_info_(-1) {
413
+ const char* repeat = getenv("LIBYUV_REPEAT");
414
+ if (repeat) {
415
+ benchmark_iterations_ = atoi(repeat); // NOLINT
416
+ }
417
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_repeat)) {
418
+ benchmark_iterations_ = LIBYUV_GET_FLAG(FLAGS_libyuv_repeat);
419
+ }
420
+ if (benchmark_iterations_ > 1) {
421
+ benchmark_width_ = 1280;
422
+ benchmark_height_ = 720;
423
+ }
424
+ const char* width = getenv("LIBYUV_WIDTH");
425
+ if (width) {
426
+ benchmark_width_ = atoi(width); // NOLINT
427
+ }
428
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_width)) {
429
+ benchmark_width_ = LIBYUV_GET_FLAG(FLAGS_libyuv_width);
430
+ }
431
+ const char* height = getenv("LIBYUV_HEIGHT");
432
+ if (height) {
433
+ benchmark_height_ = atoi(height); // NOLINT
434
+ }
435
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_height)) {
436
+ benchmark_height_ = LIBYUV_GET_FLAG(FLAGS_libyuv_height);
437
+ }
438
+ const char* cpu_flags = getenv("LIBYUV_FLAGS");
439
+ if (cpu_flags) {
440
+ disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
441
+ }
442
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_flags)) {
443
+ disable_cpu_flags_ = LIBYUV_GET_FLAG(FLAGS_libyuv_flags);
444
+ }
445
+ const char* cpu_info = getenv("LIBYUV_CPU_INFO");
446
+ if (cpu_info) {
447
+ benchmark_cpu_info_ = atoi(cpu_info); // NOLINT
448
+ }
449
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info)) {
450
+ benchmark_cpu_info_ = LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info);
451
+ }
452
+ disable_cpu_flags_ = TestCpuEnv(disable_cpu_flags_);
453
+ benchmark_cpu_info_ = TestCpuEnv(benchmark_cpu_info_);
454
+ libyuv::MaskCpuFlags(benchmark_cpu_info_);
455
+ benchmark_pixels_div1280_ =
456
+ static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
457
+ static_cast<double>(Abs(benchmark_height_)) *
458
+ static_cast<double>(benchmark_iterations_) +
459
+ 1279.0) /
460
+ 1280.0);
461
+ }
462
+
463
+ LibYUVBaseTest::LibYUVBaseTest()
464
+ : benchmark_iterations_(1),
465
+ benchmark_width_(128),
466
+ benchmark_height_(72),
467
+ disable_cpu_flags_(1),
468
+ benchmark_cpu_info_(-1) {
469
+ const char* repeat = getenv("LIBYUV_REPEAT");
470
+ if (repeat) {
471
+ benchmark_iterations_ = atoi(repeat); // NOLINT
472
+ }
473
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_repeat)) {
474
+ benchmark_iterations_ = LIBYUV_GET_FLAG(FLAGS_libyuv_repeat);
475
+ }
476
+ if (benchmark_iterations_ > 1) {
477
+ benchmark_width_ = 1280;
478
+ benchmark_height_ = 720;
479
+ }
480
+ const char* width = getenv("LIBYUV_WIDTH");
481
+ if (width) {
482
+ benchmark_width_ = atoi(width); // NOLINT
483
+ }
484
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_width)) {
485
+ benchmark_width_ = LIBYUV_GET_FLAG(FLAGS_libyuv_width);
486
+ }
487
+ const char* height = getenv("LIBYUV_HEIGHT");
488
+ if (height) {
489
+ benchmark_height_ = atoi(height); // NOLINT
490
+ }
491
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_height)) {
492
+ benchmark_height_ = LIBYUV_GET_FLAG(FLAGS_libyuv_height);
493
+ }
494
+ const char* cpu_flags = getenv("LIBYUV_FLAGS");
495
+ if (cpu_flags) {
496
+ disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
497
+ }
498
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_flags)) {
499
+ disable_cpu_flags_ = LIBYUV_GET_FLAG(FLAGS_libyuv_flags);
500
+ }
501
+ const char* cpu_info = getenv("LIBYUV_CPU_INFO");
502
+ if (cpu_info) {
503
+ benchmark_cpu_info_ = atoi(cpu_info); // NOLINT
504
+ }
505
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info)) {
506
+ benchmark_cpu_info_ = LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info);
507
+ }
508
+ disable_cpu_flags_ = TestCpuEnv(disable_cpu_flags_);
509
+ benchmark_cpu_info_ = TestCpuEnv(benchmark_cpu_info_);
510
+ libyuv::MaskCpuFlags(benchmark_cpu_info_);
511
+ benchmark_pixels_div1280_ =
512
+ static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
513
+ static_cast<double>(Abs(benchmark_height_)) *
514
+ static_cast<double>(benchmark_iterations_) +
515
+ 1279.0) /
516
+ 1280.0);
517
+ }
518
+
519
+ LibYUVCompareTest::LibYUVCompareTest()
520
+ : benchmark_iterations_(1),
521
+ benchmark_width_(128),
522
+ benchmark_height_(72),
523
+ disable_cpu_flags_(1),
524
+ benchmark_cpu_info_(-1) {
525
+ const char* repeat = getenv("LIBYUV_REPEAT");
526
+ if (repeat) {
527
+ benchmark_iterations_ = atoi(repeat); // NOLINT
528
+ }
529
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_repeat)) {
530
+ benchmark_iterations_ = LIBYUV_GET_FLAG(FLAGS_libyuv_repeat);
531
+ }
532
+ if (benchmark_iterations_ > 1) {
533
+ benchmark_width_ = 1280;
534
+ benchmark_height_ = 720;
535
+ }
536
+ const char* width = getenv("LIBYUV_WIDTH");
537
+ if (width) {
538
+ benchmark_width_ = atoi(width); // NOLINT
539
+ }
540
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_width)) {
541
+ benchmark_width_ = LIBYUV_GET_FLAG(FLAGS_libyuv_width);
542
+ }
543
+ const char* height = getenv("LIBYUV_HEIGHT");
544
+ if (height) {
545
+ benchmark_height_ = atoi(height); // NOLINT
546
+ }
547
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_height)) {
548
+ benchmark_height_ = LIBYUV_GET_FLAG(FLAGS_libyuv_height);
549
+ }
550
+ const char* cpu_flags = getenv("LIBYUV_FLAGS");
551
+ if (cpu_flags) {
552
+ disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
553
+ }
554
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_flags)) {
555
+ disable_cpu_flags_ = LIBYUV_GET_FLAG(FLAGS_libyuv_flags);
556
+ }
557
+ const char* cpu_info = getenv("LIBYUV_CPU_INFO");
558
+ if (cpu_info) {
559
+ benchmark_cpu_info_ = atoi(cpu_info); // NOLINT
560
+ }
561
+ if (LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info)) {
562
+ benchmark_cpu_info_ = LIBYUV_GET_FLAG(FLAGS_libyuv_cpu_info);
563
+ }
564
+ disable_cpu_flags_ = TestCpuEnv(disable_cpu_flags_);
565
+ benchmark_cpu_info_ = TestCpuEnv(benchmark_cpu_info_);
566
+ libyuv::MaskCpuFlags(benchmark_cpu_info_);
567
+ benchmark_pixels_div1280_ =
568
+ static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
569
+ static_cast<double>(Abs(benchmark_height_)) *
570
+ static_cast<double>(benchmark_iterations_) +
571
+ 1279.0) /
572
+ 1280.0);
573
+ }
574
+
575
+ int main(int argc, char** argv) {
576
+ ::testing::InitGoogleTest(&argc, argv);
577
+ #ifdef LIBYUV_USE_ABSL_FLAGS
578
+ absl::ParseCommandLine(argc, argv);
579
+ #endif
580
+ return RUN_ALL_TESTS();
581
+ }