react-native-vision-camera-spoof-detector 1.0.21 → 1.0.23

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 (197) hide show
  1. package/.gitattributes +2 -0
  2. package/.gitignore +27 -0
  3. package/CHANGELOG.md +2 -2
  4. package/CONTRIBUTING.md +2 -2
  5. package/README.md +442 -443
  6. package/android/build.gradle +12 -4
  7. package/android/src/main/cpp/CMakeLists.txt +101 -94
  8. package/android/src/main/cpp/libyuv/.clang-format +6 -6
  9. package/android/src/main/cpp/libyuv/.gn +40 -40
  10. package/android/src/main/cpp/libyuv/.vpython3 +410 -410
  11. package/android/src/main/cpp/libyuv/AUTHORS +7 -7
  12. package/android/src/main/cpp/libyuv/Android.bp +202 -202
  13. package/android/src/main/cpp/libyuv/Android.mk +106 -106
  14. package/android/src/main/cpp/libyuv/BUILD.gn +490 -490
  15. package/android/src/main/cpp/libyuv/CM_linux_packages.cmake +70 -70
  16. package/android/src/main/cpp/libyuv/CMakeLists.txt +259 -252
  17. package/android/src/main/cpp/libyuv/DEPS +935 -935
  18. package/android/src/main/cpp/libyuv/DIR_METADATA +3 -3
  19. package/android/src/main/cpp/libyuv/LICENSE +29 -29
  20. package/android/src/main/cpp/libyuv/OWNERS +11 -11
  21. package/android/src/main/cpp/libyuv/PATENTS +23 -23
  22. package/android/src/main/cpp/libyuv/PRESUBMIT.py +65 -65
  23. package/android/src/main/cpp/libyuv/README.chromium +11 -11
  24. package/android/src/main/cpp/libyuv/README.md +19 -19
  25. package/android/src/main/cpp/libyuv/build_overrides/build.gni +60 -60
  26. package/android/src/main/cpp/libyuv/build_overrides/gtest.gni +19 -19
  27. package/android/src/main/cpp/libyuv/build_overrides/partition_alloc.gni +17 -17
  28. package/android/src/main/cpp/libyuv/codereview.settings +5 -5
  29. package/android/src/main/cpp/libyuv/docs/deprecated_builds.md +409 -409
  30. package/android/src/main/cpp/libyuv/docs/environment_variables.md +64 -64
  31. package/android/src/main/cpp/libyuv/docs/feature_detection.md +108 -108
  32. package/android/src/main/cpp/libyuv/docs/filtering.md +196 -196
  33. package/android/src/main/cpp/libyuv/docs/formats.md +208 -208
  34. package/android/src/main/cpp/libyuv/docs/getting_started.md +296 -296
  35. package/android/src/main/cpp/libyuv/docs/rotation.md +107 -107
  36. package/android/src/main/cpp/libyuv/download_vs_toolchain.py +29 -29
  37. package/android/src/main/cpp/libyuv/include/libyuv/basic_types.h +68 -68
  38. package/android/src/main/cpp/libyuv/include/libyuv/compare.h +111 -111
  39. package/android/src/main/cpp/libyuv/include/libyuv/compare_row.h +112 -112
  40. package/android/src/main/cpp/libyuv/include/libyuv/convert.h +1117 -1117
  41. package/android/src/main/cpp/libyuv/include/libyuv/convert_argb.h +2335 -2335
  42. package/android/src/main/cpp/libyuv/include/libyuv/convert_from.h +203 -203
  43. package/android/src/main/cpp/libyuv/include/libyuv/convert_from_argb.h +394 -394
  44. package/android/src/main/cpp/libyuv/include/libyuv/cpu_id.h +147 -147
  45. package/android/src/main/cpp/libyuv/include/libyuv/cpu_support.h +99 -99
  46. package/android/src/main/cpp/libyuv/include/libyuv/loongson_intrinsics.h +1949 -1949
  47. package/android/src/main/cpp/libyuv/include/libyuv/mjpeg_decoder.h +195 -195
  48. package/android/src/main/cpp/libyuv/include/libyuv/planar_functions.h +1131 -1131
  49. package/android/src/main/cpp/libyuv/include/libyuv/rotate.h +296 -296
  50. package/android/src/main/cpp/libyuv/include/libyuv/rotate_argb.h +37 -37
  51. package/android/src/main/cpp/libyuv/include/libyuv/rotate_row.h +265 -265
  52. package/android/src/main/cpp/libyuv/include/libyuv/row.h +6738 -6738
  53. package/android/src/main/cpp/libyuv/include/libyuv/row_sve.h +2154 -2154
  54. package/android/src/main/cpp/libyuv/include/libyuv/scale.h +336 -336
  55. package/android/src/main/cpp/libyuv/include/libyuv/scale_argb.h +76 -76
  56. package/android/src/main/cpp/libyuv/include/libyuv/scale_rgb.h +42 -42
  57. package/android/src/main/cpp/libyuv/include/libyuv/scale_row.h +1726 -1726
  58. package/android/src/main/cpp/libyuv/include/libyuv/scale_uv.h +51 -51
  59. package/android/src/main/cpp/libyuv/include/libyuv/version.h +16 -16
  60. package/android/src/main/cpp/libyuv/include/libyuv/video_common.h +222 -222
  61. package/android/src/main/cpp/libyuv/include/libyuv.h +33 -33
  62. package/android/src/main/cpp/libyuv/infra/config/OWNERS +3 -3
  63. package/android/src/main/cpp/libyuv/infra/config/PRESUBMIT.py +17 -17
  64. package/android/src/main/cpp/libyuv/infra/config/README.md +2 -2
  65. package/android/src/main/cpp/libyuv/infra/config/codereview.settings +6 -6
  66. package/android/src/main/cpp/libyuv/infra/config/commit-queue.cfg +144 -144
  67. package/android/src/main/cpp/libyuv/infra/config/cr-buildbucket.cfg +1185 -1185
  68. package/android/src/main/cpp/libyuv/infra/config/luci-logdog.cfg +9 -9
  69. package/android/src/main/cpp/libyuv/infra/config/luci-milo.cfg +246 -246
  70. package/android/src/main/cpp/libyuv/infra/config/luci-scheduler.cfg +385 -385
  71. package/android/src/main/cpp/libyuv/infra/config/main.star +402 -402
  72. package/android/src/main/cpp/libyuv/infra/config/project.cfg +16 -16
  73. package/android/src/main/cpp/libyuv/infra/config/realms.cfg +111 -111
  74. package/android/src/main/cpp/libyuv/libyuv.gni +34 -34
  75. package/android/src/main/cpp/libyuv/libyuv.gyp +149 -149
  76. package/android/src/main/cpp/libyuv/libyuv.gypi +87 -87
  77. package/android/src/main/cpp/libyuv/linux.mk +96 -96
  78. package/android/src/main/cpp/libyuv/public.mk +13 -13
  79. package/android/src/main/cpp/libyuv/pylintrc +49 -49
  80. package/android/src/main/cpp/libyuv/riscv_script/prepare_toolchain_qemu.sh +74 -74
  81. package/android/src/main/cpp/libyuv/riscv_script/riscv-clang.cmake +56 -56
  82. package/android/src/main/cpp/libyuv/riscv_script/run_qemu.sh +15 -15
  83. package/android/src/main/cpp/libyuv/source/compare.cc +435 -435
  84. package/android/src/main/cpp/libyuv/source/compare_common.cc +74 -74
  85. package/android/src/main/cpp/libyuv/source/compare_gcc.cc +362 -362
  86. package/android/src/main/cpp/libyuv/source/compare_neon.cc +96 -96
  87. package/android/src/main/cpp/libyuv/source/compare_neon64.cc +223 -223
  88. package/android/src/main/cpp/libyuv/source/compare_win.cc +241 -241
  89. package/android/src/main/cpp/libyuv/source/convert.cc +4746 -4746
  90. package/android/src/main/cpp/libyuv/source/convert_argb.cc +9179 -9179
  91. package/android/src/main/cpp/libyuv/source/convert_from.cc +866 -866
  92. package/android/src/main/cpp/libyuv/source/convert_from_argb.cc +3671 -3671
  93. package/android/src/main/cpp/libyuv/source/convert_jpeg.cc +602 -602
  94. package/android/src/main/cpp/libyuv/source/convert_to_argb.cc +391 -391
  95. package/android/src/main/cpp/libyuv/source/convert_to_i420.cc +288 -288
  96. package/android/src/main/cpp/libyuv/source/cpu_id.cc +496 -496
  97. package/android/src/main/cpp/libyuv/source/mjpeg_decoder.cc +580 -580
  98. package/android/src/main/cpp/libyuv/source/mjpeg_validate.cc +71 -71
  99. package/android/src/main/cpp/libyuv/source/planar_functions.cc +5663 -5663
  100. package/android/src/main/cpp/libyuv/source/rotate.cc +1241 -1241
  101. package/android/src/main/cpp/libyuv/source/rotate_any.cc +76 -76
  102. package/android/src/main/cpp/libyuv/source/rotate_argb.cc +259 -259
  103. package/android/src/main/cpp/libyuv/source/rotate_common.cc +208 -208
  104. package/android/src/main/cpp/libyuv/source/rotate_gcc.cc +505 -505
  105. package/android/src/main/cpp/libyuv/source/rotate_lsx.cc +233 -233
  106. package/android/src/main/cpp/libyuv/source/rotate_neon.cc +219 -219
  107. package/android/src/main/cpp/libyuv/source/rotate_neon64.cc +273 -273
  108. package/android/src/main/cpp/libyuv/source/rotate_sme.cc +174 -174
  109. package/android/src/main/cpp/libyuv/source/rotate_win.cc +253 -253
  110. package/android/src/main/cpp/libyuv/source/row_any.cc +2519 -2519
  111. package/android/src/main/cpp/libyuv/source/row_common.cc +4461 -4461
  112. package/android/src/main/cpp/libyuv/source/row_gcc.cc +9570 -9570
  113. package/android/src/main/cpp/libyuv/source/row_lasx.cc +2343 -2343
  114. package/android/src/main/cpp/libyuv/source/row_lsx.cc +3030 -3030
  115. package/android/src/main/cpp/libyuv/source/row_neon.cc +4026 -4026
  116. package/android/src/main/cpp/libyuv/source/row_neon64.cc +5617 -5617
  117. package/android/src/main/cpp/libyuv/source/row_rvv.cc +2599 -2599
  118. package/android/src/main/cpp/libyuv/source/row_sme.cc +1183 -1183
  119. package/android/src/main/cpp/libyuv/source/row_sve.cc +1088 -1088
  120. package/android/src/main/cpp/libyuv/source/row_win.cc +6453 -6453
  121. package/android/src/main/cpp/libyuv/source/scale.cc +2710 -2710
  122. package/android/src/main/cpp/libyuv/source/scale_any.cc +991 -991
  123. package/android/src/main/cpp/libyuv/source/scale_argb.cc +1158 -1158
  124. package/android/src/main/cpp/libyuv/source/scale_common.cc +1977 -1977
  125. package/android/src/main/cpp/libyuv/source/scale_gcc.cc +2947 -2947
  126. package/android/src/main/cpp/libyuv/source/scale_lsx.cc +739 -739
  127. package/android/src/main/cpp/libyuv/source/scale_neon.cc +1449 -1449
  128. package/android/src/main/cpp/libyuv/source/scale_neon64.cc +1552 -1552
  129. package/android/src/main/cpp/libyuv/source/scale_rgb.cc +82 -82
  130. package/android/src/main/cpp/libyuv/source/scale_rvv.cc +1971 -1971
  131. package/android/src/main/cpp/libyuv/source/scale_sme.cc +555 -555
  132. package/android/src/main/cpp/libyuv/source/scale_uv.cc +1159 -1159
  133. package/android/src/main/cpp/libyuv/source/scale_win.cc +1392 -1392
  134. package/android/src/main/cpp/libyuv/source/test.sh +35 -35
  135. package/android/src/main/cpp/libyuv/source/video_common.cc +62 -62
  136. package/android/src/main/cpp/libyuv/tools_libyuv/OWNERS +4 -4
  137. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/roll_deps.py +931 -931
  138. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/roll_deps_test.py +164 -164
  139. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS +21 -21
  140. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.new +13 -13
  141. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.old +13 -13
  142. package/android/src/main/cpp/libyuv/tools_libyuv/get_landmines.py +38 -38
  143. package/android/src/main/cpp/libyuv/tools_libyuv/msan/OWNERS +3 -3
  144. package/android/src/main/cpp/libyuv/tools_libyuv/msan/blacklist.txt +9 -9
  145. package/android/src/main/cpp/libyuv/tools_libyuv/ubsan/OWNERS +3 -3
  146. package/android/src/main/cpp/libyuv/tools_libyuv/ubsan/blacklist.txt +15 -15
  147. package/android/src/main/cpp/libyuv/tools_libyuv/ubsan/vptr_blacklist.txt +25 -25
  148. package/android/src/main/cpp/libyuv/unit_test/basictypes_test.cc +43 -43
  149. package/android/src/main/cpp/libyuv/unit_test/color_test.cc +848 -848
  150. package/android/src/main/cpp/libyuv/unit_test/compare_test.cc +739 -739
  151. package/android/src/main/cpp/libyuv/unit_test/convert_argb_test.cc +2867 -2867
  152. package/android/src/main/cpp/libyuv/unit_test/convert_test.cc +2133 -2133
  153. package/android/src/main/cpp/libyuv/unit_test/cpu_test.cc +427 -427
  154. package/android/src/main/cpp/libyuv/unit_test/cpu_thread_test.cc +63 -63
  155. package/android/src/main/cpp/libyuv/unit_test/math_test.cc +160 -160
  156. package/android/src/main/cpp/libyuv/unit_test/planar_test.cc +4731 -4731
  157. package/android/src/main/cpp/libyuv/unit_test/rotate_argb_test.cc +334 -334
  158. package/android/src/main/cpp/libyuv/unit_test/rotate_test.cc +962 -962
  159. package/android/src/main/cpp/libyuv/unit_test/scale_argb_test.cc +590 -590
  160. package/android/src/main/cpp/libyuv/unit_test/scale_plane_test.cc +465 -465
  161. package/android/src/main/cpp/libyuv/unit_test/scale_rgb_test.cc +280 -280
  162. package/android/src/main/cpp/libyuv/unit_test/scale_test.cc +1135 -1135
  163. package/android/src/main/cpp/libyuv/unit_test/scale_uv_test.cc +249 -249
  164. package/android/src/main/cpp/libyuv/unit_test/testdata/arm_v7.txt +12 -12
  165. package/android/src/main/cpp/libyuv/unit_test/testdata/mips.txt +7 -7
  166. package/android/src/main/cpp/libyuv/unit_test/testdata/mips_loongson2k.txt +5 -5
  167. package/android/src/main/cpp/libyuv/unit_test/testdata/mips_loongson3.txt +10 -10
  168. package/android/src/main/cpp/libyuv/unit_test/testdata/mips_loongson_mmi.txt +7 -7
  169. package/android/src/main/cpp/libyuv/unit_test/testdata/riscv64.txt +3 -3
  170. package/android/src/main/cpp/libyuv/unit_test/testdata/riscv64_rvv.txt +3 -3
  171. package/android/src/main/cpp/libyuv/unit_test/testdata/riscv64_rvv_zvfh.txt +3 -3
  172. package/android/src/main/cpp/libyuv/unit_test/testdata/tegra3.txt +23 -23
  173. package/android/src/main/cpp/libyuv/unit_test/unit_test.cc +581 -581
  174. package/android/src/main/cpp/libyuv/unit_test/unit_test.h +232 -232
  175. package/android/src/main/cpp/libyuv/unit_test/video_common_test.cc +112 -112
  176. package/android/src/main/cpp/libyuv/util/Makefile +9 -9
  177. package/android/src/main/cpp/libyuv/util/color.cc +120 -120
  178. package/android/src/main/cpp/libyuv/util/compare.cc +67 -67
  179. package/android/src/main/cpp/libyuv/util/cpuid.c +211 -211
  180. package/android/src/main/cpp/libyuv/util/i444tonv12_eg.cc +27 -27
  181. package/android/src/main/cpp/libyuv/util/psnr.cc +291 -291
  182. package/android/src/main/cpp/libyuv/util/psnr.h +47 -47
  183. package/android/src/main/cpp/libyuv/util/psnr_main.cc +620 -620
  184. package/android/src/main/cpp/libyuv/util/ssim.cc +364 -364
  185. package/android/src/main/cpp/libyuv/util/ssim.h +38 -38
  186. package/android/src/main/cpp/libyuv/util/yuvconstants.c +114 -114
  187. package/android/src/main/cpp/libyuv/util/yuvconvert.cc +367 -367
  188. package/android/src/main/cpp/libyuv/winarm.mk +47 -47
  189. package/package.json +86 -84
  190. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  191. package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
  192. package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
  193. package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  194. package/android/.gradle/8.9/gc.properties +0 -0
  195. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  196. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  197. package/android/.gradle/vcs-1/gc.properties +0 -0
@@ -1,291 +1,291 @@
1
- /*
2
- * Copyright 2013 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 "./psnr.h" // NOLINT
12
-
13
- #ifdef _OPENMP
14
- #include <omp.h>
15
- #endif
16
- #ifdef _MSC_VER
17
- #include <intrin.h> // For __cpuid()
18
- #endif
19
-
20
- #ifdef __cplusplus
21
- extern "C" {
22
- #endif
23
-
24
- typedef unsigned int uint32_t; // NOLINT
25
- #ifdef _MSC_VER
26
- typedef unsigned __int64 uint64_t;
27
- #else // COMPILER_MSVC
28
- #if defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__)
29
- typedef unsigned long uint64_t; // NOLINT
30
- #else // defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__)
31
- typedef unsigned long long uint64_t; // NOLINT
32
- #endif // __LP64__
33
- #endif // _MSC_VER
34
-
35
- // libyuv provides this function when linking library for jpeg support.
36
- #if !defined(HAVE_JPEG)
37
-
38
- #if !defined(LIBYUV_DISABLE_NEON) && defined(__ARM_NEON__) && \
39
- !defined(__aarch64__)
40
- #define HAS_SUMSQUAREERROR_NEON
41
- static uint32_t SumSquareError_NEON(const uint8_t* src_a,
42
- const uint8_t* src_b,
43
- int count) {
44
- volatile uint32_t sse;
45
- asm volatile(
46
- "vmov.u8 q7, #0 \n"
47
- "vmov.u8 q9, #0 \n"
48
- "vmov.u8 q8, #0 \n"
49
- "vmov.u8 q10, #0 \n"
50
-
51
- "1: \n"
52
- "vld1.u8 {q0}, [%0]! \n"
53
- "vld1.u8 {q1}, [%1]! \n"
54
- "vsubl.u8 q2, d0, d2 \n"
55
- "vsubl.u8 q3, d1, d3 \n"
56
- "vmlal.s16 q7, d4, d4 \n"
57
- "vmlal.s16 q8, d6, d6 \n"
58
- "vmlal.s16 q8, d5, d5 \n"
59
- "vmlal.s16 q10, d7, d7 \n"
60
- "subs %2, %2, #16 \n"
61
- "bhi 1b \n"
62
-
63
- "vadd.u32 q7, q7, q8 \n"
64
- "vadd.u32 q9, q9, q10 \n"
65
- "vadd.u32 q10, q7, q9 \n"
66
- "vpaddl.u32 q1, q10 \n"
67
- "vadd.u64 d0, d2, d3 \n"
68
- "vmov.32 %3, d0[0] \n"
69
- : "+r"(src_a), "+r"(src_b), "+r"(count), "=r"(sse)
70
- :
71
- : "memory", "cc", "q0", "q1", "q2", "q3", "q7", "q8", "q9", "q10");
72
- return sse;
73
- }
74
- #elif !defined(LIBYUV_DISABLE_NEON) && defined(__aarch64__)
75
- #define HAS_SUMSQUAREERROR_NEON
76
- static uint32_t SumSquareError_NEON(const uint8_t* src_a,
77
- const uint8_t* src_b,
78
- int count) {
79
- volatile uint32_t sse;
80
- asm volatile(
81
- "eor v16.16b, v16.16b, v16.16b \n"
82
- "eor v18.16b, v18.16b, v18.16b \n"
83
- "eor v17.16b, v17.16b, v17.16b \n"
84
- "eor v19.16b, v19.16b, v19.16b \n"
85
-
86
- "1: \n"
87
- "ld1 {v0.16b}, [%0], #16 \n"
88
- "ld1 {v1.16b}, [%1], #16 \n"
89
- "subs %w2, %w2, #16 \n"
90
- "usubl v2.8h, v0.8b, v1.8b \n"
91
- "usubl2 v3.8h, v0.16b, v1.16b \n"
92
- "smlal v16.4s, v2.4h, v2.4h \n"
93
- "smlal v17.4s, v3.4h, v3.4h \n"
94
- "smlal2 v18.4s, v2.8h, v2.8h \n"
95
- "smlal2 v19.4s, v3.8h, v3.8h \n"
96
- "b.gt 1b \n"
97
-
98
- "add v16.4s, v16.4s, v17.4s \n"
99
- "add v18.4s, v18.4s, v19.4s \n"
100
- "add v19.4s, v16.4s, v18.4s \n"
101
- "addv s0, v19.4s \n"
102
- "fmov %w3, s0 \n"
103
- : "+r"(src_a), "+r"(src_b), "+r"(count), "=r"(sse)
104
- :
105
- : "cc", "v0", "v1", "v2", "v3", "v16", "v17", "v18", "v19");
106
- return sse;
107
- }
108
- #elif !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) && defined(_MSC_VER)
109
- #define HAS_SUMSQUAREERROR_SSE2
110
- __declspec(naked) static uint32_t SumSquareError_SSE2(const uint8_t* /*src_a*/,
111
- const uint8_t* /*src_b*/,
112
- int /*count*/) {
113
- __asm {
114
- mov eax, [esp + 4] // src_a
115
- mov edx, [esp + 8] // src_b
116
- mov ecx, [esp + 12] // count
117
- pxor xmm0, xmm0
118
- pxor xmm5, xmm5
119
- sub edx, eax
120
-
121
- wloop:
122
- movdqu xmm1, [eax]
123
- movdqu xmm2, [eax + edx]
124
- lea eax, [eax + 16]
125
- movdqu xmm3, xmm1
126
- psubusb xmm1, xmm2
127
- psubusb xmm2, xmm3
128
- por xmm1, xmm2
129
- movdqu xmm2, xmm1
130
- punpcklbw xmm1, xmm5
131
- punpckhbw xmm2, xmm5
132
- pmaddwd xmm1, xmm1
133
- pmaddwd xmm2, xmm2
134
- paddd xmm0, xmm1
135
- paddd xmm0, xmm2
136
- sub ecx, 16
137
- ja wloop
138
-
139
- pshufd xmm1, xmm0, 0EEh
140
- paddd xmm0, xmm1
141
- pshufd xmm1, xmm0, 01h
142
- paddd xmm0, xmm1
143
- movd eax, xmm0
144
- ret
145
- }
146
- }
147
- #elif !defined(LIBYUV_DISABLE_X86) && (defined(__x86_64__) || defined(__i386__))
148
- #define HAS_SUMSQUAREERROR_SSE2
149
- static uint32_t SumSquareError_SSE2(const uint8_t* src_a,
150
- const uint8_t* src_b,
151
- int count) {
152
- uint32_t sse;
153
- asm volatile( // NOLINT
154
- "pxor %%xmm0,%%xmm0 \n"
155
- "pxor %%xmm5,%%xmm5 \n"
156
- "sub %0,%1 \n"
157
-
158
- "1: \n"
159
- "movdqu (%0),%%xmm1 \n"
160
- "movdqu (%0,%1,1),%%xmm2 \n"
161
- "lea 0x10(%0),%0 \n"
162
- "movdqu %%xmm1,%%xmm3 \n"
163
- "psubusb %%xmm2,%%xmm1 \n"
164
- "psubusb %%xmm3,%%xmm2 \n"
165
- "por %%xmm2,%%xmm1 \n"
166
- "movdqu %%xmm1,%%xmm2 \n"
167
- "punpcklbw %%xmm5,%%xmm1 \n"
168
- "punpckhbw %%xmm5,%%xmm2 \n"
169
- "pmaddwd %%xmm1,%%xmm1 \n"
170
- "pmaddwd %%xmm2,%%xmm2 \n"
171
- "paddd %%xmm1,%%xmm0 \n"
172
- "paddd %%xmm2,%%xmm0 \n"
173
- "sub $0x10,%2 \n"
174
- "ja 1b \n"
175
-
176
- "pshufd $0xee,%%xmm0,%%xmm1 \n"
177
- "paddd %%xmm1,%%xmm0 \n"
178
- "pshufd $0x1,%%xmm0,%%xmm1 \n"
179
- "paddd %%xmm1,%%xmm0 \n"
180
- "movd %%xmm0,%3 \n"
181
-
182
- : "+r"(src_a), // %0
183
- "+r"(src_b), // %1
184
- "+r"(count), // %2
185
- "=g"(sse) // %3
186
- :
187
- : "memory", "cc"
188
- #if defined(__SSE2__)
189
- ,
190
- "xmm0", "xmm1", "xmm2", "xmm3", "xmm5"
191
- #endif
192
- ); // NOLINT
193
- return sse;
194
- }
195
- #endif // LIBYUV_DISABLE_X86 etc
196
-
197
- #if defined(HAS_SUMSQUAREERROR_SSE2)
198
- #if (defined(__pic__) || defined(__APPLE__)) && defined(__i386__)
199
- static __inline void __cpuid(int cpu_info[4], int info_type) {
200
- asm volatile( // NOLINT
201
- "mov %%ebx, %%edi \n"
202
- "cpuid \n"
203
- "xchg %%edi, %%ebx \n"
204
- : "=a"(cpu_info[0]), "=D"(cpu_info[1]), "=c"(cpu_info[2]),
205
- "=d"(cpu_info[3])
206
- : "a"(info_type));
207
- }
208
- // For gcc/clang but not clangcl.
209
- #elif !defined(_MSC_VER) && (defined(__i386__) || defined(__x86_64__))
210
- static __inline void __cpuid(int cpu_info[4], int info_type) {
211
- asm volatile( // NOLINT
212
- "cpuid \n"
213
- : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]),
214
- "=d"(cpu_info[3])
215
- : "a"(info_type));
216
- }
217
- #endif
218
-
219
- static int CpuHasSSE2() {
220
- #if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86)
221
- int cpu_info[4];
222
- __cpuid(cpu_info, 1);
223
- if (cpu_info[3] & 0x04000000) {
224
- return 1;
225
- }
226
- #endif
227
- return 0;
228
- }
229
- #endif // HAS_SUMSQUAREERROR_SSE2
230
-
231
- static uint32_t SumSquareError_C(const uint8_t* src_a,
232
- const uint8_t* src_b,
233
- int count) {
234
- uint32_t sse = 0u;
235
- for (int x = 0; x < count; ++x) {
236
- int diff = src_a[x] - src_b[x];
237
- sse += static_cast<uint32_t>(diff * diff);
238
- }
239
- return sse;
240
- }
241
-
242
- double ComputeSumSquareError(const uint8_t* src_a,
243
- const uint8_t* src_b,
244
- int count) {
245
- uint32_t (*SumSquareError)(const uint8_t* src_a, const uint8_t* src_b,
246
- int count) = SumSquareError_C;
247
- #if defined(HAS_SUMSQUAREERROR_NEON)
248
- SumSquareError = SumSquareError_NEON;
249
- #endif
250
- #if defined(HAS_SUMSQUAREERROR_SSE2)
251
- if (CpuHasSSE2()) {
252
- SumSquareError = SumSquareError_SSE2;
253
- }
254
- #endif
255
- const int kBlockSize = 1 << 15;
256
- uint64_t sse = 0;
257
- #ifdef _OPENMP
258
- #pragma omp parallel for reduction(+ : sse)
259
- #endif
260
- for (int i = 0; i < (count - (kBlockSize - 1)); i += kBlockSize) {
261
- sse += SumSquareError(src_a + i, src_b + i, kBlockSize);
262
- }
263
- src_a += count & ~(kBlockSize - 1);
264
- src_b += count & ~(kBlockSize - 1);
265
- int remainder = count & (kBlockSize - 1) & ~15;
266
- if (remainder) {
267
- sse += SumSquareError(src_a, src_b, remainder);
268
- src_a += remainder;
269
- src_b += remainder;
270
- }
271
- remainder = count & 15;
272
- if (remainder) {
273
- sse += SumSquareError_C(src_a, src_b, remainder);
274
- }
275
- return static_cast<double>(sse);
276
- }
277
- #endif
278
-
279
- // PSNR formula: psnr = 10 * log10 (Peak Signal^2 * size / sse)
280
- // Returns 128.0 (kMaxPSNR) if sse is 0 (perfect match).
281
- double ComputePSNR(double sse, double size) {
282
- const double kMINSSE = 255.0 * 255.0 * size / pow(10.0, kMaxPSNR / 10.0);
283
- if (sse <= kMINSSE) {
284
- sse = kMINSSE; // Produces max PSNR of 128
285
- }
286
- return 10.0 * log10(255.0 * 255.0 * size / sse);
287
- }
288
-
289
- #ifdef __cplusplus
290
- } // extern "C"
291
- #endif
1
+ /*
2
+ * Copyright 2013 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 "./psnr.h" // NOLINT
12
+
13
+ #ifdef _OPENMP
14
+ #include <omp.h>
15
+ #endif
16
+ #ifdef _MSC_VER
17
+ #include <intrin.h> // For __cpuid()
18
+ #endif
19
+
20
+ #ifdef __cplusplus
21
+ extern "C" {
22
+ #endif
23
+
24
+ typedef unsigned int uint32_t; // NOLINT
25
+ #ifdef _MSC_VER
26
+ typedef unsigned __int64 uint64_t;
27
+ #else // COMPILER_MSVC
28
+ #if defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__)
29
+ typedef unsigned long uint64_t; // NOLINT
30
+ #else // defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__)
31
+ typedef unsigned long long uint64_t; // NOLINT
32
+ #endif // __LP64__
33
+ #endif // _MSC_VER
34
+
35
+ // libyuv provides this function when linking library for jpeg support.
36
+ #if !defined(HAVE_JPEG)
37
+
38
+ #if !defined(LIBYUV_DISABLE_NEON) && defined(__ARM_NEON__) && \
39
+ !defined(__aarch64__)
40
+ #define HAS_SUMSQUAREERROR_NEON
41
+ static uint32_t SumSquareError_NEON(const uint8_t* src_a,
42
+ const uint8_t* src_b,
43
+ int count) {
44
+ volatile uint32_t sse;
45
+ asm volatile(
46
+ "vmov.u8 q7, #0 \n"
47
+ "vmov.u8 q9, #0 \n"
48
+ "vmov.u8 q8, #0 \n"
49
+ "vmov.u8 q10, #0 \n"
50
+
51
+ "1: \n"
52
+ "vld1.u8 {q0}, [%0]! \n"
53
+ "vld1.u8 {q1}, [%1]! \n"
54
+ "vsubl.u8 q2, d0, d2 \n"
55
+ "vsubl.u8 q3, d1, d3 \n"
56
+ "vmlal.s16 q7, d4, d4 \n"
57
+ "vmlal.s16 q8, d6, d6 \n"
58
+ "vmlal.s16 q8, d5, d5 \n"
59
+ "vmlal.s16 q10, d7, d7 \n"
60
+ "subs %2, %2, #16 \n"
61
+ "bhi 1b \n"
62
+
63
+ "vadd.u32 q7, q7, q8 \n"
64
+ "vadd.u32 q9, q9, q10 \n"
65
+ "vadd.u32 q10, q7, q9 \n"
66
+ "vpaddl.u32 q1, q10 \n"
67
+ "vadd.u64 d0, d2, d3 \n"
68
+ "vmov.32 %3, d0[0] \n"
69
+ : "+r"(src_a), "+r"(src_b), "+r"(count), "=r"(sse)
70
+ :
71
+ : "memory", "cc", "q0", "q1", "q2", "q3", "q7", "q8", "q9", "q10");
72
+ return sse;
73
+ }
74
+ #elif !defined(LIBYUV_DISABLE_NEON) && defined(__aarch64__)
75
+ #define HAS_SUMSQUAREERROR_NEON
76
+ static uint32_t SumSquareError_NEON(const uint8_t* src_a,
77
+ const uint8_t* src_b,
78
+ int count) {
79
+ volatile uint32_t sse;
80
+ asm volatile(
81
+ "eor v16.16b, v16.16b, v16.16b \n"
82
+ "eor v18.16b, v18.16b, v18.16b \n"
83
+ "eor v17.16b, v17.16b, v17.16b \n"
84
+ "eor v19.16b, v19.16b, v19.16b \n"
85
+
86
+ "1: \n"
87
+ "ld1 {v0.16b}, [%0], #16 \n"
88
+ "ld1 {v1.16b}, [%1], #16 \n"
89
+ "subs %w2, %w2, #16 \n"
90
+ "usubl v2.8h, v0.8b, v1.8b \n"
91
+ "usubl2 v3.8h, v0.16b, v1.16b \n"
92
+ "smlal v16.4s, v2.4h, v2.4h \n"
93
+ "smlal v17.4s, v3.4h, v3.4h \n"
94
+ "smlal2 v18.4s, v2.8h, v2.8h \n"
95
+ "smlal2 v19.4s, v3.8h, v3.8h \n"
96
+ "b.gt 1b \n"
97
+
98
+ "add v16.4s, v16.4s, v17.4s \n"
99
+ "add v18.4s, v18.4s, v19.4s \n"
100
+ "add v19.4s, v16.4s, v18.4s \n"
101
+ "addv s0, v19.4s \n"
102
+ "fmov %w3, s0 \n"
103
+ : "+r"(src_a), "+r"(src_b), "+r"(count), "=r"(sse)
104
+ :
105
+ : "cc", "v0", "v1", "v2", "v3", "v16", "v17", "v18", "v19");
106
+ return sse;
107
+ }
108
+ #elif !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) && defined(_MSC_VER)
109
+ #define HAS_SUMSQUAREERROR_SSE2
110
+ __declspec(naked) static uint32_t SumSquareError_SSE2(const uint8_t* /*src_a*/,
111
+ const uint8_t* /*src_b*/,
112
+ int /*count*/) {
113
+ __asm {
114
+ mov eax, [esp + 4] // src_a
115
+ mov edx, [esp + 8] // src_b
116
+ mov ecx, [esp + 12] // count
117
+ pxor xmm0, xmm0
118
+ pxor xmm5, xmm5
119
+ sub edx, eax
120
+
121
+ wloop:
122
+ movdqu xmm1, [eax]
123
+ movdqu xmm2, [eax + edx]
124
+ lea eax, [eax + 16]
125
+ movdqu xmm3, xmm1
126
+ psubusb xmm1, xmm2
127
+ psubusb xmm2, xmm3
128
+ por xmm1, xmm2
129
+ movdqu xmm2, xmm1
130
+ punpcklbw xmm1, xmm5
131
+ punpckhbw xmm2, xmm5
132
+ pmaddwd xmm1, xmm1
133
+ pmaddwd xmm2, xmm2
134
+ paddd xmm0, xmm1
135
+ paddd xmm0, xmm2
136
+ sub ecx, 16
137
+ ja wloop
138
+
139
+ pshufd xmm1, xmm0, 0EEh
140
+ paddd xmm0, xmm1
141
+ pshufd xmm1, xmm0, 01h
142
+ paddd xmm0, xmm1
143
+ movd eax, xmm0
144
+ ret
145
+ }
146
+ }
147
+ #elif !defined(LIBYUV_DISABLE_X86) && (defined(__x86_64__) || defined(__i386__))
148
+ #define HAS_SUMSQUAREERROR_SSE2
149
+ static uint32_t SumSquareError_SSE2(const uint8_t* src_a,
150
+ const uint8_t* src_b,
151
+ int count) {
152
+ uint32_t sse;
153
+ asm volatile( // NOLINT
154
+ "pxor %%xmm0,%%xmm0 \n"
155
+ "pxor %%xmm5,%%xmm5 \n"
156
+ "sub %0,%1 \n"
157
+
158
+ "1: \n"
159
+ "movdqu (%0),%%xmm1 \n"
160
+ "movdqu (%0,%1,1),%%xmm2 \n"
161
+ "lea 0x10(%0),%0 \n"
162
+ "movdqu %%xmm1,%%xmm3 \n"
163
+ "psubusb %%xmm2,%%xmm1 \n"
164
+ "psubusb %%xmm3,%%xmm2 \n"
165
+ "por %%xmm2,%%xmm1 \n"
166
+ "movdqu %%xmm1,%%xmm2 \n"
167
+ "punpcklbw %%xmm5,%%xmm1 \n"
168
+ "punpckhbw %%xmm5,%%xmm2 \n"
169
+ "pmaddwd %%xmm1,%%xmm1 \n"
170
+ "pmaddwd %%xmm2,%%xmm2 \n"
171
+ "paddd %%xmm1,%%xmm0 \n"
172
+ "paddd %%xmm2,%%xmm0 \n"
173
+ "sub $0x10,%2 \n"
174
+ "ja 1b \n"
175
+
176
+ "pshufd $0xee,%%xmm0,%%xmm1 \n"
177
+ "paddd %%xmm1,%%xmm0 \n"
178
+ "pshufd $0x1,%%xmm0,%%xmm1 \n"
179
+ "paddd %%xmm1,%%xmm0 \n"
180
+ "movd %%xmm0,%3 \n"
181
+
182
+ : "+r"(src_a), // %0
183
+ "+r"(src_b), // %1
184
+ "+r"(count), // %2
185
+ "=g"(sse) // %3
186
+ :
187
+ : "memory", "cc"
188
+ #if defined(__SSE2__)
189
+ ,
190
+ "xmm0", "xmm1", "xmm2", "xmm3", "xmm5"
191
+ #endif
192
+ ); // NOLINT
193
+ return sse;
194
+ }
195
+ #endif // LIBYUV_DISABLE_X86 etc
196
+
197
+ #if defined(HAS_SUMSQUAREERROR_SSE2)
198
+ #if (defined(__pic__) || defined(__APPLE__)) && defined(__i386__)
199
+ static __inline void __cpuid(int cpu_info[4], int info_type) {
200
+ asm volatile( // NOLINT
201
+ "mov %%ebx, %%edi \n"
202
+ "cpuid \n"
203
+ "xchg %%edi, %%ebx \n"
204
+ : "=a"(cpu_info[0]), "=D"(cpu_info[1]), "=c"(cpu_info[2]),
205
+ "=d"(cpu_info[3])
206
+ : "a"(info_type));
207
+ }
208
+ // For gcc/clang but not clangcl.
209
+ #elif !defined(_MSC_VER) && (defined(__i386__) || defined(__x86_64__))
210
+ static __inline void __cpuid(int cpu_info[4], int info_type) {
211
+ asm volatile( // NOLINT
212
+ "cpuid \n"
213
+ : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]),
214
+ "=d"(cpu_info[3])
215
+ : "a"(info_type));
216
+ }
217
+ #endif
218
+
219
+ static int CpuHasSSE2() {
220
+ #if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86)
221
+ int cpu_info[4];
222
+ __cpuid(cpu_info, 1);
223
+ if (cpu_info[3] & 0x04000000) {
224
+ return 1;
225
+ }
226
+ #endif
227
+ return 0;
228
+ }
229
+ #endif // HAS_SUMSQUAREERROR_SSE2
230
+
231
+ static uint32_t SumSquareError_C(const uint8_t* src_a,
232
+ const uint8_t* src_b,
233
+ int count) {
234
+ uint32_t sse = 0u;
235
+ for (int x = 0; x < count; ++x) {
236
+ int diff = src_a[x] - src_b[x];
237
+ sse += static_cast<uint32_t>(diff * diff);
238
+ }
239
+ return sse;
240
+ }
241
+
242
+ double ComputeSumSquareError(const uint8_t* src_a,
243
+ const uint8_t* src_b,
244
+ int count) {
245
+ uint32_t (*SumSquareError)(const uint8_t* src_a, const uint8_t* src_b,
246
+ int count) = SumSquareError_C;
247
+ #if defined(HAS_SUMSQUAREERROR_NEON)
248
+ SumSquareError = SumSquareError_NEON;
249
+ #endif
250
+ #if defined(HAS_SUMSQUAREERROR_SSE2)
251
+ if (CpuHasSSE2()) {
252
+ SumSquareError = SumSquareError_SSE2;
253
+ }
254
+ #endif
255
+ const int kBlockSize = 1 << 15;
256
+ uint64_t sse = 0;
257
+ #ifdef _OPENMP
258
+ #pragma omp parallel for reduction(+ : sse)
259
+ #endif
260
+ for (int i = 0; i < (count - (kBlockSize - 1)); i += kBlockSize) {
261
+ sse += SumSquareError(src_a + i, src_b + i, kBlockSize);
262
+ }
263
+ src_a += count & ~(kBlockSize - 1);
264
+ src_b += count & ~(kBlockSize - 1);
265
+ int remainder = count & (kBlockSize - 1) & ~15;
266
+ if (remainder) {
267
+ sse += SumSquareError(src_a, src_b, remainder);
268
+ src_a += remainder;
269
+ src_b += remainder;
270
+ }
271
+ remainder = count & 15;
272
+ if (remainder) {
273
+ sse += SumSquareError_C(src_a, src_b, remainder);
274
+ }
275
+ return static_cast<double>(sse);
276
+ }
277
+ #endif
278
+
279
+ // PSNR formula: psnr = 10 * log10 (Peak Signal^2 * size / sse)
280
+ // Returns 128.0 (kMaxPSNR) if sse is 0 (perfect match).
281
+ double ComputePSNR(double sse, double size) {
282
+ const double kMINSSE = 255.0 * 255.0 * size / pow(10.0, kMaxPSNR / 10.0);
283
+ if (sse <= kMINSSE) {
284
+ sse = kMINSSE; // Produces max PSNR of 128
285
+ }
286
+ return 10.0 * log10(255.0 * 255.0 * size / sse);
287
+ }
288
+
289
+ #ifdef __cplusplus
290
+ } // extern "C"
291
+ #endif