react-native-vision-camera-spoof-detector 1.1.23 → 1.1.25

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 (200) hide show
  1. package/android/CMakeLists.txt +12 -0
  2. package/android/build.gradle +10 -9
  3. package/android/src/main/cpp/cpp-adapter.cpp +6 -3
  4. package/ios/HybridSpoofDetectorOutput.swift +112 -72
  5. package/package.json +1 -1
  6. package/android/src/main/cpp/CMakeLists.txt +0 -33
  7. package/android/src/main/cpp/FaceAntiSpoofJSI.cpp +0 -142
  8. package/android/src/main/cpp/FastYuvJni.cpp +0 -111
  9. package/android/src/main/cpp/fast_yuv.cpp +0 -342
  10. package/android/src/main/cpp/fast_yuv.h +0 -23
  11. package/android/src/main/cpp/libyuv/.clang-format +0 -6
  12. package/android/src/main/cpp/libyuv/.gn +0 -40
  13. package/android/src/main/cpp/libyuv/.vpython3 +0 -410
  14. package/android/src/main/cpp/libyuv/AUTHORS +0 -7
  15. package/android/src/main/cpp/libyuv/Android.bp +0 -202
  16. package/android/src/main/cpp/libyuv/Android.mk +0 -106
  17. package/android/src/main/cpp/libyuv/BUILD.gn +0 -490
  18. package/android/src/main/cpp/libyuv/CM_linux_packages.cmake +0 -70
  19. package/android/src/main/cpp/libyuv/CMakeLists.txt +0 -259
  20. package/android/src/main/cpp/libyuv/DEPS +0 -935
  21. package/android/src/main/cpp/libyuv/DIR_METADATA +0 -3
  22. package/android/src/main/cpp/libyuv/LICENSE +0 -29
  23. package/android/src/main/cpp/libyuv/OWNERS +0 -11
  24. package/android/src/main/cpp/libyuv/PATENTS +0 -24
  25. package/android/src/main/cpp/libyuv/PRESUBMIT.py +0 -65
  26. package/android/src/main/cpp/libyuv/README.chromium +0 -11
  27. package/android/src/main/cpp/libyuv/README.md +0 -19
  28. package/android/src/main/cpp/libyuv/build_overrides/build.gni +0 -60
  29. package/android/src/main/cpp/libyuv/build_overrides/gtest.gni +0 -19
  30. package/android/src/main/cpp/libyuv/build_overrides/partition_alloc.gni +0 -17
  31. package/android/src/main/cpp/libyuv/codereview.settings +0 -5
  32. package/android/src/main/cpp/libyuv/docs/deprecated_builds.md +0 -409
  33. package/android/src/main/cpp/libyuv/docs/environment_variables.md +0 -64
  34. package/android/src/main/cpp/libyuv/docs/feature_detection.md +0 -108
  35. package/android/src/main/cpp/libyuv/docs/filtering.md +0 -196
  36. package/android/src/main/cpp/libyuv/docs/formats.md +0 -208
  37. package/android/src/main/cpp/libyuv/docs/getting_started.md +0 -296
  38. package/android/src/main/cpp/libyuv/docs/rotation.md +0 -107
  39. package/android/src/main/cpp/libyuv/download_vs_toolchain.py +0 -29
  40. package/android/src/main/cpp/libyuv/include/libyuv/basic_types.h +0 -68
  41. package/android/src/main/cpp/libyuv/include/libyuv/compare.h +0 -111
  42. package/android/src/main/cpp/libyuv/include/libyuv/compare_row.h +0 -112
  43. package/android/src/main/cpp/libyuv/include/libyuv/convert.h +0 -1117
  44. package/android/src/main/cpp/libyuv/include/libyuv/convert_argb.h +0 -2335
  45. package/android/src/main/cpp/libyuv/include/libyuv/convert_from.h +0 -203
  46. package/android/src/main/cpp/libyuv/include/libyuv/convert_from_argb.h +0 -394
  47. package/android/src/main/cpp/libyuv/include/libyuv/cpu_id.h +0 -147
  48. package/android/src/main/cpp/libyuv/include/libyuv/cpu_support.h +0 -99
  49. package/android/src/main/cpp/libyuv/include/libyuv/loongson_intrinsics.h +0 -1949
  50. package/android/src/main/cpp/libyuv/include/libyuv/mjpeg_decoder.h +0 -195
  51. package/android/src/main/cpp/libyuv/include/libyuv/planar_functions.h +0 -1131
  52. package/android/src/main/cpp/libyuv/include/libyuv/rotate.h +0 -296
  53. package/android/src/main/cpp/libyuv/include/libyuv/rotate_argb.h +0 -37
  54. package/android/src/main/cpp/libyuv/include/libyuv/rotate_row.h +0 -265
  55. package/android/src/main/cpp/libyuv/include/libyuv/row.h +0 -6738
  56. package/android/src/main/cpp/libyuv/include/libyuv/row_sve.h +0 -2154
  57. package/android/src/main/cpp/libyuv/include/libyuv/scale.h +0 -336
  58. package/android/src/main/cpp/libyuv/include/libyuv/scale_argb.h +0 -76
  59. package/android/src/main/cpp/libyuv/include/libyuv/scale_rgb.h +0 -42
  60. package/android/src/main/cpp/libyuv/include/libyuv/scale_row.h +0 -1726
  61. package/android/src/main/cpp/libyuv/include/libyuv/scale_uv.h +0 -51
  62. package/android/src/main/cpp/libyuv/include/libyuv/version.h +0 -16
  63. package/android/src/main/cpp/libyuv/include/libyuv/video_common.h +0 -222
  64. package/android/src/main/cpp/libyuv/include/libyuv.h +0 -33
  65. package/android/src/main/cpp/libyuv/infra/config/OWNERS +0 -3
  66. package/android/src/main/cpp/libyuv/infra/config/PRESUBMIT.py +0 -17
  67. package/android/src/main/cpp/libyuv/infra/config/README.md +0 -2
  68. package/android/src/main/cpp/libyuv/infra/config/codereview.settings +0 -6
  69. package/android/src/main/cpp/libyuv/infra/config/commit-queue.cfg +0 -144
  70. package/android/src/main/cpp/libyuv/infra/config/cr-buildbucket.cfg +0 -1185
  71. package/android/src/main/cpp/libyuv/infra/config/luci-logdog.cfg +0 -9
  72. package/android/src/main/cpp/libyuv/infra/config/luci-milo.cfg +0 -246
  73. package/android/src/main/cpp/libyuv/infra/config/luci-scheduler.cfg +0 -385
  74. package/android/src/main/cpp/libyuv/infra/config/main.star +0 -402
  75. package/android/src/main/cpp/libyuv/infra/config/project.cfg +0 -16
  76. package/android/src/main/cpp/libyuv/infra/config/realms.cfg +0 -111
  77. package/android/src/main/cpp/libyuv/libyuv.gni +0 -34
  78. package/android/src/main/cpp/libyuv/libyuv.gyp +0 -149
  79. package/android/src/main/cpp/libyuv/libyuv.gypi +0 -87
  80. package/android/src/main/cpp/libyuv/linux.mk +0 -96
  81. package/android/src/main/cpp/libyuv/public.mk +0 -13
  82. package/android/src/main/cpp/libyuv/pylintrc +0 -49
  83. package/android/src/main/cpp/libyuv/riscv_script/prepare_toolchain_qemu.sh +0 -74
  84. package/android/src/main/cpp/libyuv/riscv_script/riscv-clang.cmake +0 -56
  85. package/android/src/main/cpp/libyuv/riscv_script/run_qemu.sh +0 -15
  86. package/android/src/main/cpp/libyuv/source/compare.cc +0 -435
  87. package/android/src/main/cpp/libyuv/source/compare_common.cc +0 -74
  88. package/android/src/main/cpp/libyuv/source/compare_gcc.cc +0 -362
  89. package/android/src/main/cpp/libyuv/source/compare_neon.cc +0 -96
  90. package/android/src/main/cpp/libyuv/source/compare_neon64.cc +0 -223
  91. package/android/src/main/cpp/libyuv/source/compare_win.cc +0 -241
  92. package/android/src/main/cpp/libyuv/source/convert.cc +0 -4746
  93. package/android/src/main/cpp/libyuv/source/convert_argb.cc +0 -9179
  94. package/android/src/main/cpp/libyuv/source/convert_from.cc +0 -866
  95. package/android/src/main/cpp/libyuv/source/convert_from_argb.cc +0 -3671
  96. package/android/src/main/cpp/libyuv/source/convert_jpeg.cc +0 -602
  97. package/android/src/main/cpp/libyuv/source/convert_to_argb.cc +0 -391
  98. package/android/src/main/cpp/libyuv/source/convert_to_i420.cc +0 -288
  99. package/android/src/main/cpp/libyuv/source/cpu_id.cc +0 -496
  100. package/android/src/main/cpp/libyuv/source/mjpeg_decoder.cc +0 -580
  101. package/android/src/main/cpp/libyuv/source/mjpeg_validate.cc +0 -71
  102. package/android/src/main/cpp/libyuv/source/planar_functions.cc +0 -5663
  103. package/android/src/main/cpp/libyuv/source/rotate.cc +0 -1241
  104. package/android/src/main/cpp/libyuv/source/rotate_any.cc +0 -76
  105. package/android/src/main/cpp/libyuv/source/rotate_argb.cc +0 -259
  106. package/android/src/main/cpp/libyuv/source/rotate_common.cc +0 -208
  107. package/android/src/main/cpp/libyuv/source/rotate_gcc.cc +0 -505
  108. package/android/src/main/cpp/libyuv/source/rotate_lsx.cc +0 -233
  109. package/android/src/main/cpp/libyuv/source/rotate_neon.cc +0 -219
  110. package/android/src/main/cpp/libyuv/source/rotate_neon64.cc +0 -273
  111. package/android/src/main/cpp/libyuv/source/rotate_sme.cc +0 -174
  112. package/android/src/main/cpp/libyuv/source/rotate_win.cc +0 -253
  113. package/android/src/main/cpp/libyuv/source/row_any.cc +0 -2519
  114. package/android/src/main/cpp/libyuv/source/row_common.cc +0 -4461
  115. package/android/src/main/cpp/libyuv/source/row_gcc.cc +0 -9570
  116. package/android/src/main/cpp/libyuv/source/row_lasx.cc +0 -2343
  117. package/android/src/main/cpp/libyuv/source/row_lsx.cc +0 -3030
  118. package/android/src/main/cpp/libyuv/source/row_neon.cc +0 -4026
  119. package/android/src/main/cpp/libyuv/source/row_neon64.cc +0 -5617
  120. package/android/src/main/cpp/libyuv/source/row_rvv.cc +0 -2599
  121. package/android/src/main/cpp/libyuv/source/row_sme.cc +0 -1183
  122. package/android/src/main/cpp/libyuv/source/row_sve.cc +0 -1088
  123. package/android/src/main/cpp/libyuv/source/row_win.cc +0 -6453
  124. package/android/src/main/cpp/libyuv/source/scale.cc +0 -2710
  125. package/android/src/main/cpp/libyuv/source/scale_any.cc +0 -991
  126. package/android/src/main/cpp/libyuv/source/scale_argb.cc +0 -1158
  127. package/android/src/main/cpp/libyuv/source/scale_common.cc +0 -1977
  128. package/android/src/main/cpp/libyuv/source/scale_gcc.cc +0 -2947
  129. package/android/src/main/cpp/libyuv/source/scale_lsx.cc +0 -739
  130. package/android/src/main/cpp/libyuv/source/scale_neon.cc +0 -1449
  131. package/android/src/main/cpp/libyuv/source/scale_neon64.cc +0 -1552
  132. package/android/src/main/cpp/libyuv/source/scale_rgb.cc +0 -82
  133. package/android/src/main/cpp/libyuv/source/scale_rvv.cc +0 -1971
  134. package/android/src/main/cpp/libyuv/source/scale_sme.cc +0 -555
  135. package/android/src/main/cpp/libyuv/source/scale_uv.cc +0 -1159
  136. package/android/src/main/cpp/libyuv/source/scale_win.cc +0 -1392
  137. package/android/src/main/cpp/libyuv/source/test.sh +0 -35
  138. package/android/src/main/cpp/libyuv/source/video_common.cc +0 -62
  139. package/android/src/main/cpp/libyuv/tools_libyuv/OWNERS +0 -4
  140. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/roll_deps.py +0 -931
  141. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/roll_deps_test.py +0 -164
  142. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS +0 -21
  143. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.new +0 -13
  144. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.old +0 -13
  145. package/android/src/main/cpp/libyuv/tools_libyuv/get_landmines.py +0 -38
  146. package/android/src/main/cpp/libyuv/tools_libyuv/msan/OWNERS +0 -3
  147. package/android/src/main/cpp/libyuv/tools_libyuv/msan/blacklist.txt +0 -9
  148. package/android/src/main/cpp/libyuv/tools_libyuv/ubsan/OWNERS +0 -3
  149. package/android/src/main/cpp/libyuv/tools_libyuv/ubsan/blacklist.txt +0 -15
  150. package/android/src/main/cpp/libyuv/tools_libyuv/ubsan/vptr_blacklist.txt +0 -25
  151. package/android/src/main/cpp/libyuv/unit_test/basictypes_test.cc +0 -43
  152. package/android/src/main/cpp/libyuv/unit_test/color_test.cc +0 -848
  153. package/android/src/main/cpp/libyuv/unit_test/compare_test.cc +0 -739
  154. package/android/src/main/cpp/libyuv/unit_test/convert_argb_test.cc +0 -2867
  155. package/android/src/main/cpp/libyuv/unit_test/convert_test.cc +0 -2133
  156. package/android/src/main/cpp/libyuv/unit_test/cpu_test.cc +0 -427
  157. package/android/src/main/cpp/libyuv/unit_test/cpu_thread_test.cc +0 -63
  158. package/android/src/main/cpp/libyuv/unit_test/math_test.cc +0 -160
  159. package/android/src/main/cpp/libyuv/unit_test/planar_test.cc +0 -4731
  160. package/android/src/main/cpp/libyuv/unit_test/rotate_argb_test.cc +0 -334
  161. package/android/src/main/cpp/libyuv/unit_test/rotate_test.cc +0 -962
  162. package/android/src/main/cpp/libyuv/unit_test/scale_argb_test.cc +0 -590
  163. package/android/src/main/cpp/libyuv/unit_test/scale_plane_test.cc +0 -465
  164. package/android/src/main/cpp/libyuv/unit_test/scale_rgb_test.cc +0 -280
  165. package/android/src/main/cpp/libyuv/unit_test/scale_test.cc +0 -1135
  166. package/android/src/main/cpp/libyuv/unit_test/scale_uv_test.cc +0 -249
  167. package/android/src/main/cpp/libyuv/unit_test/testdata/arm_v7.txt +0 -12
  168. package/android/src/main/cpp/libyuv/unit_test/testdata/mips.txt +0 -7
  169. package/android/src/main/cpp/libyuv/unit_test/testdata/mips_loongson2k.txt +0 -5
  170. package/android/src/main/cpp/libyuv/unit_test/testdata/mips_loongson3.txt +0 -10
  171. package/android/src/main/cpp/libyuv/unit_test/testdata/mips_loongson_mmi.txt +0 -7
  172. package/android/src/main/cpp/libyuv/unit_test/testdata/riscv64.txt +0 -4
  173. package/android/src/main/cpp/libyuv/unit_test/testdata/riscv64_rvv.txt +0 -4
  174. package/android/src/main/cpp/libyuv/unit_test/testdata/riscv64_rvv_zvfh.txt +0 -4
  175. package/android/src/main/cpp/libyuv/unit_test/testdata/tegra3.txt +0 -23
  176. package/android/src/main/cpp/libyuv/unit_test/testdata/test0.jpg +0 -0
  177. package/android/src/main/cpp/libyuv/unit_test/testdata/test1.jpg +0 -0
  178. package/android/src/main/cpp/libyuv/unit_test/testdata/test2.jpg +0 -0
  179. package/android/src/main/cpp/libyuv/unit_test/testdata/test3.jpg +0 -0
  180. package/android/src/main/cpp/libyuv/unit_test/testdata/test4.jpg +0 -0
  181. package/android/src/main/cpp/libyuv/unit_test/unit_test.cc +0 -581
  182. package/android/src/main/cpp/libyuv/unit_test/unit_test.h +0 -232
  183. package/android/src/main/cpp/libyuv/unit_test/video_common_test.cc +0 -112
  184. package/android/src/main/cpp/libyuv/util/Makefile +0 -9
  185. package/android/src/main/cpp/libyuv/util/color.cc +0 -120
  186. package/android/src/main/cpp/libyuv/util/compare.cc +0 -67
  187. package/android/src/main/cpp/libyuv/util/cpuid.c +0 -211
  188. package/android/src/main/cpp/libyuv/util/i444tonv12_eg.cc +0 -28
  189. package/android/src/main/cpp/libyuv/util/psnr.cc +0 -291
  190. package/android/src/main/cpp/libyuv/util/psnr.h +0 -47
  191. package/android/src/main/cpp/libyuv/util/psnr_main.cc +0 -620
  192. package/android/src/main/cpp/libyuv/util/ssim.cc +0 -364
  193. package/android/src/main/cpp/libyuv/util/ssim.h +0 -38
  194. package/android/src/main/cpp/libyuv/util/yuvconstants.c +0 -114
  195. package/android/src/main/cpp/libyuv/util/yuvconvert.cc +0 -367
  196. package/android/src/main/cpp/libyuv/winarm.mk +0 -47
  197. package/android/src/main/java/com/faceantispoof/ByteBufferPool.kt +0 -68
  198. package/android/src/main/java/com/faceantispoof/FastYuv.kt +0 -51
  199. package/android/src/main/java/com/faceantispoof/YuvToFloatArrayConverter.kt +0 -584
  200. package/android/src/main/java/com/faceantispoof/YuvToRgbConverter.kt +0 -73
@@ -1,739 +0,0 @@
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 <stdlib.h>
12
- #include <string.h>
13
- #include <time.h>
14
-
15
- #include "../unit_test/unit_test.h"
16
- #include "libyuv/basic_types.h"
17
- #include "libyuv/compare.h"
18
- #include "libyuv/cpu_id.h"
19
- #include "libyuv/video_common.h"
20
-
21
- #ifdef ENABLE_ROW_TESTS
22
- #include "libyuv/compare_row.h" /* For HammingDistance_C */
23
- #endif
24
-
25
- namespace libyuv {
26
-
27
- // hash seed of 5381 recommended.
28
- static uint32_t ReferenceHashDjb2(const uint8_t* src,
29
- uint64_t count,
30
- uint32_t seed) {
31
- uint32_t hash = seed;
32
- if (count > 0) {
33
- do {
34
- hash = hash * 33 + *src++;
35
- } while (--count);
36
- }
37
- return hash;
38
- }
39
-
40
- TEST_F(LibYUVCompareTest, Djb2_Test) {
41
- const int kMaxTest = benchmark_width_ * benchmark_height_;
42
- align_buffer_page_end(src_a, kMaxTest);
43
- align_buffer_page_end(src_b, kMaxTest);
44
-
45
- const char* fox =
46
- "The quick brown fox jumps over the lazy dog"
47
- " and feels as if he were in the seventh heaven of typography"
48
- " together with Hermann Zapf";
49
- uint32_t foxhash = HashDjb2(reinterpret_cast<const uint8_t*>(fox), 131, 5381);
50
- const uint32_t kExpectedFoxHash = 2611006483u;
51
- EXPECT_EQ(kExpectedFoxHash, foxhash);
52
-
53
- for (int i = 0; i < kMaxTest; ++i) {
54
- src_a[i] = (fastrand() & 0xff);
55
- src_b[i] = (fastrand() & 0xff);
56
- }
57
- // Compare different buffers. Expect hash is different.
58
- uint32_t h1 = HashDjb2(src_a, kMaxTest, 5381);
59
- uint32_t h2 = HashDjb2(src_b, kMaxTest, 5381);
60
- EXPECT_NE(h1, h2);
61
-
62
- // Make last half same. Expect hash is different.
63
- memcpy(src_a + kMaxTest / 2, src_b + kMaxTest / 2, kMaxTest / 2);
64
- h1 = HashDjb2(src_a, kMaxTest, 5381);
65
- h2 = HashDjb2(src_b, kMaxTest, 5381);
66
- EXPECT_NE(h1, h2);
67
-
68
- // Make first half same. Expect hash is different.
69
- memcpy(src_a + kMaxTest / 2, src_a, kMaxTest / 2);
70
- memcpy(src_b + kMaxTest / 2, src_b, kMaxTest / 2);
71
- memcpy(src_a, src_b, kMaxTest / 2);
72
- h1 = HashDjb2(src_a, kMaxTest, 5381);
73
- h2 = HashDjb2(src_b, kMaxTest, 5381);
74
- EXPECT_NE(h1, h2);
75
-
76
- // Make same. Expect hash is same.
77
- memcpy(src_a, src_b, kMaxTest);
78
- h1 = HashDjb2(src_a, kMaxTest, 5381);
79
- h2 = HashDjb2(src_b, kMaxTest, 5381);
80
- EXPECT_EQ(h1, h2);
81
-
82
- // Mask seed different. Expect hash is different.
83
- memcpy(src_a, src_b, kMaxTest);
84
- h1 = HashDjb2(src_a, kMaxTest, 5381);
85
- h2 = HashDjb2(src_b, kMaxTest, 1234);
86
- EXPECT_NE(h1, h2);
87
-
88
- // Make one byte different in middle. Expect hash is different.
89
- memcpy(src_a, src_b, kMaxTest);
90
- ++src_b[kMaxTest / 2];
91
- h1 = HashDjb2(src_a, kMaxTest, 5381);
92
- h2 = HashDjb2(src_b, kMaxTest, 5381);
93
- EXPECT_NE(h1, h2);
94
-
95
- // Make first byte different. Expect hash is different.
96
- memcpy(src_a, src_b, kMaxTest);
97
- ++src_b[0];
98
- h1 = HashDjb2(src_a, kMaxTest, 5381);
99
- h2 = HashDjb2(src_b, kMaxTest, 5381);
100
- EXPECT_NE(h1, h2);
101
-
102
- // Make last byte different. Expect hash is different.
103
- memcpy(src_a, src_b, kMaxTest);
104
- ++src_b[kMaxTest - 1];
105
- h1 = HashDjb2(src_a, kMaxTest, 5381);
106
- h2 = HashDjb2(src_b, kMaxTest, 5381);
107
- EXPECT_NE(h1, h2);
108
-
109
- // Make a zeros. Test different lengths. Expect hash is different.
110
- memset(src_a, 0, kMaxTest);
111
- h1 = HashDjb2(src_a, kMaxTest, 5381);
112
- h2 = HashDjb2(src_a, kMaxTest / 2, 5381);
113
- EXPECT_NE(h1, h2);
114
-
115
- // Make a zeros and seed of zero. Test different lengths. Expect hash is same.
116
- memset(src_a, 0, kMaxTest);
117
- h1 = HashDjb2(src_a, kMaxTest, 0);
118
- h2 = HashDjb2(src_a, kMaxTest / 2, 0);
119
- EXPECT_EQ(h1, h2);
120
-
121
- free_aligned_buffer_page_end(src_a);
122
- free_aligned_buffer_page_end(src_b);
123
- }
124
-
125
- TEST_F(LibYUVCompareTest, BenchmarkDjb2_Opt) {
126
- const int kMaxTest = benchmark_width_ * benchmark_height_;
127
- align_buffer_page_end(src_a, kMaxTest);
128
-
129
- for (int i = 0; i < kMaxTest; ++i) {
130
- src_a[i] = i;
131
- }
132
- uint32_t h2 = ReferenceHashDjb2(src_a, kMaxTest, 5381);
133
- uint32_t h1;
134
- for (int i = 0; i < benchmark_iterations_; ++i) {
135
- h1 = HashDjb2(src_a, kMaxTest, 5381);
136
- }
137
- EXPECT_EQ(h1, h2);
138
- free_aligned_buffer_page_end(src_a);
139
- }
140
-
141
- TEST_F(LibYUVCompareTest, BenchmarkDjb2_Unaligned) {
142
- const int kMaxTest = benchmark_width_ * benchmark_height_;
143
- align_buffer_page_end(src_a, kMaxTest + 1);
144
- for (int i = 0; i < kMaxTest; ++i) {
145
- src_a[i + 1] = i;
146
- }
147
- uint32_t h2 = ReferenceHashDjb2(src_a + 1, kMaxTest, 5381);
148
- uint32_t h1;
149
- for (int i = 0; i < benchmark_iterations_; ++i) {
150
- h1 = HashDjb2(src_a + 1, kMaxTest, 5381);
151
- }
152
- EXPECT_EQ(h1, h2);
153
- free_aligned_buffer_page_end(src_a);
154
- }
155
-
156
- TEST_F(LibYUVCompareTest, BenchmarkARGBDetect_Opt) {
157
- uint32_t fourcc;
158
- const int kMaxTest = benchmark_width_ * benchmark_height_ * 4;
159
- align_buffer_page_end(src_a, kMaxTest);
160
- for (int i = 0; i < kMaxTest; ++i) {
161
- src_a[i] = 255;
162
- }
163
-
164
- src_a[0] = 0;
165
- fourcc = ARGBDetect(src_a, benchmark_width_ * 4, benchmark_width_,
166
- benchmark_height_);
167
- EXPECT_EQ(static_cast<uint32_t>(libyuv::FOURCC_BGRA), fourcc);
168
- src_a[0] = 255;
169
- src_a[3] = 0;
170
- fourcc = ARGBDetect(src_a, benchmark_width_ * 4, benchmark_width_,
171
- benchmark_height_);
172
- EXPECT_EQ(static_cast<uint32_t>(libyuv::FOURCC_ARGB), fourcc);
173
- src_a[3] = 255;
174
-
175
- for (int i = 0; i < benchmark_iterations_; ++i) {
176
- fourcc = ARGBDetect(src_a, benchmark_width_ * 4, benchmark_width_,
177
- benchmark_height_);
178
- }
179
- EXPECT_EQ(0u, fourcc);
180
-
181
- free_aligned_buffer_page_end(src_a);
182
- }
183
-
184
- TEST_F(LibYUVCompareTest, BenchmarkARGBDetect_Unaligned) {
185
- uint32_t fourcc;
186
- const int kMaxTest = benchmark_width_ * benchmark_height_ * 4 + 1;
187
- align_buffer_page_end(src_a, kMaxTest);
188
- for (int i = 1; i < kMaxTest; ++i) {
189
- src_a[i] = 255;
190
- }
191
-
192
- src_a[0 + 1] = 0;
193
- fourcc = ARGBDetect(src_a + 1, benchmark_width_ * 4, benchmark_width_,
194
- benchmark_height_);
195
- EXPECT_EQ(static_cast<uint32_t>(libyuv::FOURCC_BGRA), fourcc);
196
- src_a[0 + 1] = 255;
197
- src_a[3 + 1] = 0;
198
- fourcc = ARGBDetect(src_a + 1, benchmark_width_ * 4, benchmark_width_,
199
- benchmark_height_);
200
- EXPECT_EQ(static_cast<uint32_t>(libyuv::FOURCC_ARGB), fourcc);
201
- src_a[3 + 1] = 255;
202
-
203
- for (int i = 0; i < benchmark_iterations_; ++i) {
204
- fourcc = ARGBDetect(src_a + 1, benchmark_width_ * 4, benchmark_width_,
205
- benchmark_height_);
206
- }
207
- EXPECT_EQ(0u, fourcc);
208
-
209
- free_aligned_buffer_page_end(src_a);
210
- }
211
-
212
- #ifdef ENABLE_ROW_TESTS
213
- TEST_F(LibYUVCompareTest, BenchmarkHammingDistance_Opt) {
214
- const int kMaxWidth = 4096 * 3;
215
- align_buffer_page_end(src_a, kMaxWidth);
216
- align_buffer_page_end(src_b, kMaxWidth);
217
- memset(src_a, 0, kMaxWidth);
218
- memset(src_b, 0, kMaxWidth);
219
-
220
- // Test known value
221
- memcpy(src_a, "test0123test4567", 16);
222
- memcpy(src_b, "tick0123tock4567", 16);
223
- uint32_t h1 = HammingDistance_C(src_a, src_b, 16);
224
- EXPECT_EQ(16u, h1);
225
-
226
- // Test C vs OPT on random buffer
227
- MemRandomize(src_a, kMaxWidth);
228
- MemRandomize(src_b, kMaxWidth);
229
-
230
- uint32_t h0 = HammingDistance_C(src_a, src_b, kMaxWidth);
231
-
232
- int count =
233
- benchmark_iterations_ *
234
- ((benchmark_width_ * benchmark_height_ + kMaxWidth - 1) / kMaxWidth);
235
- for (int i = 0; i < count; ++i) {
236
- #if defined(HAS_HAMMINGDISTANCE_NEON)
237
- h1 = HammingDistance_NEON(src_a, src_b, kMaxWidth);
238
- #elif defined(HAS_HAMMINGDISTANCE_AVX2)
239
- int has_avx2 = TestCpuFlag(kCpuHasAVX2);
240
- if (has_avx2) {
241
- h1 = HammingDistance_AVX2(src_a, src_b, kMaxWidth);
242
- } else {
243
- int has_sse42 = TestCpuFlag(kCpuHasSSE42);
244
- if (has_sse42) {
245
- h1 = HammingDistance_SSE42(src_a, src_b, kMaxWidth);
246
- } else {
247
- int has_ssse3 = TestCpuFlag(kCpuHasSSSE3);
248
- if (has_ssse3) {
249
- h1 = HammingDistance_SSSE3(src_a, src_b, kMaxWidth);
250
- } else {
251
- h1 = HammingDistance_C(src_a, src_b, kMaxWidth);
252
- }
253
- }
254
- }
255
- #elif defined(HAS_HAMMINGDISTANCE_SSE42)
256
- int has_sse42 = TestCpuFlag(kCpuHasSSE42);
257
- if (has_sse42) {
258
- h1 = HammingDistance_SSE42(src_a, src_b, kMaxWidth);
259
- } else {
260
- h1 = HammingDistance_C(src_a, src_b, kMaxWidth);
261
- }
262
- #else
263
- h1 = HammingDistance_C(src_a, src_b, kMaxWidth);
264
- #endif
265
- }
266
- EXPECT_EQ(h0, h1);
267
-
268
- free_aligned_buffer_page_end(src_a);
269
- free_aligned_buffer_page_end(src_b);
270
- }
271
-
272
- TEST_F(LibYUVCompareTest, BenchmarkHammingDistance_C) {
273
- const int kMaxWidth = 4096 * 3;
274
- align_buffer_page_end(src_a, kMaxWidth);
275
- align_buffer_page_end(src_b, kMaxWidth);
276
- memset(src_a, 0, kMaxWidth);
277
- memset(src_b, 0, kMaxWidth);
278
-
279
- // Test known value
280
- memcpy(src_a, "test0123test4567", 16);
281
- memcpy(src_b, "tick0123tock4567", 16);
282
- uint32_t h1 = HammingDistance_C(src_a, src_b, 16);
283
- EXPECT_EQ(16u, h1);
284
-
285
- // Test C vs OPT on random buffer
286
- MemRandomize(src_a, kMaxWidth);
287
- MemRandomize(src_b, kMaxWidth);
288
-
289
- uint32_t h0 = HammingDistance_C(src_a, src_b, kMaxWidth);
290
-
291
- int count =
292
- benchmark_iterations_ *
293
- ((benchmark_width_ * benchmark_height_ + kMaxWidth - 1) / kMaxWidth);
294
- for (int i = 0; i < count; ++i) {
295
- h1 = HammingDistance_C(src_a, src_b, kMaxWidth);
296
- }
297
-
298
- EXPECT_EQ(h0, h1);
299
-
300
- free_aligned_buffer_page_end(src_a);
301
- free_aligned_buffer_page_end(src_b);
302
- }
303
-
304
- TEST_F(LibYUVCompareTest, BenchmarkHammingDistance) {
305
- const int kMaxWidth = 4096 * 3;
306
- align_buffer_page_end(src_a, kMaxWidth);
307
- align_buffer_page_end(src_b, kMaxWidth);
308
- memset(src_a, 0, kMaxWidth);
309
- memset(src_b, 0, kMaxWidth);
310
-
311
- memcpy(src_a, "test0123test4567", 16);
312
- memcpy(src_b, "tick0123tock4567", 16);
313
- uint64_t h1 = ComputeHammingDistance(src_a, src_b, 16);
314
- EXPECT_EQ(16u, h1);
315
-
316
- // Test C vs OPT on random buffer
317
- MemRandomize(src_a, kMaxWidth);
318
- MemRandomize(src_b, kMaxWidth);
319
-
320
- uint32_t h0 = HammingDistance_C(src_a, src_b, kMaxWidth);
321
-
322
- int count =
323
- benchmark_iterations_ *
324
- ((benchmark_width_ * benchmark_height_ + kMaxWidth - 1) / kMaxWidth);
325
- for (int i = 0; i < count; ++i) {
326
- h1 = ComputeHammingDistance(src_a, src_b, kMaxWidth);
327
- }
328
-
329
- EXPECT_EQ(h0, h1);
330
-
331
- free_aligned_buffer_page_end(src_a);
332
- free_aligned_buffer_page_end(src_b);
333
- }
334
-
335
- // Tests low levels match reference C for specified size.
336
- // The opt implementations have size limitations
337
- // For NEON the counters are 16 bit so the shorts overflow after 65536 bytes.
338
- // So doing one less iteration of the loop is the maximum.
339
- #if defined(HAS_HAMMINGDISTANCE_NEON)
340
- static const int kMaxOptCount = 65536 - 32; // 65504
341
- #else
342
- static const int kMaxOptCount = (1 << (32 - 3)) - 64; // 536870848
343
- #endif
344
-
345
- TEST_F(LibYUVCompareTest, TestHammingDistance_Opt) {
346
- uint32_t h1 = 0;
347
- const int kMaxWidth = (benchmark_width_ * benchmark_height_ + 63) & ~63;
348
- align_buffer_page_end(src_a, kMaxWidth);
349
- align_buffer_page_end(src_b, kMaxWidth);
350
- memset(src_a, 255u, kMaxWidth);
351
- memset(src_b, 0u, kMaxWidth);
352
-
353
- uint64_t h0 = ComputeHammingDistance(src_a, src_b, kMaxWidth);
354
- EXPECT_EQ(kMaxWidth * 8ULL, h0);
355
-
356
- for (int i = 0; i < benchmark_iterations_; ++i) {
357
- #if defined(HAS_HAMMINGDISTANCE_NEON)
358
- h1 = HammingDistance_NEON(src_a, src_b, kMaxWidth);
359
- #elif defined(HAS_HAMMINGDISTANCE_AVX2)
360
- int has_avx2 = TestCpuFlag(kCpuHasAVX2);
361
- if (has_avx2) {
362
- h1 = HammingDistance_AVX2(src_a, src_b, kMaxWidth);
363
- } else {
364
- int has_sse42 = TestCpuFlag(kCpuHasSSE42);
365
- if (has_sse42) {
366
- h1 = HammingDistance_SSE42(src_a, src_b, kMaxWidth);
367
- } else {
368
- int has_ssse3 = TestCpuFlag(kCpuHasSSSE3);
369
- if (has_ssse3) {
370
- h1 = HammingDistance_SSSE3(src_a, src_b, kMaxWidth);
371
- } else {
372
- h1 = HammingDistance_C(src_a, src_b, kMaxWidth);
373
- }
374
- }
375
- }
376
- #elif defined(HAS_HAMMINGDISTANCE_SSE42)
377
- int has_sse42 = TestCpuFlag(kCpuHasSSE42);
378
- if (has_sse42) {
379
- h1 = HammingDistance_SSE42(src_a, src_b, kMaxWidth);
380
- } else {
381
- h1 = HammingDistance_C(src_a, src_b, kMaxWidth);
382
- }
383
- #else
384
- h1 = HammingDistance_C(src_a, src_b, kMaxWidth);
385
- #endif
386
- }
387
-
388
- // A large count will cause the low level to potentially overflow so the
389
- // result can not be expected to be correct.
390
- // TODO(fbarchard): Consider expecting the low 16 bits to match.
391
- if (kMaxWidth <= kMaxOptCount) {
392
- EXPECT_EQ(kMaxWidth * 8U, h1);
393
- } else {
394
- if (kMaxWidth * 8ULL != static_cast<uint64_t>(h1)) {
395
- printf(
396
- "warning - HammingDistance_Opt %u does not match %llu "
397
- "but length of %u is longer than guaranteed.\n",
398
- h1, kMaxWidth * 8ULL, kMaxWidth);
399
- } else {
400
- printf(
401
- "warning - HammingDistance_Opt %u matches but length of %u "
402
- "is longer than guaranteed.\n",
403
- h1, kMaxWidth);
404
- }
405
- }
406
-
407
- free_aligned_buffer_page_end(src_a);
408
- free_aligned_buffer_page_end(src_b);
409
- }
410
- #endif // ENABLE_ROW_TESTS
411
-
412
- TEST_F(LibYUVCompareTest, TestHammingDistance) {
413
- align_buffer_page_end(src_a, benchmark_width_ * benchmark_height_);
414
- align_buffer_page_end(src_b, benchmark_width_ * benchmark_height_);
415
- memset(src_a, 255u, benchmark_width_ * benchmark_height_);
416
- memset(src_b, 0, benchmark_width_ * benchmark_height_);
417
-
418
- uint64_t h1 = 0;
419
- for (int i = 0; i < benchmark_iterations_; ++i) {
420
- h1 = ComputeHammingDistance(src_a, src_b,
421
- benchmark_width_ * benchmark_height_);
422
- }
423
- EXPECT_EQ(benchmark_width_ * benchmark_height_ * 8ULL, h1);
424
-
425
- free_aligned_buffer_page_end(src_a);
426
- free_aligned_buffer_page_end(src_b);
427
- }
428
-
429
- TEST_F(LibYUVCompareTest, BenchmarkSumSquareError_Opt) {
430
- const int kMaxWidth = 4096 * 3;
431
- align_buffer_page_end(src_a, kMaxWidth);
432
- align_buffer_page_end(src_b, kMaxWidth);
433
- memset(src_a, 0, kMaxWidth);
434
- memset(src_b, 0, kMaxWidth);
435
-
436
- memcpy(src_a, "test0123test4567", 16);
437
- memcpy(src_b, "tick0123tock4567", 16);
438
- uint64_t h1 = ComputeSumSquareError(src_a, src_b, 16);
439
- EXPECT_EQ(790u, h1);
440
-
441
- for (int i = 0; i < kMaxWidth; ++i) {
442
- src_a[i] = i;
443
- src_b[i] = i;
444
- }
445
- memset(src_a, 0, kMaxWidth);
446
- memset(src_b, 0, kMaxWidth);
447
-
448
- int count =
449
- benchmark_iterations_ *
450
- ((benchmark_width_ * benchmark_height_ + kMaxWidth - 1) / kMaxWidth);
451
- for (int i = 0; i < count; ++i) {
452
- h1 = ComputeSumSquareError(src_a, src_b, kMaxWidth);
453
- }
454
-
455
- EXPECT_EQ(0u, h1);
456
-
457
- free_aligned_buffer_page_end(src_a);
458
- free_aligned_buffer_page_end(src_b);
459
- }
460
-
461
- TEST_F(LibYUVCompareTest, SumSquareError) {
462
- const int kMaxWidth = 4096 * 3;
463
- align_buffer_page_end(src_a, kMaxWidth);
464
- align_buffer_page_end(src_b, kMaxWidth);
465
- memset(src_a, 0, kMaxWidth);
466
- memset(src_b, 0, kMaxWidth);
467
-
468
- uint64_t err;
469
- err = ComputeSumSquareError(src_a, src_b, kMaxWidth);
470
-
471
- EXPECT_EQ(0u, err);
472
-
473
- memset(src_a, 1, kMaxWidth);
474
- err = ComputeSumSquareError(src_a, src_b, kMaxWidth);
475
-
476
- EXPECT_EQ(static_cast<int>(err), kMaxWidth);
477
-
478
- memset(src_a, 190, kMaxWidth);
479
- memset(src_b, 193, kMaxWidth);
480
- err = ComputeSumSquareError(src_a, src_b, kMaxWidth);
481
-
482
- EXPECT_EQ(static_cast<int>(err), kMaxWidth * 3 * 3);
483
-
484
- for (int i = 0; i < kMaxWidth; ++i) {
485
- src_a[i] = (fastrand() & 0xff);
486
- src_b[i] = (fastrand() & 0xff);
487
- }
488
-
489
- MaskCpuFlags(disable_cpu_flags_);
490
- uint64_t c_err = ComputeSumSquareError(src_a, src_b, kMaxWidth);
491
-
492
- MaskCpuFlags(benchmark_cpu_info_);
493
- uint64_t opt_err = ComputeSumSquareError(src_a, src_b, kMaxWidth);
494
-
495
- EXPECT_EQ(c_err, opt_err);
496
-
497
- free_aligned_buffer_page_end(src_a);
498
- free_aligned_buffer_page_end(src_b);
499
- }
500
-
501
- TEST_F(LibYUVCompareTest, BenchmarkPsnr_Opt) {
502
- align_buffer_page_end(src_a, benchmark_width_ * benchmark_height_);
503
- align_buffer_page_end(src_b, benchmark_width_ * benchmark_height_);
504
- for (int i = 0; i < benchmark_width_ * benchmark_height_; ++i) {
505
- src_a[i] = i;
506
- src_b[i] = i;
507
- }
508
-
509
- MaskCpuFlags(benchmark_cpu_info_);
510
-
511
- double opt_time = get_time();
512
- for (int i = 0; i < benchmark_iterations_; ++i) {
513
- CalcFramePsnr(src_a, benchmark_width_, src_b, benchmark_width_,
514
- benchmark_width_, benchmark_height_);
515
- }
516
-
517
- opt_time = (get_time() - opt_time) / benchmark_iterations_;
518
- printf("BenchmarkPsnr_Opt - %8.2f us opt\n", opt_time * 1e6);
519
-
520
- EXPECT_EQ(0, 0);
521
-
522
- free_aligned_buffer_page_end(src_a);
523
- free_aligned_buffer_page_end(src_b);
524
- }
525
-
526
- TEST_F(LibYUVCompareTest, BenchmarkPsnr_Unaligned) {
527
- align_buffer_page_end(src_a, benchmark_width_ * benchmark_height_ + 1);
528
- align_buffer_page_end(src_b, benchmark_width_ * benchmark_height_);
529
- for (int i = 0; i < benchmark_width_ * benchmark_height_; ++i) {
530
- src_a[i + 1] = i;
531
- src_b[i] = i;
532
- }
533
-
534
- MaskCpuFlags(benchmark_cpu_info_);
535
-
536
- double opt_time = get_time();
537
- for (int i = 0; i < benchmark_iterations_; ++i) {
538
- CalcFramePsnr(src_a + 1, benchmark_width_, src_b, benchmark_width_,
539
- benchmark_width_, benchmark_height_);
540
- }
541
-
542
- opt_time = (get_time() - opt_time) / benchmark_iterations_;
543
- printf("BenchmarkPsnr_Opt - %8.2f us opt\n", opt_time * 1e6);
544
-
545
- EXPECT_EQ(0, 0);
546
-
547
- free_aligned_buffer_page_end(src_a);
548
- free_aligned_buffer_page_end(src_b);
549
- }
550
-
551
- TEST_F(LibYUVCompareTest, Psnr) {
552
- const int kSrcWidth = benchmark_width_;
553
- const int kSrcHeight = benchmark_height_;
554
- const int b = 128;
555
- const int kSrcPlaneSize = (kSrcWidth + b * 2) * (kSrcHeight + b * 2);
556
- const int kSrcStride = 2 * b + kSrcWidth;
557
- align_buffer_page_end(src_a, kSrcPlaneSize);
558
- align_buffer_page_end(src_b, kSrcPlaneSize);
559
- memset(src_a, 0, kSrcPlaneSize);
560
- memset(src_b, 0, kSrcPlaneSize);
561
-
562
- double err;
563
- err = CalcFramePsnr(src_a + kSrcStride * b + b, kSrcStride,
564
- src_b + kSrcStride * b + b, kSrcStride, kSrcWidth,
565
- kSrcHeight);
566
-
567
- EXPECT_EQ(err, kMaxPsnr);
568
-
569
- memset(src_a, 255, kSrcPlaneSize);
570
-
571
- err = CalcFramePsnr(src_a + kSrcStride * b + b, kSrcStride,
572
- src_b + kSrcStride * b + b, kSrcStride, kSrcWidth,
573
- kSrcHeight);
574
-
575
- EXPECT_EQ(err, 0.0);
576
-
577
- memset(src_a, 1, kSrcPlaneSize);
578
-
579
- err = CalcFramePsnr(src_a + kSrcStride * b + b, kSrcStride,
580
- src_b + kSrcStride * b + b, kSrcStride, kSrcWidth,
581
- kSrcHeight);
582
-
583
- EXPECT_GT(err, 48.0);
584
- EXPECT_LT(err, 49.0);
585
-
586
- for (int i = 0; i < kSrcPlaneSize; ++i) {
587
- src_a[i] = i;
588
- }
589
-
590
- err = CalcFramePsnr(src_a + kSrcStride * b + b, kSrcStride,
591
- src_b + kSrcStride * b + b, kSrcStride, kSrcWidth,
592
- kSrcHeight);
593
-
594
- EXPECT_GT(err, 2.0);
595
- if (kSrcWidth * kSrcHeight >= 256) {
596
- EXPECT_LT(err, 6.0);
597
- }
598
-
599
- memset(src_a, 0, kSrcPlaneSize);
600
- memset(src_b, 0, kSrcPlaneSize);
601
-
602
- for (int i = b; i < (kSrcHeight + b); ++i) {
603
- for (int j = b; j < (kSrcWidth + b); ++j) {
604
- src_a[(i * kSrcStride) + j] = (fastrand() & 0xff);
605
- src_b[(i * kSrcStride) + j] = (fastrand() & 0xff);
606
- }
607
- }
608
-
609
- MaskCpuFlags(disable_cpu_flags_);
610
- double c_err, opt_err;
611
-
612
- c_err = CalcFramePsnr(src_a + kSrcStride * b + b, kSrcStride,
613
- src_b + kSrcStride * b + b, kSrcStride, kSrcWidth,
614
- kSrcHeight);
615
-
616
- MaskCpuFlags(benchmark_cpu_info_);
617
-
618
- opt_err = CalcFramePsnr(src_a + kSrcStride * b + b, kSrcStride,
619
- src_b + kSrcStride * b + b, kSrcStride, kSrcWidth,
620
- kSrcHeight);
621
-
622
- EXPECT_EQ(opt_err, c_err);
623
-
624
- free_aligned_buffer_page_end(src_a);
625
- free_aligned_buffer_page_end(src_b);
626
- }
627
-
628
- TEST_F(LibYUVCompareTest, DISABLED_BenchmarkSsim_Opt) {
629
- align_buffer_page_end(src_a, benchmark_width_ * benchmark_height_);
630
- align_buffer_page_end(src_b, benchmark_width_ * benchmark_height_);
631
- for (int i = 0; i < benchmark_width_ * benchmark_height_; ++i) {
632
- src_a[i] = i;
633
- src_b[i] = i;
634
- }
635
-
636
- MaskCpuFlags(benchmark_cpu_info_);
637
-
638
- double opt_time = get_time();
639
- for (int i = 0; i < benchmark_iterations_; ++i) {
640
- CalcFrameSsim(src_a, benchmark_width_, src_b, benchmark_width_,
641
- benchmark_width_, benchmark_height_);
642
- }
643
-
644
- opt_time = (get_time() - opt_time) / benchmark_iterations_;
645
- printf("BenchmarkSsim_Opt - %8.2f us opt\n", opt_time * 1e6);
646
-
647
- EXPECT_EQ(0, 0); // Pass if we get this far.
648
-
649
- free_aligned_buffer_page_end(src_a);
650
- free_aligned_buffer_page_end(src_b);
651
- }
652
-
653
- TEST_F(LibYUVCompareTest, Ssim) {
654
- const int kSrcWidth = benchmark_width_;
655
- const int kSrcHeight = benchmark_height_;
656
- const int b = 128;
657
- const int kSrcPlaneSize = (kSrcWidth + b * 2) * (kSrcHeight + b * 2);
658
- const int kSrcStride = 2 * b + kSrcWidth;
659
- align_buffer_page_end(src_a, kSrcPlaneSize);
660
- align_buffer_page_end(src_b, kSrcPlaneSize);
661
- memset(src_a, 0, kSrcPlaneSize);
662
- memset(src_b, 0, kSrcPlaneSize);
663
-
664
- if (kSrcWidth <= 8 || kSrcHeight <= 8) {
665
- printf("warning - Ssim size too small. Testing function executes.\n");
666
- }
667
-
668
- double err;
669
- err = CalcFrameSsim(src_a + kSrcStride * b + b, kSrcStride,
670
- src_b + kSrcStride * b + b, kSrcStride, kSrcWidth,
671
- kSrcHeight);
672
-
673
- if (kSrcWidth > 8 && kSrcHeight > 8) {
674
- EXPECT_EQ(err, 1.0);
675
- }
676
-
677
- memset(src_a, 255, kSrcPlaneSize);
678
-
679
- err = CalcFrameSsim(src_a + kSrcStride * b + b, kSrcStride,
680
- src_b + kSrcStride * b + b, kSrcStride, kSrcWidth,
681
- kSrcHeight);
682
-
683
- if (kSrcWidth > 8 && kSrcHeight > 8) {
684
- EXPECT_LT(err, 0.0001);
685
- }
686
-
687
- memset(src_a, 1, kSrcPlaneSize);
688
-
689
- err = CalcFrameSsim(src_a + kSrcStride * b + b, kSrcStride,
690
- src_b + kSrcStride * b + b, kSrcStride, kSrcWidth,
691
- kSrcHeight);
692
-
693
- if (kSrcWidth > 8 && kSrcHeight > 8) {
694
- EXPECT_GT(err, 0.0001);
695
- EXPECT_LT(err, 0.9);
696
- }
697
-
698
- for (int i = 0; i < kSrcPlaneSize; ++i) {
699
- src_a[i] = i;
700
- }
701
-
702
- err = CalcFrameSsim(src_a + kSrcStride * b + b, kSrcStride,
703
- src_b + kSrcStride * b + b, kSrcStride, kSrcWidth,
704
- kSrcHeight);
705
-
706
- if (kSrcWidth > 8 && kSrcHeight > 8) {
707
- EXPECT_GT(err, 0.0);
708
- EXPECT_LT(err, 0.01);
709
- }
710
-
711
- for (int i = b; i < (kSrcHeight + b); ++i) {
712
- for (int j = b; j < (kSrcWidth + b); ++j) {
713
- src_a[(i * kSrcStride) + j] = (fastrand() & 0xff);
714
- src_b[(i * kSrcStride) + j] = (fastrand() & 0xff);
715
- }
716
- }
717
-
718
- MaskCpuFlags(disable_cpu_flags_);
719
- double c_err, opt_err;
720
-
721
- c_err = CalcFrameSsim(src_a + kSrcStride * b + b, kSrcStride,
722
- src_b + kSrcStride * b + b, kSrcStride, kSrcWidth,
723
- kSrcHeight);
724
-
725
- MaskCpuFlags(benchmark_cpu_info_);
726
-
727
- opt_err = CalcFrameSsim(src_a + kSrcStride * b + b, kSrcStride,
728
- src_b + kSrcStride * b + b, kSrcStride, kSrcWidth,
729
- kSrcHeight);
730
-
731
- if (kSrcWidth > 8 && kSrcHeight > 8) {
732
- EXPECT_EQ(opt_err, c_err);
733
- }
734
-
735
- free_aligned_buffer_page_end(src_a);
736
- free_aligned_buffer_page_end(src_b);
737
- }
738
-
739
- } // namespace libyuv