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,590 +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 <time.h>
13
-
14
- #include "../unit_test/unit_test.h"
15
- #include "libyuv/convert_argb.h"
16
- #include "libyuv/cpu_id.h"
17
- #include "libyuv/scale_argb.h"
18
- #include "libyuv/video_common.h"
19
-
20
- namespace libyuv {
21
-
22
- #define STRINGIZE(line) #line
23
- #define FILELINESTR(file, line) file ":" STRINGIZE(line)
24
-
25
- #if !defined(DISABLE_SLOW_TESTS) || defined(__x86_64__) || defined(__i386__)
26
- // SLOW TESTS are those that are unoptimized C code.
27
- // FULL TESTS are optimized but test many variations of the same code.
28
- #define ENABLE_FULL_TESTS
29
- #endif
30
-
31
- // Test scaling with C vs Opt and return maximum pixel difference. 0 = exact.
32
- static int ARGBTestFilter(int src_width,
33
- int src_height,
34
- int dst_width,
35
- int dst_height,
36
- FilterMode f,
37
- int benchmark_iterations,
38
- int disable_cpu_flags,
39
- int benchmark_cpu_info) {
40
- if (!SizeValid(src_width, src_height, dst_width, dst_height)) {
41
- return 0;
42
- }
43
-
44
- int i, j;
45
- const int b = 0; // 128 to test for padding/stride.
46
- int64_t src_argb_plane_size =
47
- (Abs(src_width) + b * 2) * (Abs(src_height) + b * 2) * 4LL;
48
- int src_stride_argb = (b * 2 + Abs(src_width)) * 4;
49
-
50
- align_buffer_page_end(src_argb, src_argb_plane_size);
51
- if (!src_argb) {
52
- printf("Skipped. Alloc failed " FILELINESTR(__FILE__, __LINE__) "\n");
53
- return 0;
54
- }
55
- MemRandomize(src_argb, src_argb_plane_size);
56
-
57
- int64_t dst_argb_plane_size =
58
- (dst_width + b * 2) * (dst_height + b * 2) * 4LL;
59
- int dst_stride_argb = (b * 2 + dst_width) * 4;
60
-
61
- align_buffer_page_end(dst_argb_c, dst_argb_plane_size);
62
- align_buffer_page_end(dst_argb_opt, dst_argb_plane_size);
63
- if (!dst_argb_c || !dst_argb_opt) {
64
- printf("Skipped. Alloc failed " FILELINESTR(__FILE__, __LINE__) "\n");
65
- return 0;
66
- }
67
- memset(dst_argb_c, 2, dst_argb_plane_size);
68
- memset(dst_argb_opt, 3, dst_argb_plane_size);
69
-
70
- // Warm up both versions for consistent benchmarks.
71
- MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
72
- ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb,
73
- src_width, src_height, dst_argb_c + (dst_stride_argb * b) + b * 4,
74
- dst_stride_argb, dst_width, dst_height, f);
75
- MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
76
- ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb,
77
- src_width, src_height, dst_argb_opt + (dst_stride_argb * b) + b * 4,
78
- dst_stride_argb, dst_width, dst_height, f);
79
-
80
- MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
81
- double c_time = get_time();
82
- ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb,
83
- src_width, src_height, dst_argb_c + (dst_stride_argb * b) + b * 4,
84
- dst_stride_argb, dst_width, dst_height, f);
85
-
86
- c_time = (get_time() - c_time);
87
-
88
- MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
89
- double opt_time = get_time();
90
- for (i = 0; i < benchmark_iterations; ++i) {
91
- ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb,
92
- src_width, src_height,
93
- dst_argb_opt + (dst_stride_argb * b) + b * 4, dst_stride_argb,
94
- dst_width, dst_height, f);
95
- }
96
- opt_time = (get_time() - opt_time) / benchmark_iterations;
97
-
98
- // Report performance of C vs OPT
99
- printf("filter %d - %8d us C - %8d us OPT\n", f,
100
- static_cast<int>(c_time * 1e6), static_cast<int>(opt_time * 1e6));
101
-
102
- // C version may be a little off from the optimized. Order of
103
- // operations may introduce rounding somewhere. So do a difference
104
- // of the buffers and look to see that the max difference isn't
105
- // over 2.
106
- int max_diff = 0;
107
- for (i = b; i < (dst_height + b); ++i) {
108
- for (j = b * 4; j < (dst_width + b) * 4; ++j) {
109
- int abs_diff = Abs(dst_argb_c[(i * dst_stride_argb) + j] -
110
- dst_argb_opt[(i * dst_stride_argb) + j]);
111
- if (abs_diff > max_diff) {
112
- max_diff = abs_diff;
113
- }
114
- }
115
- }
116
-
117
- free_aligned_buffer_page_end(dst_argb_c);
118
- free_aligned_buffer_page_end(dst_argb_opt);
119
- free_aligned_buffer_page_end(src_argb);
120
- return max_diff;
121
- }
122
-
123
- static const int kTileX = 64;
124
- static const int kTileY = 64;
125
-
126
- static int TileARGBScale(const uint8_t* src_argb,
127
- int src_stride_argb,
128
- int src_width,
129
- int src_height,
130
- uint8_t* dst_argb,
131
- int dst_stride_argb,
132
- int dst_width,
133
- int dst_height,
134
- FilterMode filtering) {
135
- for (int y = 0; y < dst_height; y += kTileY) {
136
- for (int x = 0; x < dst_width; x += kTileX) {
137
- int clip_width = kTileX;
138
- if (x + clip_width > dst_width) {
139
- clip_width = dst_width - x;
140
- }
141
- int clip_height = kTileY;
142
- if (y + clip_height > dst_height) {
143
- clip_height = dst_height - y;
144
- }
145
- int r = ARGBScaleClip(src_argb, src_stride_argb, src_width, src_height,
146
- dst_argb, dst_stride_argb, dst_width, dst_height, x,
147
- y, clip_width, clip_height, filtering);
148
- if (r) {
149
- return r;
150
- }
151
- }
152
- }
153
- return 0;
154
- }
155
-
156
- static int ARGBClipTestFilter(int src_width,
157
- int src_height,
158
- int dst_width,
159
- int dst_height,
160
- FilterMode f,
161
- int benchmark_iterations) {
162
- if (!SizeValid(src_width, src_height, dst_width, dst_height)) {
163
- return 0;
164
- }
165
-
166
- const int b = 128;
167
- int64_t src_argb_plane_size =
168
- (Abs(src_width) + b * 2) * (Abs(src_height) + b * 2) * 4;
169
- int src_stride_argb = (b * 2 + Abs(src_width)) * 4;
170
-
171
- align_buffer_page_end(src_argb, src_argb_plane_size);
172
- if (!src_argb) {
173
- printf("Skipped. Alloc failed " FILELINESTR(__FILE__, __LINE__) "\n");
174
- return 0;
175
- }
176
- memset(src_argb, 1, src_argb_plane_size);
177
-
178
- int64_t dst_argb_plane_size = (dst_width + b * 2) * (dst_height + b * 2) * 4;
179
- int dst_stride_argb = (b * 2 + dst_width) * 4;
180
-
181
- int i, j;
182
- for (i = b; i < (Abs(src_height) + b); ++i) {
183
- for (j = b; j < (Abs(src_width) + b) * 4; ++j) {
184
- src_argb[(i * src_stride_argb) + j] = (fastrand() & 0xff);
185
- }
186
- }
187
-
188
- align_buffer_page_end(dst_argb_c, dst_argb_plane_size);
189
- align_buffer_page_end(dst_argb_opt, dst_argb_plane_size);
190
- if (!dst_argb_c || !dst_argb_opt) {
191
- printf("Skipped. Alloc failed " FILELINESTR(__FILE__, __LINE__) "\n");
192
- return 0;
193
- }
194
- memset(dst_argb_c, 2, dst_argb_plane_size);
195
- memset(dst_argb_opt, 3, dst_argb_plane_size);
196
-
197
- // Do full image, no clipping.
198
- double c_time = get_time();
199
- ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb,
200
- src_width, src_height, dst_argb_c + (dst_stride_argb * b) + b * 4,
201
- dst_stride_argb, dst_width, dst_height, f);
202
- c_time = (get_time() - c_time);
203
-
204
- // Do tiled image, clipping scale to a tile at a time.
205
- double opt_time = get_time();
206
- for (i = 0; i < benchmark_iterations; ++i) {
207
- TileARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb,
208
- src_width, src_height,
209
- dst_argb_opt + (dst_stride_argb * b) + b * 4, dst_stride_argb,
210
- dst_width, dst_height, f);
211
- }
212
- opt_time = (get_time() - opt_time) / benchmark_iterations;
213
-
214
- // Report performance of Full vs Tiled.
215
- printf("filter %d - %8d us Full - %8d us Tiled\n", f,
216
- static_cast<int>(c_time * 1e6), static_cast<int>(opt_time * 1e6));
217
-
218
- // Compare full scaled image vs tiled image.
219
- int max_diff = 0;
220
- for (i = b; i < (dst_height + b); ++i) {
221
- for (j = b * 4; j < (dst_width + b) * 4; ++j) {
222
- int abs_diff = Abs(dst_argb_c[(i * dst_stride_argb) + j] -
223
- dst_argb_opt[(i * dst_stride_argb) + j]);
224
- if (abs_diff > max_diff) {
225
- max_diff = abs_diff;
226
- }
227
- }
228
- }
229
-
230
- free_aligned_buffer_page_end(dst_argb_c);
231
- free_aligned_buffer_page_end(dst_argb_opt);
232
- free_aligned_buffer_page_end(src_argb);
233
- return max_diff;
234
- }
235
-
236
- // The following adjustments in dimensions ensure the scale factor will be
237
- // exactly achieved.
238
- #define DX(x, nom, denom) static_cast<int>((Abs(x) / nom) * nom)
239
- #define SX(x, nom, denom) static_cast<int>((x / nom) * denom)
240
-
241
- #define TEST_FACTOR1(DISABLED_, name, filter, nom, denom, max_diff) \
242
- TEST_F(LibYUVScaleTest, ARGBScaleDownBy##name##_##filter) { \
243
- int diff = ARGBTestFilter( \
244
- SX(benchmark_width_, nom, denom), SX(benchmark_height_, nom, denom), \
245
- DX(benchmark_width_, nom, denom), DX(benchmark_height_, nom, denom), \
246
- kFilter##filter, benchmark_iterations_, disable_cpu_flags_, \
247
- benchmark_cpu_info_); \
248
- EXPECT_LE(diff, max_diff); \
249
- } \
250
- TEST_F(LibYUVScaleTest, DISABLED_##ARGBScaleDownClipBy##name##_##filter) { \
251
- int diff = ARGBClipTestFilter( \
252
- SX(benchmark_width_, nom, denom), SX(benchmark_height_, nom, denom), \
253
- DX(benchmark_width_, nom, denom), DX(benchmark_height_, nom, denom), \
254
- kFilter##filter, benchmark_iterations_); \
255
- EXPECT_LE(diff, max_diff); \
256
- }
257
-
258
- // Test a scale factor with all 4 filters. Expect unfiltered to be exact, but
259
- // filtering is different fixed point implementations for SSSE3, Neon and C.
260
- #ifndef DISABLE_SLOW_TESTS
261
- #define TEST_FACTOR(name, nom, denom) \
262
- TEST_FACTOR1(, name, None, nom, denom, 0) \
263
- TEST_FACTOR1(, name, Linear, nom, denom, 3) \
264
- TEST_FACTOR1(, name, Bilinear, nom, denom, 3) \
265
- TEST_FACTOR1(, name, Box, nom, denom, 3)
266
- #else
267
- #if defined(ENABLE_FULL_TESTS)
268
- #define TEST_FACTOR(name, nom, denom) \
269
- TEST_FACTOR1(DISABLED_, name, None, nom, denom, 0) \
270
- TEST_FACTOR1(DISABLED_, name, Linear, nom, denom, 3) \
271
- TEST_FACTOR1(DISABLED_, name, Bilinear, nom, denom, 3) \
272
- TEST_FACTOR1(DISABLED_, name, Box, nom, denom, 3)
273
- #else
274
- #define TEST_FACTOR(name, nom, denom) \
275
- TEST_FACTOR1(DISABLED_, name, Bilinear, nom, denom, 3)
276
- #endif
277
- #endif
278
-
279
- TEST_FACTOR(2, 1, 2)
280
- TEST_FACTOR(4, 1, 4)
281
- #ifndef DISABLE_SLOW_TESTS
282
- TEST_FACTOR(8, 1, 8)
283
- #endif
284
- TEST_FACTOR(3by4, 3, 4)
285
- TEST_FACTOR(3by8, 3, 8)
286
- TEST_FACTOR(3, 1, 3)
287
- #undef TEST_FACTOR1
288
- #undef TEST_FACTOR
289
- #undef SX
290
- #undef DX
291
-
292
- #define TEST_SCALETO1(DISABLED_, name, width, height, filter, max_diff) \
293
- TEST_F(LibYUVScaleTest, name##To##width##x##height##_##filter) { \
294
- int diff = ARGBTestFilter(benchmark_width_, benchmark_height_, width, \
295
- height, kFilter##filter, benchmark_iterations_, \
296
- disable_cpu_flags_, benchmark_cpu_info_); \
297
- EXPECT_LE(diff, max_diff); \
298
- } \
299
- TEST_F(LibYUVScaleTest, name##From##width##x##height##_##filter) { \
300
- int diff = ARGBTestFilter(width, height, Abs(benchmark_width_), \
301
- Abs(benchmark_height_), kFilter##filter, \
302
- benchmark_iterations_, disable_cpu_flags_, \
303
- benchmark_cpu_info_); \
304
- EXPECT_LE(diff, max_diff); \
305
- } \
306
- TEST_F(LibYUVScaleTest, \
307
- DISABLED_##name##ClipTo##width##x##height##_##filter) { \
308
- int diff = \
309
- ARGBClipTestFilter(benchmark_width_, benchmark_height_, width, height, \
310
- kFilter##filter, benchmark_iterations_); \
311
- EXPECT_LE(diff, max_diff); \
312
- } \
313
- TEST_F(LibYUVScaleTest, \
314
- DISABLED_##name##ClipFrom##width##x##height##_##filter) { \
315
- int diff = ARGBClipTestFilter(width, height, Abs(benchmark_width_), \
316
- Abs(benchmark_height_), kFilter##filter, \
317
- benchmark_iterations_); \
318
- EXPECT_LE(diff, max_diff); \
319
- }
320
-
321
- #ifndef DISABLE_SLOW_TESTS
322
- // Test scale to a specified size with all 4 filters.
323
- #define TEST_SCALETO(name, width, height) \
324
- TEST_SCALETO1(, name, width, height, None, 0) \
325
- TEST_SCALETO1(, name, width, height, Linear, 3) \
326
- TEST_SCALETO1(, name, width, height, Bilinear, 3) \
327
- TEST_SCALETO1(, name, width, height, Box, 3)
328
- #else
329
- #if defined(ENABLE_FULL_TESTS)
330
- #define TEST_SCALETO(name, width, height) \
331
- TEST_SCALETO1(DISABLED_, name, width, height, None, 0) \
332
- TEST_SCALETO1(DISABLED_, name, width, height, Linear, 3) \
333
- TEST_SCALETO1(DISABLED_, name, width, height, Bilinear, 3) \
334
- TEST_SCALETO1(DISABLED_, name, width, height, Box, 3)
335
- #else
336
- #define TEST_SCALETO(name, width, height) \
337
- TEST_SCALETO1(DISABLED_, name, width, height, Bilinear, 3)
338
- #endif
339
- #endif
340
-
341
- TEST_SCALETO(ARGBScale, 1, 1)
342
- TEST_SCALETO(ARGBScale, 569, 480)
343
- TEST_SCALETO(ARGBScale, 640, 360)
344
- #ifndef DISABLE_SLOW_TESTS
345
- TEST_SCALETO(ARGBScale, 50, 1)
346
- TEST_SCALETO(ARGBScale, 256, 144) /* 128x72 * 2 */
347
- TEST_SCALETO(ARGBScale, 320, 240)
348
- TEST_SCALETO(ARGBScale, 1280, 720)
349
- TEST_SCALETO(ARGBScale, 1920, 1080)
350
- #endif // DISABLE_SLOW_TESTS
351
- #undef TEST_SCALETO1
352
- #undef TEST_SCALETO
353
-
354
- #define TEST_SCALESWAPXY1(name, filter, max_diff) \
355
- TEST_F(LibYUVScaleTest, name##SwapXY_##filter) { \
356
- int diff = ARGBTestFilter(benchmark_width_, benchmark_height_, \
357
- benchmark_height_, benchmark_width_, \
358
- kFilter##filter, benchmark_iterations_, \
359
- disable_cpu_flags_, benchmark_cpu_info_); \
360
- EXPECT_LE(diff, max_diff); \
361
- }
362
-
363
- #if defined(ENABLE_FULL_TESTS)
364
- // Test scale with swapped width and height with all 3 filters.
365
- TEST_SCALESWAPXY1(ARGBScale, None, 0)
366
- TEST_SCALESWAPXY1(ARGBScale, Linear, 0)
367
- TEST_SCALESWAPXY1(ARGBScale, Bilinear, 0)
368
- #else
369
- TEST_SCALESWAPXY1(ARGBScale, Bilinear, 0)
370
- #endif
371
- #undef TEST_SCALESWAPXY1
372
-
373
- // Scale with YUV conversion to ARGB and clipping.
374
- // TODO(fbarchard): Add fourcc support. All 4 ARGB formats is easy to support.
375
- static int YUVToARGBScaleReference2(const uint8_t* src_y,
376
- int src_stride_y,
377
- const uint8_t* src_u,
378
- int src_stride_u,
379
- const uint8_t* src_v,
380
- int src_stride_v,
381
- uint32_t /* src_fourcc */,
382
- int src_width,
383
- int src_height,
384
- uint8_t* dst_argb,
385
- int dst_stride_argb,
386
- uint32_t /* dst_fourcc */,
387
- int dst_width,
388
- int dst_height,
389
- int clip_x,
390
- int clip_y,
391
- int clip_width,
392
- int clip_height,
393
- enum FilterMode filtering) {
394
- uint8_t* argb_buffer =
395
- static_cast<uint8_t*>(malloc(src_width * src_height * 4));
396
- int r;
397
- I420ToARGB(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v,
398
- argb_buffer, src_width * 4, src_width, src_height);
399
-
400
- r = ARGBScaleClip(argb_buffer, src_width * 4, src_width, src_height, dst_argb,
401
- dst_stride_argb, dst_width, dst_height, clip_x, clip_y,
402
- clip_width, clip_height, filtering);
403
- free(argb_buffer);
404
- return r;
405
- }
406
-
407
- static void FillRamp(uint8_t* buf,
408
- int width,
409
- int height,
410
- int v,
411
- int dx,
412
- int dy) {
413
- int rv = v;
414
- for (int y = 0; y < height; ++y) {
415
- for (int x = 0; x < width; ++x) {
416
- *buf++ = v;
417
- v += dx;
418
- if (v < 0 || v > 255) {
419
- dx = -dx;
420
- v += dx;
421
- }
422
- }
423
- v = rv + dy;
424
- if (v < 0 || v > 255) {
425
- dy = -dy;
426
- v += dy;
427
- }
428
- rv = v;
429
- }
430
- }
431
-
432
- // Test scaling with C vs Opt and return maximum pixel difference. 0 = exact.
433
- static int YUVToARGBTestFilter(int src_width,
434
- int src_height,
435
- int dst_width,
436
- int dst_height,
437
- FilterMode f,
438
- int benchmark_iterations) {
439
- int64_t src_y_plane_size = Abs(src_width) * Abs(src_height);
440
- int64_t src_uv_plane_size =
441
- ((Abs(src_width) + 1) / 2) * ((Abs(src_height) + 1) / 2);
442
- int src_stride_y = Abs(src_width);
443
- int src_stride_uv = (Abs(src_width) + 1) / 2;
444
-
445
- align_buffer_page_end(src_y, src_y_plane_size);
446
- align_buffer_page_end(src_u, src_uv_plane_size);
447
- align_buffer_page_end(src_v, src_uv_plane_size);
448
-
449
- int64_t dst_argb_plane_size = (dst_width) * (dst_height)*4LL;
450
- int dst_stride_argb = (dst_width)*4;
451
- align_buffer_page_end(dst_argb_c, dst_argb_plane_size);
452
- align_buffer_page_end(dst_argb_opt, dst_argb_plane_size);
453
- if (!dst_argb_c || !dst_argb_opt || !src_y || !src_u || !src_v) {
454
- printf("Skipped. Alloc failed " FILELINESTR(__FILE__, __LINE__) "\n");
455
- return 0;
456
- }
457
- // Fill YUV image with continuous ramp, which is less sensitive to
458
- // subsampling and filtering differences for test purposes.
459
- FillRamp(src_y, Abs(src_width), Abs(src_height), 128, 1, 1);
460
- FillRamp(src_u, (Abs(src_width) + 1) / 2, (Abs(src_height) + 1) / 2, 3, 1, 1);
461
- FillRamp(src_v, (Abs(src_width) + 1) / 2, (Abs(src_height) + 1) / 2, 4, 1, 1);
462
- memset(dst_argb_c, 2, dst_argb_plane_size);
463
- memset(dst_argb_opt, 3, dst_argb_plane_size);
464
-
465
- YUVToARGBScaleReference2(src_y, src_stride_y, src_u, src_stride_uv, src_v,
466
- src_stride_uv, libyuv::FOURCC_I420, src_width,
467
- src_height, dst_argb_c, dst_stride_argb,
468
- libyuv::FOURCC_I420, dst_width, dst_height, 0, 0,
469
- dst_width, dst_height, f);
470
-
471
- for (int i = 0; i < benchmark_iterations; ++i) {
472
- YUVToARGBScaleClip(src_y, src_stride_y, src_u, src_stride_uv, src_v,
473
- src_stride_uv, libyuv::FOURCC_I420, src_width,
474
- src_height, dst_argb_opt, dst_stride_argb,
475
- libyuv::FOURCC_I420, dst_width, dst_height, 0, 0,
476
- dst_width, dst_height, f);
477
- }
478
- int max_diff = 0;
479
- for (int i = 0; i < dst_height; ++i) {
480
- for (int j = 0; j < dst_width * 4; ++j) {
481
- int abs_diff = Abs(dst_argb_c[(i * dst_stride_argb) + j] -
482
- dst_argb_opt[(i * dst_stride_argb) + j]);
483
- if (abs_diff > max_diff) {
484
- printf("error %d at %d,%d c %d opt %d", abs_diff, j, i,
485
- dst_argb_c[(i * dst_stride_argb) + j],
486
- dst_argb_opt[(i * dst_stride_argb) + j]);
487
- EXPECT_LE(abs_diff, 40);
488
- max_diff = abs_diff;
489
- }
490
- }
491
- }
492
-
493
- free_aligned_buffer_page_end(dst_argb_c);
494
- free_aligned_buffer_page_end(dst_argb_opt);
495
- free_aligned_buffer_page_end(src_y);
496
- free_aligned_buffer_page_end(src_u);
497
- free_aligned_buffer_page_end(src_v);
498
- return max_diff;
499
- }
500
-
501
- TEST_F(LibYUVScaleTest, YUVToRGBScaleUp) {
502
- int diff =
503
- YUVToARGBTestFilter(benchmark_width_, benchmark_height_,
504
- benchmark_width_ * 3 / 2, benchmark_height_ * 3 / 2,
505
- libyuv::kFilterBilinear, benchmark_iterations_);
506
- EXPECT_LE(diff, 10);
507
- }
508
-
509
- TEST_F(LibYUVScaleTest, YUVToRGBScaleDown) {
510
- int diff = YUVToARGBTestFilter(
511
- benchmark_width_ * 3 / 2, benchmark_height_ * 3 / 2, benchmark_width_,
512
- benchmark_height_, libyuv::kFilterBilinear, benchmark_iterations_);
513
- EXPECT_LE(diff, 10);
514
- }
515
-
516
- TEST_F(LibYUVScaleTest, ARGBTest3x) {
517
- const int kSrcStride = 480 * 4;
518
- const int kDstStride = 160 * 4;
519
- const int kSize = kSrcStride * 3;
520
- align_buffer_page_end(orig_pixels, kSize);
521
- for (int i = 0; i < 480 * 3; ++i) {
522
- orig_pixels[i * 4 + 0] = i;
523
- orig_pixels[i * 4 + 1] = 255 - i;
524
- orig_pixels[i * 4 + 2] = i + 1;
525
- orig_pixels[i * 4 + 3] = i + 10;
526
- }
527
- align_buffer_page_end(dest_pixels, kDstStride);
528
-
529
- int iterations160 = (benchmark_width_ * benchmark_height_ + (160 - 1)) / 160 *
530
- benchmark_iterations_;
531
- for (int i = 0; i < iterations160; ++i) {
532
- ARGBScale(orig_pixels, kSrcStride, 480, 3, dest_pixels, kDstStride, 160, 1,
533
- kFilterBilinear);
534
- }
535
-
536
- EXPECT_EQ(225, dest_pixels[0]);
537
- EXPECT_EQ(255 - 225, dest_pixels[1]);
538
- EXPECT_EQ(226, dest_pixels[2]);
539
- EXPECT_EQ(235, dest_pixels[3]);
540
-
541
- ARGBScale(orig_pixels, kSrcStride, 480, 3, dest_pixels, kDstStride, 160, 1,
542
- kFilterNone);
543
-
544
- EXPECT_EQ(225, dest_pixels[0]);
545
- EXPECT_EQ(255 - 225, dest_pixels[1]);
546
- EXPECT_EQ(226, dest_pixels[2]);
547
- EXPECT_EQ(235, dest_pixels[3]);
548
-
549
- free_aligned_buffer_page_end(dest_pixels);
550
- free_aligned_buffer_page_end(orig_pixels);
551
- }
552
-
553
- TEST_F(LibYUVScaleTest, ARGBTest4x) {
554
- const int kSrcStride = 640 * 4;
555
- const int kDstStride = 160 * 4;
556
- const int kSize = kSrcStride * 4;
557
- align_buffer_page_end(orig_pixels, kSize);
558
- for (int i = 0; i < 640 * 4; ++i) {
559
- orig_pixels[i * 4 + 0] = i;
560
- orig_pixels[i * 4 + 1] = 255 - i;
561
- orig_pixels[i * 4 + 2] = i + 1;
562
- orig_pixels[i * 4 + 3] = i + 10;
563
- }
564
- align_buffer_page_end(dest_pixels, kDstStride);
565
-
566
- int iterations160 = (benchmark_width_ * benchmark_height_ + (160 - 1)) / 160 *
567
- benchmark_iterations_;
568
- for (int i = 0; i < iterations160; ++i) {
569
- ARGBScale(orig_pixels, kSrcStride, 640, 4, dest_pixels, kDstStride, 160, 1,
570
- kFilterBilinear);
571
- }
572
-
573
- EXPECT_NEAR(66, dest_pixels[0], 4);
574
- EXPECT_NEAR(255 - 66, dest_pixels[1], 4);
575
- EXPECT_NEAR(67, dest_pixels[2], 4);
576
- EXPECT_NEAR(76, dest_pixels[3], 4);
577
-
578
- ARGBScale(orig_pixels, kSrcStride, 640, 4, dest_pixels, kDstStride, 160, 1,
579
- kFilterNone);
580
-
581
- EXPECT_EQ(2, dest_pixels[0]);
582
- EXPECT_EQ(255 - 2, dest_pixels[1]);
583
- EXPECT_EQ(3, dest_pixels[2]);
584
- EXPECT_EQ(12, dest_pixels[3]);
585
-
586
- free_aligned_buffer_page_end(dest_pixels);
587
- free_aligned_buffer_page_end(orig_pixels);
588
- }
589
-
590
- } // namespace libyuv