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,1088 +1,1088 @@
1
- /*
2
- * Copyright 2024 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 "libyuv/row_sve.h"
12
- #include "libyuv/row.h"
13
-
14
- #ifdef __cplusplus
15
- namespace libyuv {
16
- extern "C" {
17
- #endif
18
-
19
- #if !defined(LIBYUV_DISABLE_SVE) && defined(__aarch64__)
20
-
21
- #define RGBTOARGB8_SVE_2X \
22
- /* Inputs: B: z16.h, G: z17.h, R: z18.h, A: z19.b */ \
23
- "uqshrnb z16.b, z16.h, #6 \n" /* B0 */ \
24
- "uqshrnb z17.b, z17.h, #6 \n" /* G0 */ \
25
- "uqshrnb z18.b, z18.h, #6 \n" /* R0 */ \
26
- "uqshrnt z16.b, z20.h, #6 \n" /* B1 */ \
27
- "uqshrnt z17.b, z21.h, #6 \n" /* G1 */ \
28
- "uqshrnt z18.b, z22.h, #6 \n" /* R1 */
29
-
30
- #define RGBTOARGB8_SVE_TOP_2X \
31
- /* Inputs: B: z16.h, G: z17.h, R: z18.h */ \
32
- "uqshl z16.h, p0/m, z16.h, #2 \n" /* B0 */ \
33
- "uqshl z17.h, p0/m, z17.h, #2 \n" /* G0 */ \
34
- "uqshl z18.h, p0/m, z18.h, #2 \n" /* R0 */ \
35
- "uqshl z20.h, p0/m, z20.h, #2 \n" /* B1 */ \
36
- "uqshl z21.h, p0/m, z21.h, #2 \n" /* G1 */ \
37
- "uqshl z22.h, p0/m, z22.h, #2 \n" /* R1 */
38
-
39
- void I444ToARGBRow_SVE2(const uint8_t* src_y,
40
- const uint8_t* src_u,
41
- const uint8_t* src_v,
42
- uint8_t* dst_argb,
43
- const struct YuvConstants* yuvconstants,
44
- int width) {
45
- uint64_t vl;
46
- asm volatile(
47
- "cnth %[vl] \n"
48
- "ptrue p0.b \n" //
49
- YUVTORGB_SVE_SETUP
50
- "dup z19.b, #255 \n" // Alpha
51
- "subs %w[width], %w[width], %w[vl] \n"
52
- "b.lt 2f \n"
53
-
54
- // Run bulk of computation with an all-true predicate to avoid predicate
55
- // generation overhead.
56
- "ptrue p1.h \n"
57
- "1: \n" //
58
- READYUV444_SVE I4XXTORGB_SVE RGBTOARGB8_SVE
59
- "subs %w[width], %w[width], %w[vl] \n"
60
- "st2h {z16.h, z17.h}, p1, [%[dst_argb]] \n"
61
- "add %[dst_argb], %[dst_argb], %[vl], lsl #2 \n"
62
- "b.ge 1b \n"
63
-
64
- "2: \n"
65
- "adds %w[width], %w[width], %w[vl] \n"
66
- "b.eq 99f \n"
67
-
68
- // Calculate a predicate for the final iteration to deal with the tail.
69
- "whilelt p1.h, wzr, %w[width] \n" //
70
- READYUV444_SVE I4XXTORGB_SVE RGBTOARGB8_SVE
71
- "st2h {z16.h, z17.h}, p1, [%[dst_argb]] \n"
72
-
73
- "99: \n"
74
- : [src_y] "+r"(src_y), // %[src_y]
75
- [src_u] "+r"(src_u), // %[src_u]
76
- [src_v] "+r"(src_v), // %[src_v]
77
- [dst_argb] "+r"(dst_argb), // %[dst_argb]
78
- [width] "+r"(width), // %[width]
79
- [vl] "=&r"(vl) // %[vl]
80
- : [kUVCoeff] "r"(&yuvconstants->kUVCoeff), // %[kUVCoeff]
81
- [kRGBCoeffBias] "r"(&yuvconstants->kRGBCoeffBias) // %[kRGBCoeffBias]
82
- : "cc", "memory", YUVTORGB_SVE_REGS);
83
- }
84
-
85
- void I444ToRGB24Row_SVE2(const uint8_t* src_y,
86
- const uint8_t* src_u,
87
- const uint8_t* src_v,
88
- uint8_t* dst_rgb24,
89
- const struct YuvConstants* yuvconstants,
90
- int width) {
91
- I444ToRGB24Row_SVE_SC(src_y, src_u, src_v, dst_rgb24, yuvconstants, width);
92
- }
93
-
94
- void I400ToARGBRow_SVE2(const uint8_t* src_y,
95
- uint8_t* dst_argb,
96
- const struct YuvConstants* yuvconstants,
97
- int width) {
98
- I400ToARGBRow_SVE_SC(src_y, dst_argb, yuvconstants, width);
99
- }
100
-
101
- void I422ToARGBRow_SVE2(const uint8_t* src_y,
102
- const uint8_t* src_u,
103
- const uint8_t* src_v,
104
- uint8_t* dst_argb,
105
- const struct YuvConstants* yuvconstants,
106
- int width) {
107
- I422ToARGBRow_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
108
- }
109
-
110
- void I422ToRGB24Row_SVE2(const uint8_t* src_y,
111
- const uint8_t* src_u,
112
- const uint8_t* src_v,
113
- uint8_t* dst_argb,
114
- const struct YuvConstants* yuvconstants,
115
- int width) {
116
- I422ToRGB24Row_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
117
- }
118
-
119
- void I422ToRGB565Row_SVE2(const uint8_t* src_y,
120
- const uint8_t* src_u,
121
- const uint8_t* src_v,
122
- uint8_t* dst_rgb565,
123
- const struct YuvConstants* yuvconstants,
124
- int width) {
125
- I422ToRGB565Row_SVE_SC(src_y, src_u, src_v, dst_rgb565, yuvconstants, width);
126
- }
127
-
128
- void I422ToARGB1555Row_SVE2(const uint8_t* src_y,
129
- const uint8_t* src_u,
130
- const uint8_t* src_v,
131
- uint8_t* dst_argb1555,
132
- const struct YuvConstants* yuvconstants,
133
- int width) {
134
- I422ToARGB1555Row_SVE_SC(src_y, src_u, src_v, dst_argb1555, yuvconstants,
135
- width);
136
- }
137
-
138
- void I422ToARGB4444Row_SVE2(const uint8_t* src_y,
139
- const uint8_t* src_u,
140
- const uint8_t* src_v,
141
- uint8_t* dst_argb4444,
142
- const struct YuvConstants* yuvconstants,
143
- int width) {
144
- I422ToARGB4444Row_SVE_SC(src_y, src_u, src_v, dst_argb4444, yuvconstants,
145
- width);
146
- }
147
-
148
- void I422ToRGBARow_SVE2(const uint8_t* src_y,
149
- const uint8_t* src_u,
150
- const uint8_t* src_v,
151
- uint8_t* dst_argb,
152
- const struct YuvConstants* yuvconstants,
153
- int width) {
154
- I422ToRGBARow_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
155
- }
156
-
157
- void I422ToAR30Row_SVE2(const uint8_t* src_y,
158
- const uint8_t* src_u,
159
- const uint8_t* src_v,
160
- uint8_t* dst_argb,
161
- const struct YuvConstants* yuvconstants,
162
- int width) {
163
- I422ToAR30Row_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
164
- }
165
-
166
- void I422AlphaToARGBRow_SVE2(const uint8_t* src_y,
167
- const uint8_t* src_u,
168
- const uint8_t* src_v,
169
- const uint8_t* src_a,
170
- uint8_t* dst_argb,
171
- const struct YuvConstants* yuvconstants,
172
- int width) {
173
- I422AlphaToARGBRow_SVE_SC(src_y, src_u, src_v, src_a, dst_argb, yuvconstants,
174
- width);
175
- }
176
-
177
- void I444AlphaToARGBRow_SVE2(const uint8_t* src_y,
178
- const uint8_t* src_u,
179
- const uint8_t* src_v,
180
- const uint8_t* src_a,
181
- uint8_t* dst_argb,
182
- const struct YuvConstants* yuvconstants,
183
- int width) {
184
- I444AlphaToARGBRow_SVE_SC(src_y, src_u, src_v, src_a, dst_argb, yuvconstants,
185
- width);
186
- }
187
-
188
- void NV12ToARGBRow_SVE2(const uint8_t* src_y,
189
- const uint8_t* src_uv,
190
- uint8_t* dst_argb,
191
- const struct YuvConstants* yuvconstants,
192
- int width) {
193
- NV12ToARGBRow_SVE_SC(src_y, src_uv, dst_argb, yuvconstants, width);
194
- }
195
-
196
- void NV21ToARGBRow_SVE2(const uint8_t* src_y,
197
- const uint8_t* src_vu,
198
- uint8_t* dst_argb,
199
- const struct YuvConstants* yuvconstants,
200
- int width) {
201
- NV21ToARGBRow_SVE_SC(src_y, src_vu, dst_argb, yuvconstants, width);
202
- }
203
-
204
- void NV12ToRGB24Row_SVE2(const uint8_t* src_y,
205
- const uint8_t* src_uv,
206
- uint8_t* dst_rgb24,
207
- const struct YuvConstants* yuvconstants,
208
- int width) {
209
- NV12ToRGB24Row_SVE_SC(src_y, src_uv, dst_rgb24, yuvconstants, width);
210
- }
211
-
212
- void NV21ToRGB24Row_SVE2(const uint8_t* src_y,
213
- const uint8_t* src_vu,
214
- uint8_t* dst_rgb24,
215
- const struct YuvConstants* yuvconstants,
216
- int width) {
217
- NV21ToRGB24Row_SVE_SC(src_y, src_vu, dst_rgb24, yuvconstants, width);
218
- }
219
-
220
- void ARGBToUVRow_SVE2(const uint8_t* src_argb,
221
- int src_stride_argb,
222
- uint8_t* dst_u,
223
- uint8_t* dst_v,
224
- int width) {
225
- ARGBToUVMatrixRow_SVE_SC(src_argb, src_stride_argb, dst_u, dst_v, width,
226
- kARGBToUVCoefficients);
227
- }
228
-
229
- void ARGBToUVJRow_SVE2(const uint8_t* src_argb,
230
- int src_stride_argb,
231
- uint8_t* dst_u,
232
- uint8_t* dst_v,
233
- int width) {
234
- ARGBToUVMatrixRow_SVE_SC(src_argb, src_stride_argb, dst_u, dst_v, width,
235
- kARGBToUVJCoefficients);
236
- }
237
-
238
- void ABGRToUVJRow_SVE2(const uint8_t* src_abgr,
239
- int src_stride_abgr,
240
- uint8_t* dst_uj,
241
- uint8_t* dst_vj,
242
- int width) {
243
- ARGBToUVMatrixRow_SVE_SC(src_abgr, src_stride_abgr, dst_uj, dst_vj, width,
244
- kABGRToUVJCoefficients);
245
- }
246
-
247
- void BGRAToUVRow_SVE2(const uint8_t* src_bgra,
248
- int src_stride_bgra,
249
- uint8_t* dst_u,
250
- uint8_t* dst_v,
251
- int width) {
252
- ARGBToUVMatrixRow_SVE_SC(src_bgra, src_stride_bgra, dst_u, dst_v, width,
253
- kBGRAToUVCoefficients);
254
- }
255
-
256
- void ABGRToUVRow_SVE2(const uint8_t* src_abgr,
257
- int src_stride_abgr,
258
- uint8_t* dst_u,
259
- uint8_t* dst_v,
260
- int width) {
261
- ARGBToUVMatrixRow_SVE_SC(src_abgr, src_stride_abgr, dst_u, dst_v, width,
262
- kABGRToUVCoefficients);
263
- }
264
-
265
- void RGBAToUVRow_SVE2(const uint8_t* src_rgba,
266
- int src_stride_rgba,
267
- uint8_t* dst_u,
268
- uint8_t* dst_v,
269
- int width) {
270
- ARGBToUVMatrixRow_SVE_SC(src_rgba, src_stride_rgba, dst_u, dst_v, width,
271
- kRGBAToUVCoefficients);
272
- }
273
-
274
- #define ARGBTORGB565_SVE \
275
- /* Inputs: \
276
- * z0: rrrrrxxxbbbbbxxx \
277
- * z1: xxxxxxxxggggggxx \
278
- * z3: 0000000000000011 (3, 0, 3, 0, ...) \
279
- * z4: 0000011111100000 \
280
- */ \
281
- "lsr z0.b, p0/m, z0.b, z3.b \n" \
282
- "lsl z1.h, z1.h, #3 \n" \
283
- "bsl z1.d, z1.d, z0.d, z4.d \n"
284
-
285
- void ARGBToRGB565Row_SVE2(const uint8_t* src_argb,
286
- uint8_t* dst_rgb,
287
- int width) {
288
- unsigned bsl_mask = 0x7e0;
289
- uint64_t vl;
290
- width *= 2;
291
- asm volatile(
292
- "mov z3.h, #3 \n"
293
- "dup z4.h, %w[bsl_mask] \n"
294
-
295
- "cntb %[vl] \n"
296
- "subs %w[width], %w[width], %w[vl] \n"
297
- "b.lt 2f \n"
298
-
299
- "ptrue p0.b \n"
300
- "1: \n"
301
- "ld2b {z0.b, z1.b}, p0/z, [%[src]] \n" // BR, GA
302
- "incb %[src], all, mul #2 \n"
303
- "subs %w[width], %w[width], %w[vl] \n" //
304
- ARGBTORGB565_SVE
305
- "st1b {z1.b}, p0, [%[dst]] \n"
306
- "incb %[dst] \n"
307
- "b.ge 1b \n"
308
-
309
- "2: \n"
310
- "adds %w[width], %w[width], %w[vl] \n"
311
- "b.eq 99f \n"
312
-
313
- "whilelt p0.b, wzr, %w[width] \n"
314
- "ld2b {z0.b, z1.b}, p0/z, [%[src]] \n" // BR, GA
315
- ARGBTORGB565_SVE
316
- "st1b {z1.b}, p0, [%[dst]] \n"
317
-
318
- "99: \n"
319
- : [src] "+r"(src_argb), // %[src]
320
- [dst] "+r"(dst_rgb), // %[dst]
321
- [width] "+r"(width), // %[width]
322
- [vl] "=&r"(vl) // %[vl]
323
- : [bsl_mask] "r"(bsl_mask) // %[bsl_mask]
324
- : "cc", "memory", "z0", "z1", "z3", "z4", "p0");
325
- }
326
-
327
- void ARGBToRGB565DitherRow_SVE2(const uint8_t* src_argb,
328
- uint8_t* dst_rgb,
329
- uint32_t dither4,
330
- int width) {
331
- unsigned bsl_mask = 0x7e0;
332
- uint64_t vl;
333
- width *= 2;
334
- asm volatile(
335
- "mov z3.h, #3 \n"
336
- "dup z4.h, %w[bsl_mask] \n"
337
- "dup z2.s, %w[dither4] \n"
338
- "zip1 z2.b, z2.b, z2.b \n"
339
-
340
- "cntb %[vl] \n"
341
- "subs %w[width], %w[width], %w[vl] \n"
342
- "b.lt 2f \n"
343
-
344
- "ptrue p0.b \n"
345
- "1: \n"
346
- "ld2b {z0.b, z1.b}, p0/z, [%[src]] \n" // BR, GA
347
- "incb %[src], all, mul #2 \n"
348
- "uqadd z0.b, z0.b, z2.b \n"
349
- "uqadd z1.b, z1.b, z2.b \n"
350
- "subs %w[width], %w[width], %w[vl] \n" //
351
- ARGBTORGB565_SVE
352
- "st1b {z1.b}, p0, [%[dst]] \n"
353
- "incb %[dst] \n"
354
- "b.ge 1b \n"
355
-
356
- "2: \n"
357
- "adds %w[width], %w[width], %w[vl] \n"
358
- "b.eq 99f \n"
359
-
360
- "whilelt p0.b, wzr, %w[width] \n"
361
- "ld2b {z0.b, z1.b}, p0/z, [%[src]] \n" // BR, GA
362
- "uqadd z0.b, z0.b, z2.b \n"
363
- "uqadd z1.b, z1.b, z2.b \n" //
364
- ARGBTORGB565_SVE
365
- "st1b {z1.b}, p0, [%[dst]] \n"
366
-
367
- "99: \n"
368
- : [src] "+r"(src_argb), // %[src]
369
- [dst] "+r"(dst_rgb), // %[dst]
370
- [width] "+r"(width), // %[width]
371
- [vl] "=&r"(vl) // %[vl]
372
- : [bsl_mask] "r"(bsl_mask), // %[bsl_mask]
373
- [dither4] "r"(dither4) // %[dither4]
374
- : "cc", "memory", "z0", "z1", "z3", "z4", "p0");
375
- }
376
-
377
- #define ARGB1555TOARGB \
378
- /* Input: z1/z3.h = arrrrrgggggbbbbb */ \
379
- "lsl z0.h, z1.h, #3 \n" /* rrrgggggbbbbb000 */ \
380
- "lsl z2.h, z3.h, #3 \n" /* rrrgggggbbbbb000 */ \
381
- "asr z1.h, z1.h, #7 \n" /* aaaaaaaarrrrrggg */ \
382
- "asr z3.h, z3.h, #7 \n" /* aaaaaaaarrrrrggg */ \
383
- "lsl z0.b, p0/m, z0.b, z4.b \n" /* ggggg000bbbbb000 */ \
384
- "lsl z2.b, p0/m, z2.b, z4.b \n" /* ggggg000bbbbb000 */ \
385
- "sri z1.b, z1.b, #5 \n" /* aaaaaaaarrrrrrrr */ \
386
- "sri z3.b, z3.b, #5 \n" /* aaaaaaaarrrrrrrr */ \
387
- "sri z0.b, z0.b, #5 \n" /* ggggggggbbbbbbbb */ \
388
- "sri z2.b, z2.b, #5 \n" /* ggggggggbbbbbbbb */
389
-
390
- void ARGB1555ToARGBRow_SVE2(const uint8_t* src_argb1555,
391
- uint8_t* dst_argb,
392
- int width) {
393
- uint64_t vl;
394
- asm volatile(
395
- "mov z4.h, #0x0300 \n"
396
- "ptrue p0.b \n"
397
-
398
- "cnth %x[vl] \n"
399
- "subs %w[width], %w[width], %w[vl], lsl #1 \n"
400
- "b.lt 2f \n"
401
-
402
- "1: \n"
403
- "ld1h {z1.h}, p0/z, [%[src]] \n"
404
- "ld1h {z3.h}, p0/z, [%[src], #1, mul vl] \n"
405
- "incb %[src], all, mul #2 \n" //
406
- ARGB1555TOARGB
407
- "subs %w[width], %w[width], %w[vl], lsl #1 \n"
408
- "st2h {z0.h, z1.h}, p0, [%[dst]] \n"
409
- "st2h {z2.h, z3.h}, p0, [%[dst], #2, mul vl] \n"
410
- "incb %[dst], all, mul #4 \n"
411
- "b.ge 1b \n"
412
-
413
- "2: \n"
414
- "adds %w[width], %w[width], %w[vl], lsl #1 \n"
415
- "b.eq 99f \n"
416
-
417
- "whilelt p1.h, wzr, %w[width] \n"
418
- "whilelt p2.h, %w[vl], %w[width] \n"
419
- "ld1h {z1.h}, p1/z, [%[src]] \n"
420
- "ld1h {z3.h}, p2/z, [%[src], #1, mul vl] \n" //
421
- ARGB1555TOARGB
422
- "st2h {z0.h, z1.h}, p1, [%[dst]] \n"
423
- "st2h {z2.h, z3.h}, p2, [%[dst], #2, mul vl] \n"
424
-
425
- "99: \n"
426
- : [src] "+r"(src_argb1555), // %[src]
427
- [dst] "+r"(dst_argb), // %[dst]
428
- [width] "+r"(width), // %[width]
429
- [vl] "=&r"(vl) // %[vl]
430
- :
431
- : "cc", "memory", "z0", "z1", "z2", "z3", "z4", "p0", "p1", "p2");
432
- }
433
-
434
- // clang-format off
435
- #define AYUVTOUV_SVE(zU0, zV0, zU1, zV1) /* e.g. */ \
436
- "ld2h {z0.h, z1.h}, p0/z, [%[src0]] \n" /* VUVU.. YAYA.. */ \
437
- "ld2h {z1.h, z2.h}, p1/z, [%[src0], #2, mul vl] \n" /* VUVU.. YAYA.. */ \
438
- "ld2h {z2.h, z3.h}, p0/z, [%[src1]] \n" /* VUVU.. YAYA.. */ \
439
- "ld2h {z3.h, z4.h}, p1/z, [%[src1], #2, mul vl] \n" /* VUVU.. YAYA.. */ \
440
- "incb %[src0], all, mul #4 \n" \
441
- "incb %[src1], all, mul #4 \n" \
442
- "uaddlb z4.h, z0.b, z2.b \n" /* V */ \
443
- "uaddlt z5.h, z0.b, z2.b \n" /* U */ \
444
- "uaddlb z6.h, z1.b, z3.b \n" /* V */ \
445
- "uaddlt z7.h, z1.b, z3.b \n" /* U */ \
446
- "addp " #zU0 ".h, p0/m, " #zU0 ".h, " #zV0 ".h \n" /* UV */ \
447
- "addp " #zU1 ".h, p1/m, " #zU1 ".h, " #zV1 ".h \n" /* UV */ \
448
- "subs %w[width], %w[width], %w[vl] \n" \
449
- "urshr " #zU0 ".h, p0/m, " #zU0 ".h, #2 \n" /* U0V0 */ \
450
- "urshr " #zU1 ".h, p1/m, " #zU1 ".h, #2 \n" /* U0V0 */ \
451
- "st1b {" #zU0 ".h}, p0, [%[dst]] \n" \
452
- "st1b {" #zU1 ".h}, p1, [%[dst], #1, mul vl] \n" \
453
- "incb %[dst] \n"
454
- // clang-format on
455
-
456
- // Filter 2 rows of AYUV UV's (444) into UV (420).
457
- // AYUV is VUYA in memory. UV for NV12 is UV order in memory.
458
- void AYUVToUVRow_SVE2(const uint8_t* src_ayuv,
459
- int src_stride_ayuv,
460
- uint8_t* dst_uv,
461
- int width) {
462
- // Output a row of UV values, filtering 2x2 rows of AYUV.
463
- const uint8_t* src_ayuv1 = src_ayuv + src_stride_ayuv;
464
- int vl;
465
- asm volatile (
466
- "cntb %x[vl] \n"
467
- "subs %w[width], %w[width], %w[vl] \n"
468
- "b.lt 2f \n"
469
-
470
- "ptrue p0.h \n"
471
- "ptrue p1.h \n"
472
- "1: \n"
473
- AYUVTOUV_SVE(z5, z4, z7, z6)
474
- "b.ge 1b \n"
475
-
476
- "2: \n"
477
- "adds %w[width], %w[width], %w[vl] \n"
478
- "b.eq 99f \n"
479
-
480
- "cnth %x[vl] \n"
481
- "whilelt p0.h, wzr, %w[width] \n" // first row
482
- "whilelt p1.h, %w[vl], %w[width] \n" // second row
483
- AYUVTOUV_SVE(z5, z4, z7, z6)
484
-
485
- "99: \n"
486
- : [src0]"+r"(src_ayuv), // %[src0]
487
- [src1]"+r"(src_ayuv1), // %[src1]
488
- [dst]"+r"(dst_uv), // %[dst]
489
- [width]"+r"(width), // %[width]
490
- [vl]"=&r"(vl) // %[vl]
491
- :
492
- : "cc", "memory", "z0", "z1", "z2", "z3", "z4", "z5", "z6", "z7", "p0",
493
- "p1");
494
- }
495
-
496
- // Filter 2 rows of AYUV UV's (444) into VU (420).
497
- void AYUVToVURow_SVE2(const uint8_t* src_ayuv,
498
- int src_stride_ayuv,
499
- uint8_t* dst_vu,
500
- int width) {
501
- // Output a row of VU values, filtering 2x2 rows of AYUV.
502
- const uint8_t* src_ayuv1 = src_ayuv + src_stride_ayuv;
503
- int vl;
504
- asm volatile (
505
- "cntb %x[vl] \n"
506
- "cmp %w[width], %w[vl] \n"
507
- "subs %w[width], %w[width], %w[vl] \n"
508
- "b.lt 2f \n"
509
-
510
- "ptrue p0.h \n"
511
- "ptrue p1.h \n"
512
- "1: \n"
513
- AYUVTOUV_SVE(z4, z5, z6, z7)
514
- "b.ge 1b \n"
515
-
516
- "2: \n"
517
- "adds %w[width], %w[width], %w[vl] \n"
518
- "b.eq 99f \n"
519
-
520
- "cnth %x[vl] \n"
521
- "whilelt p0.h, wzr, %w[width] \n" // first row
522
- "whilelt p1.h, %w[vl], %w[width] \n" // second row
523
- AYUVTOUV_SVE(z4, z5, z6, z7)
524
-
525
- "99: \n"
526
- : [src0]"+r"(src_ayuv), // %[src0]
527
- [src1]"+r"(src_ayuv1), // %[src1]
528
- [dst]"+r"(dst_vu), // %[dst]
529
- [width]"+r"(width), // %[width]
530
- [vl]"=&r"(vl) // %[vl]
531
- :
532
- : "cc", "memory", "z0", "z1", "z2", "z3", "z4", "z5", "z6", "z7", "p0",
533
- "p1");
534
- }
535
-
536
- void YUY2ToARGBRow_SVE2(const uint8_t* src_yuy2,
537
- uint8_t* dst_argb,
538
- const struct YuvConstants* yuvconstants,
539
- int width) {
540
- YUY2ToARGBRow_SVE_SC(src_yuy2, dst_argb, yuvconstants, width);
541
- }
542
-
543
- void UYVYToARGBRow_SVE2(const uint8_t* src_uyvy,
544
- uint8_t* dst_argb,
545
- const struct YuvConstants* yuvconstants,
546
- int width) {
547
- UYVYToARGBRow_SVE_SC(src_uyvy, dst_argb, yuvconstants, width);
548
- }
549
-
550
- static inline void RAWToWXYZRow_SVE2(const uint8_t* src_raw,
551
- uint8_t* dst_wxyz,
552
- int width,
553
- uint32_t idx_start,
554
- uint32_t idx_step,
555
- uint32_t alpha) {
556
- uint32_t vl;
557
- asm("cntw %x0" : "=r"(vl));
558
- uint32_t vl_mul3 = vl * 3;
559
- uint32_t rem_mul3;
560
- asm volatile(
561
- "index z31.s, %w[idx_start], %w[idx_step] \n"
562
- "dup z30.s, %w[alpha] \n"
563
- "subs %w[width], %w[width], %w[vl], lsl #1 \n"
564
- "b.lt 2f \n"
565
-
566
- // Run bulk of computation with the same predicates to avoid predicate
567
- // generation overhead. We set up p1 to only load 3/4 of a vector.
568
- "ptrue p0.s \n"
569
- "whilelt p1.b, wzr, %w[vl_mul3] \n"
570
- "1: \n"
571
- "ld1b {z0.b}, p1/z, [%[src]] \n"
572
- "add %[src], %[src], %x[vl_mul3] \n"
573
- "ld1b {z1.b}, p1/z, [%[src]] \n"
574
- "add %[src], %[src], %x[vl_mul3] \n"
575
- "tbl z0.b, {z0.b}, z31.b \n"
576
- "tbl z1.b, {z1.b}, z31.b \n"
577
- "subs %w[width], %w[width], %w[vl], lsl #1 \n"
578
- "orr z0.d, z0.d, z30.d \n"
579
- "orr z1.d, z1.d, z30.d \n"
580
- "st1w {z0.s}, p0, [%[dst]] \n"
581
- "st1w {z1.s}, p0, [%[dst], #1, mul vl] \n"
582
- "incb %[dst], all, mul #2 \n"
583
- "b.ge 1b \n"
584
-
585
- "2: \n"
586
- "adds %w[width], %w[width], %w[vl], lsl #1 \n"
587
- "b.eq 99f \n"
588
-
589
- // Calculate a pair of predicates for the final iteration to deal with
590
- // the tail.
591
- "3: \n"
592
- "add %w[rem_mul3], %w[width], %w[width], lsl #1 \n"
593
- "whilelt p0.s, wzr, %w[width] \n"
594
- "whilelt p1.b, wzr, %w[rem_mul3] \n"
595
- "ld1b {z0.b}, p1/z, [%[src]] \n"
596
- "add %[src], %[src], %x[vl_mul3] \n"
597
- "tbl z0.b, {z0.b}, z31.b \n"
598
- "subs %w[width], %w[width], %w[vl] \n"
599
- "orr z0.d, z0.d, z30.d \n"
600
- "st1w {z0.s}, p0, [%[dst]] \n"
601
- "incb %[dst] \n"
602
- "b.gt 3b \n"
603
-
604
- "99: \n"
605
- : [src] "+r"(src_raw), // %[src]
606
- [dst] "+r"(dst_wxyz), // %[dst]
607
- [width] "+r"(width), // %[width]
608
- [vl_mul3] "+r"(vl_mul3), // %[vl_mul3]
609
- [rem_mul3] "=&r"(rem_mul3) // %[rem_mul3]
610
- : [idx_start] "r"(idx_start), // %[idx_start]
611
- [idx_step] "r"(idx_step), // %[idx_step]
612
- [alpha] "r"(alpha), // %[alpha]
613
- [vl] "r"(vl) // %[vl]
614
- : "cc", "memory", "z0", "z1", "z30", "z31", "p0", "p1");
615
- }
616
-
617
- void RAWToARGBRow_SVE2(const uint8_t* src_raw, uint8_t* dst_argb, int width) {
618
- RAWToWXYZRow_SVE2(src_raw, dst_argb, width, 0xff000102U, 0x00030303U,
619
- 0xff000000U);
620
- }
621
-
622
- void RAWToRGBARow_SVE2(const uint8_t* src_raw, uint8_t* dst_rgba, int width) {
623
- RAWToWXYZRow_SVE2(src_raw, dst_rgba, width, 0x000102ffU, 0x03030300U,
624
- 0x000000ffU);
625
- }
626
-
627
- void RGB24ToARGBRow_SVE2(const uint8_t* src_rgb24,
628
- uint8_t* dst_argb,
629
- int width) {
630
- RAWToWXYZRow_SVE2(src_rgb24, dst_argb, width, 0xff020100U, 0x00030303U,
631
- 0xff000000U);
632
- }
633
-
634
- static const uint8_t kRAWToRGB24Indices[] = {
635
- 2, 1, 0, 5, 4, 3, 8, 7, 6, 11, 10, 9, 14, 13, 12,
636
- 17, 16, 15, 20, 19, 18, 23, 22, 21, 26, 25, 24, 29, 28, 27,
637
- 32, 31, 30, 35, 34, 33, 38, 37, 36, 41, 40, 39, 44, 43, 42,
638
- 47, 46, 45, 50, 49, 48, 53, 52, 51, 56, 55, 54, 59, 58, 57,
639
- 62, 61, 60, 65, 64, 63, 68, 67, 66, 71, 70, 69, 74, 73, 72,
640
- 77, 76, 75, 80, 79, 78, 83, 82, 81, 86, 85, 84, 89, 88, 87,
641
- 92, 91, 90, 95, 94, 93, 98, 97, 96, 101, 100, 99, 104, 103, 102,
642
- 107, 106, 105, 110, 109, 108, 113, 112, 111, 116, 115, 114, 119, 118, 117,
643
- 122, 121, 120, 125, 124, 123, 128, 127, 126, 131, 130, 129, 134, 133, 132,
644
- 137, 136, 135, 140, 139, 138, 143, 142, 141, 146, 145, 144, 149, 148, 147,
645
- 152, 151, 150, 155, 154, 153, 158, 157, 156, 161, 160, 159, 164, 163, 162,
646
- 167, 166, 165, 170, 169, 168, 173, 172, 171, 176, 175, 174, 179, 178, 177,
647
- 182, 181, 180, 185, 184, 183, 188, 187, 186, 191, 190, 189, 194, 193, 192,
648
- 197, 196, 195, 200, 199, 198, 203, 202, 201, 206, 205, 204, 209, 208, 207,
649
- 212, 211, 210, 215, 214, 213, 218, 217, 216, 221, 220, 219, 224, 223, 222,
650
- 227, 226, 225, 230, 229, 228, 233, 232, 231, 236, 235, 234, 239, 238, 237,
651
- 242, 241, 240, 245, 244, 243, 248, 247, 246, 251, 250, 249, 254, 253, 252};
652
-
653
- void RAWToRGB24Row_SVE2(const uint8_t* src_raw, uint8_t* dst_rgb24, int width) {
654
- // width is in elements, convert to bytes.
655
- width *= 3;
656
- // we use the mul3 predicate pattern throughout to use the largest multiple
657
- // of three number of lanes, for instance with a vector length of 16 bytes
658
- // only the first 15 bytes will be used for load/store instructions.
659
- uint32_t vl;
660
- asm volatile(
661
- "cntb %x[vl], mul3 \n"
662
- "ptrue p0.b, mul3 \n"
663
- "ld1b {z31.b}, p0/z, [%[kIndices]] \n"
664
- "subs %w[width], %w[width], %w[vl] \n"
665
- "b.lt 2f \n"
666
-
667
- // Run bulk of computation with the same predicate to avoid predicate
668
- // generation overhead.
669
- "1: \n"
670
- "ld1b {z0.b}, p0/z, [%[src]] \n"
671
- "add %[src], %[src], %x[vl] \n"
672
- "tbl z0.b, {z0.b}, z31.b \n"
673
- "subs %w[width], %w[width], %w[vl] \n"
674
- "st1b {z0.b}, p0, [%[dst]] \n"
675
- "add %[dst], %[dst], %x[vl] \n"
676
- "b.ge 1b \n"
677
-
678
- "2: \n"
679
- "adds %w[width], %w[width], %w[vl] \n"
680
- "b.eq 99f \n"
681
-
682
- // Calculate a predicate for the final iteration to deal with the tail.
683
- "whilelt p0.b, wzr, %w[width] \n"
684
- "ld1b {z0.b}, p0/z, [%[src]] \n"
685
- "tbl z0.b, {z0.b}, z31.b \n"
686
- "st1b {z0.b}, p0, [%[dst]] \n"
687
-
688
- "99: \n"
689
- : [src] "+r"(src_raw), // %[src]
690
- [dst] "+r"(dst_rgb24), // %[dst]
691
- [width] "+r"(width), // %[width]
692
- [vl] "=&r"(vl) // %[vl]
693
- : [kIndices] "r"(kRAWToRGB24Indices) // %[kIndices]
694
- : "cc", "memory", "z0", "z31", "p0");
695
- }
696
-
697
- static inline void ARGBToXYZRow_SVE2(const uint8_t* src_argb,
698
- uint8_t* dst_xyz,
699
- int width,
700
- const uint8_t* indices) {
701
- uint32_t vl;
702
- asm("cntw %x0" : "=r"(vl));
703
- uint32_t vl_mul3 = vl * 3;
704
- uint32_t rem_mul3;
705
- asm volatile(
706
- "whilelt p1.b, wzr, %w[vl_mul3] \n"
707
- "ld1b {z31.b}, p1/z, [%[indices]] \n"
708
- "subs %w[width], %w[width], %w[vl], lsl #1 \n"
709
- "b.lt 2f \n"
710
-
711
- // Run bulk of computation with the same predicates to avoid predicate
712
- // generation overhead. We set up p1 to only store 3/4 of a vector.
713
- "ptrue p0.s \n"
714
- "1: \n"
715
- "ld1w {z0.s}, p0/z, [%[src]] \n"
716
- "ld1w {z1.s}, p0/z, [%[src], #1, mul vl] \n"
717
- "incb %[src], all, mul #2 \n"
718
- "tbl z0.b, {z0.b}, z31.b \n"
719
- "tbl z1.b, {z1.b}, z31.b \n"
720
- "subs %w[width], %w[width], %w[vl], lsl #1 \n"
721
- "st1b {z0.b}, p1, [%[dst]] \n"
722
- "add %[dst], %[dst], %x[vl_mul3] \n"
723
- "st1b {z1.b}, p1, [%[dst]] \n"
724
- "add %[dst], %[dst], %x[vl_mul3] \n"
725
- "b.ge 1b \n"
726
-
727
- "2: \n"
728
- "adds %w[width], %w[width], %w[vl], lsl #1 \n"
729
- "b.eq 99f \n"
730
-
731
- // Calculate predicates for the final iteration to deal with the tail.
732
- "add %w[rem_mul3], %w[width], %w[width], lsl #1 \n"
733
- "whilelt p0.s, wzr, %w[width] \n"
734
- "whilelt p1.b, wzr, %w[rem_mul3] \n"
735
- "whilelt p2.s, %w[vl], %w[width] \n"
736
- "whilelt p3.b, %w[vl_mul3], %w[rem_mul3] \n"
737
- "ld1w {z0.s}, p0/z, [%[src]] \n"
738
- "ld1w {z1.s}, p2/z, [%[src], #1, mul vl] \n"
739
- "tbl z0.b, {z0.b}, z31.b \n"
740
- "tbl z1.b, {z1.b}, z31.b \n"
741
- "st1b {z0.b}, p1, [%[dst]] \n"
742
- "add %[dst], %[dst], %x[vl_mul3] \n"
743
- "st1b {z1.b}, p3, [%[dst]] \n"
744
-
745
- "99: \n"
746
- : [src] "+r"(src_argb), // %[src]
747
- [dst] "+r"(dst_xyz), // %[dst]
748
- [width] "+r"(width), // %[width]
749
- [rem_mul3] "=&r"(rem_mul3) // %[rem_mul3]
750
- : [indices] "r"(indices), // %[indices]
751
- [vl_mul3] "r"(vl_mul3), // %[vl_mul3]
752
- [vl] "r"(vl) // %[vl]
753
- : "cc", "memory", "z0", "z1", "z31", "p0", "p1", "p2", "p3");
754
- }
755
-
756
- static const uint8_t kARGBToRGB24RowIndices[] = {
757
- 0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18,
758
- 20, 21, 22, 24, 25, 26, 28, 29, 30, 32, 33, 34, 36, 37, 38,
759
- 40, 41, 42, 44, 45, 46, 48, 49, 50, 52, 53, 54, 56, 57, 58,
760
- 60, 61, 62, 64, 65, 66, 68, 69, 70, 72, 73, 74, 76, 77, 78,
761
- 80, 81, 82, 84, 85, 86, 88, 89, 90, 92, 93, 94, 96, 97, 98,
762
- 100, 101, 102, 104, 105, 106, 108, 109, 110, 112, 113, 114, 116, 117, 118,
763
- 120, 121, 122, 124, 125, 126, 128, 129, 130, 132, 133, 134, 136, 137, 138,
764
- 140, 141, 142, 144, 145, 146, 148, 149, 150, 152, 153, 154, 156, 157, 158,
765
- 160, 161, 162, 164, 165, 166, 168, 169, 170, 172, 173, 174, 176, 177, 178,
766
- 180, 181, 182, 184, 185, 186, 188, 189, 190, 192, 193, 194, 196, 197, 198,
767
- 200, 201, 202, 204, 205, 206, 208, 209, 210, 212, 213, 214, 216, 217, 218,
768
- 220, 221, 222, 224, 225, 226, 228, 229, 230, 232, 233, 234, 236, 237, 238,
769
- 240, 241, 242, 244, 245, 246, 248, 249, 250, 252, 253, 254,
770
- };
771
-
772
- static const uint8_t kARGBToRAWRowIndices[] = {
773
- 2, 1, 0, 6, 5, 4, 10, 9, 8, 14, 13, 12, 18, 17, 16,
774
- 22, 21, 20, 26, 25, 24, 30, 29, 28, 34, 33, 32, 38, 37, 36,
775
- 42, 41, 40, 46, 45, 44, 50, 49, 48, 54, 53, 52, 58, 57, 56,
776
- 62, 61, 60, 66, 65, 64, 70, 69, 68, 74, 73, 72, 78, 77, 76,
777
- 82, 81, 80, 86, 85, 84, 90, 89, 88, 94, 93, 92, 98, 97, 96,
778
- 102, 101, 100, 106, 105, 104, 110, 109, 108, 114, 113, 112, 118, 117, 116,
779
- 122, 121, 120, 126, 125, 124, 130, 129, 128, 134, 133, 132, 138, 137, 136,
780
- 142, 141, 140, 146, 145, 144, 150, 149, 148, 154, 153, 152, 158, 157, 156,
781
- 162, 161, 160, 166, 165, 164, 170, 169, 168, 174, 173, 172, 178, 177, 176,
782
- 182, 181, 180, 186, 185, 184, 190, 189, 188, 194, 193, 192, 198, 197, 196,
783
- 202, 201, 200, 206, 205, 204, 210, 209, 208, 214, 213, 212, 218, 217, 216,
784
- 222, 221, 220, 226, 225, 224, 230, 229, 228, 234, 233, 232, 238, 237, 236,
785
- 242, 241, 240, 246, 245, 244, 250, 249, 248, 254, 253, 252,
786
- };
787
-
788
- void ARGBToRGB24Row_SVE2(const uint8_t* src_argb, uint8_t* dst_rgb, int width) {
789
- ARGBToXYZRow_SVE2(src_argb, dst_rgb, width, kARGBToRGB24RowIndices);
790
- }
791
-
792
- void ARGBToRAWRow_SVE2(const uint8_t* src_argb, uint8_t* dst_rgb, int width) {
793
- ARGBToXYZRow_SVE2(src_argb, dst_rgb, width, kARGBToRAWRowIndices);
794
- }
795
-
796
- void DivideRow_16_SVE2(const uint16_t* src_y,
797
- uint16_t* dst_y,
798
- int scale,
799
- int width) {
800
- uint64_t vl;
801
- asm volatile(
802
- "cnth %x[vl] \n"
803
- "dup z0.h, %w[scale] \n"
804
- "subs %w[width], %w[width], %w[vl], lsl #1 \n"
805
- "b.le 2f \n"
806
-
807
- // Run bulk of computation with the same predicates to avoid predicate
808
- // generation overhead.
809
- "ptrue p0.h \n"
810
- "1: \n"
811
- "ld1h {z1.h}, p0/z, [%[src]] \n"
812
- "ld1h {z2.h}, p0/z, [%[src], #1, mul vl] \n"
813
- "incb %[src], all, mul #2 \n"
814
- "umulh z1.h, z1.h, z0.h \n"
815
- "umulh z2.h, z2.h, z0.h \n"
816
- "subs %w[width], %w[width], %w[vl], lsl #1 \n"
817
- "st1h {z1.h}, p0, [%[dst]] \n"
818
- "st1h {z2.h}, p0, [%[dst], #1, mul vl] \n"
819
- "incb %[dst], all, mul #2 \n"
820
- "b.gt 1b \n"
821
-
822
- "2: \n"
823
- "adds %w[width], %w[width], %w[vl], lsl #1 \n"
824
- "b.eq 99f \n"
825
-
826
- // Calculate a pair of predicates for the final iteration to deal with
827
- // the tail.
828
- "whilelt p0.h, wzr, %w[width] \n"
829
- "whilelt p1.h, %w[vl], %w[width] \n"
830
- "ld1h {z1.h}, p0/z, [%[src]] \n"
831
- "ld1h {z2.h}, p1/z, [%[src], #1, mul vl] \n"
832
- "umulh z1.h, z1.h, z0.h \n"
833
- "umulh z2.h, z2.h, z0.h \n"
834
- "st1h {z1.h}, p0, [%[dst]] \n"
835
- "st1h {z2.h}, p1, [%[dst], #1, mul vl] \n"
836
-
837
- "99: \n"
838
- : [src] "+r"(src_y), // %[src]
839
- [dst] "+r"(dst_y), // %[dst]
840
- [width] "+r"(width), // %[width]
841
- [vl] "=&r"(vl) // %[vl]
842
- : [scale] "r"(scale) // %[scale]
843
- : "cc", "memory", "z0", "z1", "z2", "p0", "p1");
844
- }
845
-
846
- #define HALFFLOAT_SVE \
847
- "scvtf z0.s, p0/m, z0.s \n" \
848
- "scvtf z1.s, p0/m, z1.s \n" \
849
- "scvtf z2.s, p0/m, z2.s \n" \
850
- "scvtf z3.s, p0/m, z3.s \n" \
851
- "fmul z0.s, z0.s, z4.s \n" \
852
- "fmul z1.s, z1.s, z4.s \n" \
853
- "fmul z2.s, z2.s, z4.s \n" \
854
- "fmul z3.s, z3.s, z4.s \n" \
855
- "uqshrnb z0.h, z0.s, #13 \n" \
856
- "uqshrnb z1.h, z1.s, #13 \n" \
857
- "uqshrnb z2.h, z2.s, #13 \n" \
858
- "uqshrnb z3.h, z3.s, #13 \n"
859
-
860
- void HalfFloatRow_SVE2(const uint16_t* src,
861
- uint16_t* dst,
862
- float scale,
863
- int width) {
864
- uint64_t vl;
865
- asm("cntw %x0" : "=r"(vl));
866
- asm volatile(
867
- "mov z4.s, %s[scale] \n"
868
- "subs %w[width], %w[width], %w[vl], lsl #2 \n"
869
- "b.lt 2f \n"
870
-
871
- // Run bulk of computation with all-true predicates to avoid predicate
872
- // generation overhead.
873
- "ptrue p0.s \n"
874
- "1: \n"
875
- "ld1h {z0.s}, p0/z, [%[src]] \n"
876
- "ld1h {z1.s}, p0/z, [%[src], #1, mul vl] \n"
877
- "ld1h {z2.s}, p0/z, [%[src], #2, mul vl] \n"
878
- "ld1h {z3.s}, p0/z, [%[src], #3, mul vl] \n"
879
- "incb %[src], all, mul #2 \n" //
880
- HALFFLOAT_SVE
881
- "subs %w[width], %w[width], %w[vl], lsl #2 \n"
882
- "st1h {z0.s}, p0, [%[dst]] \n"
883
- "st1h {z1.s}, p0, [%[dst], #1, mul vl] \n"
884
- "st1h {z2.s}, p0, [%[dst], #2, mul vl] \n"
885
- "st1h {z3.s}, p0, [%[dst], #3, mul vl] \n"
886
- "incb %[dst], all, mul #2 \n"
887
- "b.ge 1b \n"
888
-
889
- "2: \n"
890
- "adds %w[width], %w[width], %w[vl], lsl #2 \n"
891
- "b.eq 99f \n"
892
-
893
- // Calculate predicates for the final iteration to deal with the tail.
894
- "whilelt p0.s, wzr, %w[width] \n"
895
- "whilelt p1.s, %w[vl], %w[width] \n"
896
- "whilelt p2.s, %w[vl2], %w[width] \n"
897
- "whilelt p3.s, %w[vl3], %w[width] \n"
898
- "ld1h {z0.s}, p0/z, [%[src]] \n"
899
- "ld1h {z1.s}, p1/z, [%[src], #1, mul vl] \n"
900
- "ld1h {z2.s}, p2/z, [%[src], #2, mul vl] \n"
901
- "ld1h {z3.s}, p3/z, [%[src], #3, mul vl] \n" //
902
- HALFFLOAT_SVE
903
- "st1h {z0.s}, p0, [%[dst]] \n"
904
- "st1h {z1.s}, p1, [%[dst], #1, mul vl] \n"
905
- "st1h {z2.s}, p2, [%[dst], #2, mul vl] \n"
906
- "st1h {z3.s}, p3, [%[dst], #3, mul vl] \n"
907
-
908
- "99: \n"
909
- : [src] "+r"(src), // %[src]
910
- [dst] "+r"(dst), // %[dst]
911
- [width] "+r"(width) // %[width]
912
- : [vl] "r"(vl), // %[vl]
913
- [vl2] "r"(vl * 2), // %[vl2]
914
- [vl3] "r"(vl * 3), // %[vl3]
915
- [scale] "w"(scale * 1.9259299444e-34f) // %[scale]
916
- : "cc", "memory", "z0", "z1", "z2", "z3", "z4", "p0", "p1", "p2", "p3");
917
- }
918
-
919
- void HalfFloat1Row_SVE2(const uint16_t* src,
920
- uint16_t* dst,
921
- float scale,
922
- int width) {
923
- uint64_t vl;
924
- asm volatile(
925
- "cnth %x[vl] \n"
926
- "subs %w[width], %w[width], %w[vl], lsl #1 \n"
927
- "b.lt 2f \n"
928
-
929
- // Run bulk of computation with all-true predicates to avoid predicate
930
- // generation overhead.
931
- "ptrue p0.h \n"
932
- "1: \n"
933
- "ld1h {z0.h}, p0/z, [%[src]] \n"
934
- "ld1h {z1.h}, p0/z, [%[src], #1, mul vl] \n"
935
- "incb %[src], all, mul #2 \n"
936
- "ucvtf z0.h, p0/m, z0.h \n"
937
- "ucvtf z1.h, p0/m, z1.h \n"
938
- "subs %w[width], %w[width], %w[vl], lsl #1 \n"
939
- "st1h {z0.h}, p0, [%[dst]] \n"
940
- "st1h {z1.h}, p0, [%[dst], #1, mul vl] \n"
941
- "incb %[dst], all, mul #2 \n"
942
- "b.ge 1b \n"
943
-
944
- "2: \n"
945
- "adds %w[width], %w[width], %w[vl], lsl #1 \n"
946
- "b.eq 99f \n"
947
-
948
- // Calculate predicates for the final iteration to deal with the tail.
949
- "whilelt p0.h, wzr, %w[width] \n"
950
- "whilelt p1.h, %w[vl], %w[width] \n"
951
- "ld1h {z0.h}, p0/z, [%[src]] \n"
952
- "ld1h {z1.h}, p1/z, [%[src], #1, mul vl] \n"
953
- "ucvtf z0.h, p0/m, z0.h \n"
954
- "ucvtf z1.h, p0/m, z1.h \n"
955
- "st1h {z0.h}, p0, [%[dst]] \n"
956
- "st1h {z1.h}, p1, [%[dst], #1, mul vl] \n"
957
-
958
- "99: \n"
959
- : [src] "+r"(src), // %[src]
960
- [dst] "+r"(dst), // %[dst]
961
- [width] "+r"(width), // %[width]
962
- [vl] "=&r"(vl) // %[vl]
963
- :
964
- : "cc", "memory", "z0", "z1", "p0", "p1");
965
- }
966
-
967
- void I210ToARGBRow_SVE2(const uint16_t* src_y,
968
- const uint16_t* src_u,
969
- const uint16_t* src_v,
970
- uint8_t* dst_argb,
971
- const struct YuvConstants* yuvconstants,
972
- int width) {
973
- I210ToARGBRow_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
974
- }
975
-
976
- void I210AlphaToARGBRow_SVE2(const uint16_t* src_y,
977
- const uint16_t* src_u,
978
- const uint16_t* src_v,
979
- const uint16_t* src_a,
980
- uint8_t* dst_argb,
981
- const struct YuvConstants* yuvconstants,
982
- int width) {
983
- I210AlphaToARGBRow_SVE_SC(src_y, src_u, src_v, src_a, dst_argb, yuvconstants,
984
- width);
985
- }
986
-
987
- void I210ToAR30Row_SVE2(const uint16_t* src_y,
988
- const uint16_t* src_u,
989
- const uint16_t* src_v,
990
- uint8_t* dst_ar30,
991
- const struct YuvConstants* yuvconstants,
992
- int width) {
993
- I210ToAR30Row_SVE_SC(src_y, src_u, src_v, dst_ar30, yuvconstants, width);
994
- }
995
-
996
- void P210ToARGBRow_SVE2(const uint16_t* src_y,
997
- const uint16_t* src_uv,
998
- uint8_t* dst_argb,
999
- const struct YuvConstants* yuvconstants,
1000
- int width) {
1001
- P210ToARGBRow_SVE_SC(src_y, src_uv, dst_argb, yuvconstants, width);
1002
- }
1003
-
1004
- void P210ToAR30Row_SVE2(const uint16_t* src_y,
1005
- const uint16_t* src_uv,
1006
- uint8_t* dst_ar30,
1007
- const struct YuvConstants* yuvconstants,
1008
- int width) {
1009
- P210ToAR30Row_SVE_SC(src_y, src_uv, dst_ar30, yuvconstants, width);
1010
- }
1011
-
1012
- void I410ToARGBRow_SVE2(const uint16_t* src_y,
1013
- const uint16_t* src_u,
1014
- const uint16_t* src_v,
1015
- uint8_t* dst_argb,
1016
- const struct YuvConstants* yuvconstants,
1017
- int width) {
1018
- I410ToARGBRow_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
1019
- }
1020
-
1021
- void I410AlphaToARGBRow_SVE2(const uint16_t* src_y,
1022
- const uint16_t* src_u,
1023
- const uint16_t* src_v,
1024
- const uint16_t* src_a,
1025
- uint8_t* dst_argb,
1026
- const struct YuvConstants* yuvconstants,
1027
- int width) {
1028
- I410AlphaToARGBRow_SVE_SC(src_y, src_u, src_v, src_a, dst_argb, yuvconstants,
1029
- width);
1030
- }
1031
-
1032
- void I410ToAR30Row_SVE2(const uint16_t* src_y,
1033
- const uint16_t* src_u,
1034
- const uint16_t* src_v,
1035
- uint8_t* dst_ar30,
1036
- const struct YuvConstants* yuvconstants,
1037
- int width) {
1038
- I410ToAR30Row_SVE_SC(src_y, src_u, src_v, dst_ar30, yuvconstants, width);
1039
- }
1040
-
1041
- void P410ToARGBRow_SVE2(const uint16_t* src_y,
1042
- const uint16_t* src_uv,
1043
- uint8_t* dst_argb,
1044
- const struct YuvConstants* yuvconstants,
1045
- int width) {
1046
- P410ToARGBRow_SVE_SC(src_y, src_uv, dst_argb, yuvconstants, width);
1047
- }
1048
-
1049
- void P410ToAR30Row_SVE2(const uint16_t* src_y,
1050
- const uint16_t* src_uv,
1051
- uint8_t* dst_ar30,
1052
- const struct YuvConstants* yuvconstants,
1053
- int width) {
1054
- P410ToAR30Row_SVE_SC(src_y, src_uv, dst_ar30, yuvconstants, width);
1055
- }
1056
-
1057
- void I212ToAR30Row_SVE2(const uint16_t* src_y,
1058
- const uint16_t* src_u,
1059
- const uint16_t* src_v,
1060
- uint8_t* dst_ar30,
1061
- const struct YuvConstants* yuvconstants,
1062
- int width) {
1063
- I212ToAR30Row_SVE_SC(src_y, src_u, src_v, dst_ar30, yuvconstants, width);
1064
- }
1065
-
1066
- void I212ToARGBRow_SVE2(const uint16_t* src_y,
1067
- const uint16_t* src_u,
1068
- const uint16_t* src_v,
1069
- uint8_t* dst_argb,
1070
- const struct YuvConstants* yuvconstants,
1071
- int width) {
1072
- I212ToARGBRow_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
1073
- }
1074
-
1075
- void Convert8To8Row_SVE2(const uint8_t* src_y,
1076
- uint8_t* dst_y,
1077
- int scale,
1078
- int bias,
1079
- int width) {
1080
- Convert8To8Row_SVE_SC(src_y, dst_y, scale, bias, width);
1081
- }
1082
-
1083
- #endif // !defined(LIBYUV_DISABLE_SVE) && defined(__aarch64__)
1084
-
1085
- #ifdef __cplusplus
1086
- } // extern "C"
1087
- } // namespace libyuv
1088
- #endif
1
+ /*
2
+ * Copyright 2024 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 "libyuv/row_sve.h"
12
+ #include "libyuv/row.h"
13
+
14
+ #ifdef __cplusplus
15
+ namespace libyuv {
16
+ extern "C" {
17
+ #endif
18
+
19
+ #if !defined(LIBYUV_DISABLE_SVE) && defined(__aarch64__)
20
+
21
+ #define RGBTOARGB8_SVE_2X \
22
+ /* Inputs: B: z16.h, G: z17.h, R: z18.h, A: z19.b */ \
23
+ "uqshrnb z16.b, z16.h, #6 \n" /* B0 */ \
24
+ "uqshrnb z17.b, z17.h, #6 \n" /* G0 */ \
25
+ "uqshrnb z18.b, z18.h, #6 \n" /* R0 */ \
26
+ "uqshrnt z16.b, z20.h, #6 \n" /* B1 */ \
27
+ "uqshrnt z17.b, z21.h, #6 \n" /* G1 */ \
28
+ "uqshrnt z18.b, z22.h, #6 \n" /* R1 */
29
+
30
+ #define RGBTOARGB8_SVE_TOP_2X \
31
+ /* Inputs: B: z16.h, G: z17.h, R: z18.h */ \
32
+ "uqshl z16.h, p0/m, z16.h, #2 \n" /* B0 */ \
33
+ "uqshl z17.h, p0/m, z17.h, #2 \n" /* G0 */ \
34
+ "uqshl z18.h, p0/m, z18.h, #2 \n" /* R0 */ \
35
+ "uqshl z20.h, p0/m, z20.h, #2 \n" /* B1 */ \
36
+ "uqshl z21.h, p0/m, z21.h, #2 \n" /* G1 */ \
37
+ "uqshl z22.h, p0/m, z22.h, #2 \n" /* R1 */
38
+
39
+ void I444ToARGBRow_SVE2(const uint8_t* src_y,
40
+ const uint8_t* src_u,
41
+ const uint8_t* src_v,
42
+ uint8_t* dst_argb,
43
+ const struct YuvConstants* yuvconstants,
44
+ int width) {
45
+ uint64_t vl;
46
+ asm volatile(
47
+ "cnth %[vl] \n"
48
+ "ptrue p0.b \n" //
49
+ YUVTORGB_SVE_SETUP
50
+ "dup z19.b, #255 \n" // Alpha
51
+ "subs %w[width], %w[width], %w[vl] \n"
52
+ "b.lt 2f \n"
53
+
54
+ // Run bulk of computation with an all-true predicate to avoid predicate
55
+ // generation overhead.
56
+ "ptrue p1.h \n"
57
+ "1: \n" //
58
+ READYUV444_SVE I4XXTORGB_SVE RGBTOARGB8_SVE
59
+ "subs %w[width], %w[width], %w[vl] \n"
60
+ "st2h {z16.h, z17.h}, p1, [%[dst_argb]] \n"
61
+ "add %[dst_argb], %[dst_argb], %[vl], lsl #2 \n"
62
+ "b.ge 1b \n"
63
+
64
+ "2: \n"
65
+ "adds %w[width], %w[width], %w[vl] \n"
66
+ "b.eq 99f \n"
67
+
68
+ // Calculate a predicate for the final iteration to deal with the tail.
69
+ "whilelt p1.h, wzr, %w[width] \n" //
70
+ READYUV444_SVE I4XXTORGB_SVE RGBTOARGB8_SVE
71
+ "st2h {z16.h, z17.h}, p1, [%[dst_argb]] \n"
72
+
73
+ "99: \n"
74
+ : [src_y] "+r"(src_y), // %[src_y]
75
+ [src_u] "+r"(src_u), // %[src_u]
76
+ [src_v] "+r"(src_v), // %[src_v]
77
+ [dst_argb] "+r"(dst_argb), // %[dst_argb]
78
+ [width] "+r"(width), // %[width]
79
+ [vl] "=&r"(vl) // %[vl]
80
+ : [kUVCoeff] "r"(&yuvconstants->kUVCoeff), // %[kUVCoeff]
81
+ [kRGBCoeffBias] "r"(&yuvconstants->kRGBCoeffBias) // %[kRGBCoeffBias]
82
+ : "cc", "memory", YUVTORGB_SVE_REGS);
83
+ }
84
+
85
+ void I444ToRGB24Row_SVE2(const uint8_t* src_y,
86
+ const uint8_t* src_u,
87
+ const uint8_t* src_v,
88
+ uint8_t* dst_rgb24,
89
+ const struct YuvConstants* yuvconstants,
90
+ int width) {
91
+ I444ToRGB24Row_SVE_SC(src_y, src_u, src_v, dst_rgb24, yuvconstants, width);
92
+ }
93
+
94
+ void I400ToARGBRow_SVE2(const uint8_t* src_y,
95
+ uint8_t* dst_argb,
96
+ const struct YuvConstants* yuvconstants,
97
+ int width) {
98
+ I400ToARGBRow_SVE_SC(src_y, dst_argb, yuvconstants, width);
99
+ }
100
+
101
+ void I422ToARGBRow_SVE2(const uint8_t* src_y,
102
+ const uint8_t* src_u,
103
+ const uint8_t* src_v,
104
+ uint8_t* dst_argb,
105
+ const struct YuvConstants* yuvconstants,
106
+ int width) {
107
+ I422ToARGBRow_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
108
+ }
109
+
110
+ void I422ToRGB24Row_SVE2(const uint8_t* src_y,
111
+ const uint8_t* src_u,
112
+ const uint8_t* src_v,
113
+ uint8_t* dst_argb,
114
+ const struct YuvConstants* yuvconstants,
115
+ int width) {
116
+ I422ToRGB24Row_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
117
+ }
118
+
119
+ void I422ToRGB565Row_SVE2(const uint8_t* src_y,
120
+ const uint8_t* src_u,
121
+ const uint8_t* src_v,
122
+ uint8_t* dst_rgb565,
123
+ const struct YuvConstants* yuvconstants,
124
+ int width) {
125
+ I422ToRGB565Row_SVE_SC(src_y, src_u, src_v, dst_rgb565, yuvconstants, width);
126
+ }
127
+
128
+ void I422ToARGB1555Row_SVE2(const uint8_t* src_y,
129
+ const uint8_t* src_u,
130
+ const uint8_t* src_v,
131
+ uint8_t* dst_argb1555,
132
+ const struct YuvConstants* yuvconstants,
133
+ int width) {
134
+ I422ToARGB1555Row_SVE_SC(src_y, src_u, src_v, dst_argb1555, yuvconstants,
135
+ width);
136
+ }
137
+
138
+ void I422ToARGB4444Row_SVE2(const uint8_t* src_y,
139
+ const uint8_t* src_u,
140
+ const uint8_t* src_v,
141
+ uint8_t* dst_argb4444,
142
+ const struct YuvConstants* yuvconstants,
143
+ int width) {
144
+ I422ToARGB4444Row_SVE_SC(src_y, src_u, src_v, dst_argb4444, yuvconstants,
145
+ width);
146
+ }
147
+
148
+ void I422ToRGBARow_SVE2(const uint8_t* src_y,
149
+ const uint8_t* src_u,
150
+ const uint8_t* src_v,
151
+ uint8_t* dst_argb,
152
+ const struct YuvConstants* yuvconstants,
153
+ int width) {
154
+ I422ToRGBARow_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
155
+ }
156
+
157
+ void I422ToAR30Row_SVE2(const uint8_t* src_y,
158
+ const uint8_t* src_u,
159
+ const uint8_t* src_v,
160
+ uint8_t* dst_argb,
161
+ const struct YuvConstants* yuvconstants,
162
+ int width) {
163
+ I422ToAR30Row_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
164
+ }
165
+
166
+ void I422AlphaToARGBRow_SVE2(const uint8_t* src_y,
167
+ const uint8_t* src_u,
168
+ const uint8_t* src_v,
169
+ const uint8_t* src_a,
170
+ uint8_t* dst_argb,
171
+ const struct YuvConstants* yuvconstants,
172
+ int width) {
173
+ I422AlphaToARGBRow_SVE_SC(src_y, src_u, src_v, src_a, dst_argb, yuvconstants,
174
+ width);
175
+ }
176
+
177
+ void I444AlphaToARGBRow_SVE2(const uint8_t* src_y,
178
+ const uint8_t* src_u,
179
+ const uint8_t* src_v,
180
+ const uint8_t* src_a,
181
+ uint8_t* dst_argb,
182
+ const struct YuvConstants* yuvconstants,
183
+ int width) {
184
+ I444AlphaToARGBRow_SVE_SC(src_y, src_u, src_v, src_a, dst_argb, yuvconstants,
185
+ width);
186
+ }
187
+
188
+ void NV12ToARGBRow_SVE2(const uint8_t* src_y,
189
+ const uint8_t* src_uv,
190
+ uint8_t* dst_argb,
191
+ const struct YuvConstants* yuvconstants,
192
+ int width) {
193
+ NV12ToARGBRow_SVE_SC(src_y, src_uv, dst_argb, yuvconstants, width);
194
+ }
195
+
196
+ void NV21ToARGBRow_SVE2(const uint8_t* src_y,
197
+ const uint8_t* src_vu,
198
+ uint8_t* dst_argb,
199
+ const struct YuvConstants* yuvconstants,
200
+ int width) {
201
+ NV21ToARGBRow_SVE_SC(src_y, src_vu, dst_argb, yuvconstants, width);
202
+ }
203
+
204
+ void NV12ToRGB24Row_SVE2(const uint8_t* src_y,
205
+ const uint8_t* src_uv,
206
+ uint8_t* dst_rgb24,
207
+ const struct YuvConstants* yuvconstants,
208
+ int width) {
209
+ NV12ToRGB24Row_SVE_SC(src_y, src_uv, dst_rgb24, yuvconstants, width);
210
+ }
211
+
212
+ void NV21ToRGB24Row_SVE2(const uint8_t* src_y,
213
+ const uint8_t* src_vu,
214
+ uint8_t* dst_rgb24,
215
+ const struct YuvConstants* yuvconstants,
216
+ int width) {
217
+ NV21ToRGB24Row_SVE_SC(src_y, src_vu, dst_rgb24, yuvconstants, width);
218
+ }
219
+
220
+ void ARGBToUVRow_SVE2(const uint8_t* src_argb,
221
+ int src_stride_argb,
222
+ uint8_t* dst_u,
223
+ uint8_t* dst_v,
224
+ int width) {
225
+ ARGBToUVMatrixRow_SVE_SC(src_argb, src_stride_argb, dst_u, dst_v, width,
226
+ kARGBToUVCoefficients);
227
+ }
228
+
229
+ void ARGBToUVJRow_SVE2(const uint8_t* src_argb,
230
+ int src_stride_argb,
231
+ uint8_t* dst_u,
232
+ uint8_t* dst_v,
233
+ int width) {
234
+ ARGBToUVMatrixRow_SVE_SC(src_argb, src_stride_argb, dst_u, dst_v, width,
235
+ kARGBToUVJCoefficients);
236
+ }
237
+
238
+ void ABGRToUVJRow_SVE2(const uint8_t* src_abgr,
239
+ int src_stride_abgr,
240
+ uint8_t* dst_uj,
241
+ uint8_t* dst_vj,
242
+ int width) {
243
+ ARGBToUVMatrixRow_SVE_SC(src_abgr, src_stride_abgr, dst_uj, dst_vj, width,
244
+ kABGRToUVJCoefficients);
245
+ }
246
+
247
+ void BGRAToUVRow_SVE2(const uint8_t* src_bgra,
248
+ int src_stride_bgra,
249
+ uint8_t* dst_u,
250
+ uint8_t* dst_v,
251
+ int width) {
252
+ ARGBToUVMatrixRow_SVE_SC(src_bgra, src_stride_bgra, dst_u, dst_v, width,
253
+ kBGRAToUVCoefficients);
254
+ }
255
+
256
+ void ABGRToUVRow_SVE2(const uint8_t* src_abgr,
257
+ int src_stride_abgr,
258
+ uint8_t* dst_u,
259
+ uint8_t* dst_v,
260
+ int width) {
261
+ ARGBToUVMatrixRow_SVE_SC(src_abgr, src_stride_abgr, dst_u, dst_v, width,
262
+ kABGRToUVCoefficients);
263
+ }
264
+
265
+ void RGBAToUVRow_SVE2(const uint8_t* src_rgba,
266
+ int src_stride_rgba,
267
+ uint8_t* dst_u,
268
+ uint8_t* dst_v,
269
+ int width) {
270
+ ARGBToUVMatrixRow_SVE_SC(src_rgba, src_stride_rgba, dst_u, dst_v, width,
271
+ kRGBAToUVCoefficients);
272
+ }
273
+
274
+ #define ARGBTORGB565_SVE \
275
+ /* Inputs: \
276
+ * z0: rrrrrxxxbbbbbxxx \
277
+ * z1: xxxxxxxxggggggxx \
278
+ * z3: 0000000000000011 (3, 0, 3, 0, ...) \
279
+ * z4: 0000011111100000 \
280
+ */ \
281
+ "lsr z0.b, p0/m, z0.b, z3.b \n" \
282
+ "lsl z1.h, z1.h, #3 \n" \
283
+ "bsl z1.d, z1.d, z0.d, z4.d \n"
284
+
285
+ void ARGBToRGB565Row_SVE2(const uint8_t* src_argb,
286
+ uint8_t* dst_rgb,
287
+ int width) {
288
+ unsigned bsl_mask = 0x7e0;
289
+ uint64_t vl;
290
+ width *= 2;
291
+ asm volatile(
292
+ "mov z3.h, #3 \n"
293
+ "dup z4.h, %w[bsl_mask] \n"
294
+
295
+ "cntb %[vl] \n"
296
+ "subs %w[width], %w[width], %w[vl] \n"
297
+ "b.lt 2f \n"
298
+
299
+ "ptrue p0.b \n"
300
+ "1: \n"
301
+ "ld2b {z0.b, z1.b}, p0/z, [%[src]] \n" // BR, GA
302
+ "incb %[src], all, mul #2 \n"
303
+ "subs %w[width], %w[width], %w[vl] \n" //
304
+ ARGBTORGB565_SVE
305
+ "st1b {z1.b}, p0, [%[dst]] \n"
306
+ "incb %[dst] \n"
307
+ "b.ge 1b \n"
308
+
309
+ "2: \n"
310
+ "adds %w[width], %w[width], %w[vl] \n"
311
+ "b.eq 99f \n"
312
+
313
+ "whilelt p0.b, wzr, %w[width] \n"
314
+ "ld2b {z0.b, z1.b}, p0/z, [%[src]] \n" // BR, GA
315
+ ARGBTORGB565_SVE
316
+ "st1b {z1.b}, p0, [%[dst]] \n"
317
+
318
+ "99: \n"
319
+ : [src] "+r"(src_argb), // %[src]
320
+ [dst] "+r"(dst_rgb), // %[dst]
321
+ [width] "+r"(width), // %[width]
322
+ [vl] "=&r"(vl) // %[vl]
323
+ : [bsl_mask] "r"(bsl_mask) // %[bsl_mask]
324
+ : "cc", "memory", "z0", "z1", "z3", "z4", "p0");
325
+ }
326
+
327
+ void ARGBToRGB565DitherRow_SVE2(const uint8_t* src_argb,
328
+ uint8_t* dst_rgb,
329
+ uint32_t dither4,
330
+ int width) {
331
+ unsigned bsl_mask = 0x7e0;
332
+ uint64_t vl;
333
+ width *= 2;
334
+ asm volatile(
335
+ "mov z3.h, #3 \n"
336
+ "dup z4.h, %w[bsl_mask] \n"
337
+ "dup z2.s, %w[dither4] \n"
338
+ "zip1 z2.b, z2.b, z2.b \n"
339
+
340
+ "cntb %[vl] \n"
341
+ "subs %w[width], %w[width], %w[vl] \n"
342
+ "b.lt 2f \n"
343
+
344
+ "ptrue p0.b \n"
345
+ "1: \n"
346
+ "ld2b {z0.b, z1.b}, p0/z, [%[src]] \n" // BR, GA
347
+ "incb %[src], all, mul #2 \n"
348
+ "uqadd z0.b, z0.b, z2.b \n"
349
+ "uqadd z1.b, z1.b, z2.b \n"
350
+ "subs %w[width], %w[width], %w[vl] \n" //
351
+ ARGBTORGB565_SVE
352
+ "st1b {z1.b}, p0, [%[dst]] \n"
353
+ "incb %[dst] \n"
354
+ "b.ge 1b \n"
355
+
356
+ "2: \n"
357
+ "adds %w[width], %w[width], %w[vl] \n"
358
+ "b.eq 99f \n"
359
+
360
+ "whilelt p0.b, wzr, %w[width] \n"
361
+ "ld2b {z0.b, z1.b}, p0/z, [%[src]] \n" // BR, GA
362
+ "uqadd z0.b, z0.b, z2.b \n"
363
+ "uqadd z1.b, z1.b, z2.b \n" //
364
+ ARGBTORGB565_SVE
365
+ "st1b {z1.b}, p0, [%[dst]] \n"
366
+
367
+ "99: \n"
368
+ : [src] "+r"(src_argb), // %[src]
369
+ [dst] "+r"(dst_rgb), // %[dst]
370
+ [width] "+r"(width), // %[width]
371
+ [vl] "=&r"(vl) // %[vl]
372
+ : [bsl_mask] "r"(bsl_mask), // %[bsl_mask]
373
+ [dither4] "r"(dither4) // %[dither4]
374
+ : "cc", "memory", "z0", "z1", "z3", "z4", "p0");
375
+ }
376
+
377
+ #define ARGB1555TOARGB \
378
+ /* Input: z1/z3.h = arrrrrgggggbbbbb */ \
379
+ "lsl z0.h, z1.h, #3 \n" /* rrrgggggbbbbb000 */ \
380
+ "lsl z2.h, z3.h, #3 \n" /* rrrgggggbbbbb000 */ \
381
+ "asr z1.h, z1.h, #7 \n" /* aaaaaaaarrrrrggg */ \
382
+ "asr z3.h, z3.h, #7 \n" /* aaaaaaaarrrrrggg */ \
383
+ "lsl z0.b, p0/m, z0.b, z4.b \n" /* ggggg000bbbbb000 */ \
384
+ "lsl z2.b, p0/m, z2.b, z4.b \n" /* ggggg000bbbbb000 */ \
385
+ "sri z1.b, z1.b, #5 \n" /* aaaaaaaarrrrrrrr */ \
386
+ "sri z3.b, z3.b, #5 \n" /* aaaaaaaarrrrrrrr */ \
387
+ "sri z0.b, z0.b, #5 \n" /* ggggggggbbbbbbbb */ \
388
+ "sri z2.b, z2.b, #5 \n" /* ggggggggbbbbbbbb */
389
+
390
+ void ARGB1555ToARGBRow_SVE2(const uint8_t* src_argb1555,
391
+ uint8_t* dst_argb,
392
+ int width) {
393
+ uint64_t vl;
394
+ asm volatile(
395
+ "mov z4.h, #0x0300 \n"
396
+ "ptrue p0.b \n"
397
+
398
+ "cnth %x[vl] \n"
399
+ "subs %w[width], %w[width], %w[vl], lsl #1 \n"
400
+ "b.lt 2f \n"
401
+
402
+ "1: \n"
403
+ "ld1h {z1.h}, p0/z, [%[src]] \n"
404
+ "ld1h {z3.h}, p0/z, [%[src], #1, mul vl] \n"
405
+ "incb %[src], all, mul #2 \n" //
406
+ ARGB1555TOARGB
407
+ "subs %w[width], %w[width], %w[vl], lsl #1 \n"
408
+ "st2h {z0.h, z1.h}, p0, [%[dst]] \n"
409
+ "st2h {z2.h, z3.h}, p0, [%[dst], #2, mul vl] \n"
410
+ "incb %[dst], all, mul #4 \n"
411
+ "b.ge 1b \n"
412
+
413
+ "2: \n"
414
+ "adds %w[width], %w[width], %w[vl], lsl #1 \n"
415
+ "b.eq 99f \n"
416
+
417
+ "whilelt p1.h, wzr, %w[width] \n"
418
+ "whilelt p2.h, %w[vl], %w[width] \n"
419
+ "ld1h {z1.h}, p1/z, [%[src]] \n"
420
+ "ld1h {z3.h}, p2/z, [%[src], #1, mul vl] \n" //
421
+ ARGB1555TOARGB
422
+ "st2h {z0.h, z1.h}, p1, [%[dst]] \n"
423
+ "st2h {z2.h, z3.h}, p2, [%[dst], #2, mul vl] \n"
424
+
425
+ "99: \n"
426
+ : [src] "+r"(src_argb1555), // %[src]
427
+ [dst] "+r"(dst_argb), // %[dst]
428
+ [width] "+r"(width), // %[width]
429
+ [vl] "=&r"(vl) // %[vl]
430
+ :
431
+ : "cc", "memory", "z0", "z1", "z2", "z3", "z4", "p0", "p1", "p2");
432
+ }
433
+
434
+ // clang-format off
435
+ #define AYUVTOUV_SVE(zU0, zV0, zU1, zV1) /* e.g. */ \
436
+ "ld2h {z0.h, z1.h}, p0/z, [%[src0]] \n" /* VUVU.. YAYA.. */ \
437
+ "ld2h {z1.h, z2.h}, p1/z, [%[src0], #2, mul vl] \n" /* VUVU.. YAYA.. */ \
438
+ "ld2h {z2.h, z3.h}, p0/z, [%[src1]] \n" /* VUVU.. YAYA.. */ \
439
+ "ld2h {z3.h, z4.h}, p1/z, [%[src1], #2, mul vl] \n" /* VUVU.. YAYA.. */ \
440
+ "incb %[src0], all, mul #4 \n" \
441
+ "incb %[src1], all, mul #4 \n" \
442
+ "uaddlb z4.h, z0.b, z2.b \n" /* V */ \
443
+ "uaddlt z5.h, z0.b, z2.b \n" /* U */ \
444
+ "uaddlb z6.h, z1.b, z3.b \n" /* V */ \
445
+ "uaddlt z7.h, z1.b, z3.b \n" /* U */ \
446
+ "addp " #zU0 ".h, p0/m, " #zU0 ".h, " #zV0 ".h \n" /* UV */ \
447
+ "addp " #zU1 ".h, p1/m, " #zU1 ".h, " #zV1 ".h \n" /* UV */ \
448
+ "subs %w[width], %w[width], %w[vl] \n" \
449
+ "urshr " #zU0 ".h, p0/m, " #zU0 ".h, #2 \n" /* U0V0 */ \
450
+ "urshr " #zU1 ".h, p1/m, " #zU1 ".h, #2 \n" /* U0V0 */ \
451
+ "st1b {" #zU0 ".h}, p0, [%[dst]] \n" \
452
+ "st1b {" #zU1 ".h}, p1, [%[dst], #1, mul vl] \n" \
453
+ "incb %[dst] \n"
454
+ // clang-format on
455
+
456
+ // Filter 2 rows of AYUV UV's (444) into UV (420).
457
+ // AYUV is VUYA in memory. UV for NV12 is UV order in memory.
458
+ void AYUVToUVRow_SVE2(const uint8_t* src_ayuv,
459
+ int src_stride_ayuv,
460
+ uint8_t* dst_uv,
461
+ int width) {
462
+ // Output a row of UV values, filtering 2x2 rows of AYUV.
463
+ const uint8_t* src_ayuv1 = src_ayuv + src_stride_ayuv;
464
+ int vl;
465
+ asm volatile (
466
+ "cntb %x[vl] \n"
467
+ "subs %w[width], %w[width], %w[vl] \n"
468
+ "b.lt 2f \n"
469
+
470
+ "ptrue p0.h \n"
471
+ "ptrue p1.h \n"
472
+ "1: \n"
473
+ AYUVTOUV_SVE(z5, z4, z7, z6)
474
+ "b.ge 1b \n"
475
+
476
+ "2: \n"
477
+ "adds %w[width], %w[width], %w[vl] \n"
478
+ "b.eq 99f \n"
479
+
480
+ "cnth %x[vl] \n"
481
+ "whilelt p0.h, wzr, %w[width] \n" // first row
482
+ "whilelt p1.h, %w[vl], %w[width] \n" // second row
483
+ AYUVTOUV_SVE(z5, z4, z7, z6)
484
+
485
+ "99: \n"
486
+ : [src0]"+r"(src_ayuv), // %[src0]
487
+ [src1]"+r"(src_ayuv1), // %[src1]
488
+ [dst]"+r"(dst_uv), // %[dst]
489
+ [width]"+r"(width), // %[width]
490
+ [vl]"=&r"(vl) // %[vl]
491
+ :
492
+ : "cc", "memory", "z0", "z1", "z2", "z3", "z4", "z5", "z6", "z7", "p0",
493
+ "p1");
494
+ }
495
+
496
+ // Filter 2 rows of AYUV UV's (444) into VU (420).
497
+ void AYUVToVURow_SVE2(const uint8_t* src_ayuv,
498
+ int src_stride_ayuv,
499
+ uint8_t* dst_vu,
500
+ int width) {
501
+ // Output a row of VU values, filtering 2x2 rows of AYUV.
502
+ const uint8_t* src_ayuv1 = src_ayuv + src_stride_ayuv;
503
+ int vl;
504
+ asm volatile (
505
+ "cntb %x[vl] \n"
506
+ "cmp %w[width], %w[vl] \n"
507
+ "subs %w[width], %w[width], %w[vl] \n"
508
+ "b.lt 2f \n"
509
+
510
+ "ptrue p0.h \n"
511
+ "ptrue p1.h \n"
512
+ "1: \n"
513
+ AYUVTOUV_SVE(z4, z5, z6, z7)
514
+ "b.ge 1b \n"
515
+
516
+ "2: \n"
517
+ "adds %w[width], %w[width], %w[vl] \n"
518
+ "b.eq 99f \n"
519
+
520
+ "cnth %x[vl] \n"
521
+ "whilelt p0.h, wzr, %w[width] \n" // first row
522
+ "whilelt p1.h, %w[vl], %w[width] \n" // second row
523
+ AYUVTOUV_SVE(z4, z5, z6, z7)
524
+
525
+ "99: \n"
526
+ : [src0]"+r"(src_ayuv), // %[src0]
527
+ [src1]"+r"(src_ayuv1), // %[src1]
528
+ [dst]"+r"(dst_vu), // %[dst]
529
+ [width]"+r"(width), // %[width]
530
+ [vl]"=&r"(vl) // %[vl]
531
+ :
532
+ : "cc", "memory", "z0", "z1", "z2", "z3", "z4", "z5", "z6", "z7", "p0",
533
+ "p1");
534
+ }
535
+
536
+ void YUY2ToARGBRow_SVE2(const uint8_t* src_yuy2,
537
+ uint8_t* dst_argb,
538
+ const struct YuvConstants* yuvconstants,
539
+ int width) {
540
+ YUY2ToARGBRow_SVE_SC(src_yuy2, dst_argb, yuvconstants, width);
541
+ }
542
+
543
+ void UYVYToARGBRow_SVE2(const uint8_t* src_uyvy,
544
+ uint8_t* dst_argb,
545
+ const struct YuvConstants* yuvconstants,
546
+ int width) {
547
+ UYVYToARGBRow_SVE_SC(src_uyvy, dst_argb, yuvconstants, width);
548
+ }
549
+
550
+ static inline void RAWToWXYZRow_SVE2(const uint8_t* src_raw,
551
+ uint8_t* dst_wxyz,
552
+ int width,
553
+ uint32_t idx_start,
554
+ uint32_t idx_step,
555
+ uint32_t alpha) {
556
+ uint32_t vl;
557
+ asm("cntw %x0" : "=r"(vl));
558
+ uint32_t vl_mul3 = vl * 3;
559
+ uint32_t rem_mul3;
560
+ asm volatile(
561
+ "index z31.s, %w[idx_start], %w[idx_step] \n"
562
+ "dup z30.s, %w[alpha] \n"
563
+ "subs %w[width], %w[width], %w[vl], lsl #1 \n"
564
+ "b.lt 2f \n"
565
+
566
+ // Run bulk of computation with the same predicates to avoid predicate
567
+ // generation overhead. We set up p1 to only load 3/4 of a vector.
568
+ "ptrue p0.s \n"
569
+ "whilelt p1.b, wzr, %w[vl_mul3] \n"
570
+ "1: \n"
571
+ "ld1b {z0.b}, p1/z, [%[src]] \n"
572
+ "add %[src], %[src], %x[vl_mul3] \n"
573
+ "ld1b {z1.b}, p1/z, [%[src]] \n"
574
+ "add %[src], %[src], %x[vl_mul3] \n"
575
+ "tbl z0.b, {z0.b}, z31.b \n"
576
+ "tbl z1.b, {z1.b}, z31.b \n"
577
+ "subs %w[width], %w[width], %w[vl], lsl #1 \n"
578
+ "orr z0.d, z0.d, z30.d \n"
579
+ "orr z1.d, z1.d, z30.d \n"
580
+ "st1w {z0.s}, p0, [%[dst]] \n"
581
+ "st1w {z1.s}, p0, [%[dst], #1, mul vl] \n"
582
+ "incb %[dst], all, mul #2 \n"
583
+ "b.ge 1b \n"
584
+
585
+ "2: \n"
586
+ "adds %w[width], %w[width], %w[vl], lsl #1 \n"
587
+ "b.eq 99f \n"
588
+
589
+ // Calculate a pair of predicates for the final iteration to deal with
590
+ // the tail.
591
+ "3: \n"
592
+ "add %w[rem_mul3], %w[width], %w[width], lsl #1 \n"
593
+ "whilelt p0.s, wzr, %w[width] \n"
594
+ "whilelt p1.b, wzr, %w[rem_mul3] \n"
595
+ "ld1b {z0.b}, p1/z, [%[src]] \n"
596
+ "add %[src], %[src], %x[vl_mul3] \n"
597
+ "tbl z0.b, {z0.b}, z31.b \n"
598
+ "subs %w[width], %w[width], %w[vl] \n"
599
+ "orr z0.d, z0.d, z30.d \n"
600
+ "st1w {z0.s}, p0, [%[dst]] \n"
601
+ "incb %[dst] \n"
602
+ "b.gt 3b \n"
603
+
604
+ "99: \n"
605
+ : [src] "+r"(src_raw), // %[src]
606
+ [dst] "+r"(dst_wxyz), // %[dst]
607
+ [width] "+r"(width), // %[width]
608
+ [vl_mul3] "+r"(vl_mul3), // %[vl_mul3]
609
+ [rem_mul3] "=&r"(rem_mul3) // %[rem_mul3]
610
+ : [idx_start] "r"(idx_start), // %[idx_start]
611
+ [idx_step] "r"(idx_step), // %[idx_step]
612
+ [alpha] "r"(alpha), // %[alpha]
613
+ [vl] "r"(vl) // %[vl]
614
+ : "cc", "memory", "z0", "z1", "z30", "z31", "p0", "p1");
615
+ }
616
+
617
+ void RAWToARGBRow_SVE2(const uint8_t* src_raw, uint8_t* dst_argb, int width) {
618
+ RAWToWXYZRow_SVE2(src_raw, dst_argb, width, 0xff000102U, 0x00030303U,
619
+ 0xff000000U);
620
+ }
621
+
622
+ void RAWToRGBARow_SVE2(const uint8_t* src_raw, uint8_t* dst_rgba, int width) {
623
+ RAWToWXYZRow_SVE2(src_raw, dst_rgba, width, 0x000102ffU, 0x03030300U,
624
+ 0x000000ffU);
625
+ }
626
+
627
+ void RGB24ToARGBRow_SVE2(const uint8_t* src_rgb24,
628
+ uint8_t* dst_argb,
629
+ int width) {
630
+ RAWToWXYZRow_SVE2(src_rgb24, dst_argb, width, 0xff020100U, 0x00030303U,
631
+ 0xff000000U);
632
+ }
633
+
634
+ static const uint8_t kRAWToRGB24Indices[] = {
635
+ 2, 1, 0, 5, 4, 3, 8, 7, 6, 11, 10, 9, 14, 13, 12,
636
+ 17, 16, 15, 20, 19, 18, 23, 22, 21, 26, 25, 24, 29, 28, 27,
637
+ 32, 31, 30, 35, 34, 33, 38, 37, 36, 41, 40, 39, 44, 43, 42,
638
+ 47, 46, 45, 50, 49, 48, 53, 52, 51, 56, 55, 54, 59, 58, 57,
639
+ 62, 61, 60, 65, 64, 63, 68, 67, 66, 71, 70, 69, 74, 73, 72,
640
+ 77, 76, 75, 80, 79, 78, 83, 82, 81, 86, 85, 84, 89, 88, 87,
641
+ 92, 91, 90, 95, 94, 93, 98, 97, 96, 101, 100, 99, 104, 103, 102,
642
+ 107, 106, 105, 110, 109, 108, 113, 112, 111, 116, 115, 114, 119, 118, 117,
643
+ 122, 121, 120, 125, 124, 123, 128, 127, 126, 131, 130, 129, 134, 133, 132,
644
+ 137, 136, 135, 140, 139, 138, 143, 142, 141, 146, 145, 144, 149, 148, 147,
645
+ 152, 151, 150, 155, 154, 153, 158, 157, 156, 161, 160, 159, 164, 163, 162,
646
+ 167, 166, 165, 170, 169, 168, 173, 172, 171, 176, 175, 174, 179, 178, 177,
647
+ 182, 181, 180, 185, 184, 183, 188, 187, 186, 191, 190, 189, 194, 193, 192,
648
+ 197, 196, 195, 200, 199, 198, 203, 202, 201, 206, 205, 204, 209, 208, 207,
649
+ 212, 211, 210, 215, 214, 213, 218, 217, 216, 221, 220, 219, 224, 223, 222,
650
+ 227, 226, 225, 230, 229, 228, 233, 232, 231, 236, 235, 234, 239, 238, 237,
651
+ 242, 241, 240, 245, 244, 243, 248, 247, 246, 251, 250, 249, 254, 253, 252};
652
+
653
+ void RAWToRGB24Row_SVE2(const uint8_t* src_raw, uint8_t* dst_rgb24, int width) {
654
+ // width is in elements, convert to bytes.
655
+ width *= 3;
656
+ // we use the mul3 predicate pattern throughout to use the largest multiple
657
+ // of three number of lanes, for instance with a vector length of 16 bytes
658
+ // only the first 15 bytes will be used for load/store instructions.
659
+ uint32_t vl;
660
+ asm volatile(
661
+ "cntb %x[vl], mul3 \n"
662
+ "ptrue p0.b, mul3 \n"
663
+ "ld1b {z31.b}, p0/z, [%[kIndices]] \n"
664
+ "subs %w[width], %w[width], %w[vl] \n"
665
+ "b.lt 2f \n"
666
+
667
+ // Run bulk of computation with the same predicate to avoid predicate
668
+ // generation overhead.
669
+ "1: \n"
670
+ "ld1b {z0.b}, p0/z, [%[src]] \n"
671
+ "add %[src], %[src], %x[vl] \n"
672
+ "tbl z0.b, {z0.b}, z31.b \n"
673
+ "subs %w[width], %w[width], %w[vl] \n"
674
+ "st1b {z0.b}, p0, [%[dst]] \n"
675
+ "add %[dst], %[dst], %x[vl] \n"
676
+ "b.ge 1b \n"
677
+
678
+ "2: \n"
679
+ "adds %w[width], %w[width], %w[vl] \n"
680
+ "b.eq 99f \n"
681
+
682
+ // Calculate a predicate for the final iteration to deal with the tail.
683
+ "whilelt p0.b, wzr, %w[width] \n"
684
+ "ld1b {z0.b}, p0/z, [%[src]] \n"
685
+ "tbl z0.b, {z0.b}, z31.b \n"
686
+ "st1b {z0.b}, p0, [%[dst]] \n"
687
+
688
+ "99: \n"
689
+ : [src] "+r"(src_raw), // %[src]
690
+ [dst] "+r"(dst_rgb24), // %[dst]
691
+ [width] "+r"(width), // %[width]
692
+ [vl] "=&r"(vl) // %[vl]
693
+ : [kIndices] "r"(kRAWToRGB24Indices) // %[kIndices]
694
+ : "cc", "memory", "z0", "z31", "p0");
695
+ }
696
+
697
+ static inline void ARGBToXYZRow_SVE2(const uint8_t* src_argb,
698
+ uint8_t* dst_xyz,
699
+ int width,
700
+ const uint8_t* indices) {
701
+ uint32_t vl;
702
+ asm("cntw %x0" : "=r"(vl));
703
+ uint32_t vl_mul3 = vl * 3;
704
+ uint32_t rem_mul3;
705
+ asm volatile(
706
+ "whilelt p1.b, wzr, %w[vl_mul3] \n"
707
+ "ld1b {z31.b}, p1/z, [%[indices]] \n"
708
+ "subs %w[width], %w[width], %w[vl], lsl #1 \n"
709
+ "b.lt 2f \n"
710
+
711
+ // Run bulk of computation with the same predicates to avoid predicate
712
+ // generation overhead. We set up p1 to only store 3/4 of a vector.
713
+ "ptrue p0.s \n"
714
+ "1: \n"
715
+ "ld1w {z0.s}, p0/z, [%[src]] \n"
716
+ "ld1w {z1.s}, p0/z, [%[src], #1, mul vl] \n"
717
+ "incb %[src], all, mul #2 \n"
718
+ "tbl z0.b, {z0.b}, z31.b \n"
719
+ "tbl z1.b, {z1.b}, z31.b \n"
720
+ "subs %w[width], %w[width], %w[vl], lsl #1 \n"
721
+ "st1b {z0.b}, p1, [%[dst]] \n"
722
+ "add %[dst], %[dst], %x[vl_mul3] \n"
723
+ "st1b {z1.b}, p1, [%[dst]] \n"
724
+ "add %[dst], %[dst], %x[vl_mul3] \n"
725
+ "b.ge 1b \n"
726
+
727
+ "2: \n"
728
+ "adds %w[width], %w[width], %w[vl], lsl #1 \n"
729
+ "b.eq 99f \n"
730
+
731
+ // Calculate predicates for the final iteration to deal with the tail.
732
+ "add %w[rem_mul3], %w[width], %w[width], lsl #1 \n"
733
+ "whilelt p0.s, wzr, %w[width] \n"
734
+ "whilelt p1.b, wzr, %w[rem_mul3] \n"
735
+ "whilelt p2.s, %w[vl], %w[width] \n"
736
+ "whilelt p3.b, %w[vl_mul3], %w[rem_mul3] \n"
737
+ "ld1w {z0.s}, p0/z, [%[src]] \n"
738
+ "ld1w {z1.s}, p2/z, [%[src], #1, mul vl] \n"
739
+ "tbl z0.b, {z0.b}, z31.b \n"
740
+ "tbl z1.b, {z1.b}, z31.b \n"
741
+ "st1b {z0.b}, p1, [%[dst]] \n"
742
+ "add %[dst], %[dst], %x[vl_mul3] \n"
743
+ "st1b {z1.b}, p3, [%[dst]] \n"
744
+
745
+ "99: \n"
746
+ : [src] "+r"(src_argb), // %[src]
747
+ [dst] "+r"(dst_xyz), // %[dst]
748
+ [width] "+r"(width), // %[width]
749
+ [rem_mul3] "=&r"(rem_mul3) // %[rem_mul3]
750
+ : [indices] "r"(indices), // %[indices]
751
+ [vl_mul3] "r"(vl_mul3), // %[vl_mul3]
752
+ [vl] "r"(vl) // %[vl]
753
+ : "cc", "memory", "z0", "z1", "z31", "p0", "p1", "p2", "p3");
754
+ }
755
+
756
+ static const uint8_t kARGBToRGB24RowIndices[] = {
757
+ 0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18,
758
+ 20, 21, 22, 24, 25, 26, 28, 29, 30, 32, 33, 34, 36, 37, 38,
759
+ 40, 41, 42, 44, 45, 46, 48, 49, 50, 52, 53, 54, 56, 57, 58,
760
+ 60, 61, 62, 64, 65, 66, 68, 69, 70, 72, 73, 74, 76, 77, 78,
761
+ 80, 81, 82, 84, 85, 86, 88, 89, 90, 92, 93, 94, 96, 97, 98,
762
+ 100, 101, 102, 104, 105, 106, 108, 109, 110, 112, 113, 114, 116, 117, 118,
763
+ 120, 121, 122, 124, 125, 126, 128, 129, 130, 132, 133, 134, 136, 137, 138,
764
+ 140, 141, 142, 144, 145, 146, 148, 149, 150, 152, 153, 154, 156, 157, 158,
765
+ 160, 161, 162, 164, 165, 166, 168, 169, 170, 172, 173, 174, 176, 177, 178,
766
+ 180, 181, 182, 184, 185, 186, 188, 189, 190, 192, 193, 194, 196, 197, 198,
767
+ 200, 201, 202, 204, 205, 206, 208, 209, 210, 212, 213, 214, 216, 217, 218,
768
+ 220, 221, 222, 224, 225, 226, 228, 229, 230, 232, 233, 234, 236, 237, 238,
769
+ 240, 241, 242, 244, 245, 246, 248, 249, 250, 252, 253, 254,
770
+ };
771
+
772
+ static const uint8_t kARGBToRAWRowIndices[] = {
773
+ 2, 1, 0, 6, 5, 4, 10, 9, 8, 14, 13, 12, 18, 17, 16,
774
+ 22, 21, 20, 26, 25, 24, 30, 29, 28, 34, 33, 32, 38, 37, 36,
775
+ 42, 41, 40, 46, 45, 44, 50, 49, 48, 54, 53, 52, 58, 57, 56,
776
+ 62, 61, 60, 66, 65, 64, 70, 69, 68, 74, 73, 72, 78, 77, 76,
777
+ 82, 81, 80, 86, 85, 84, 90, 89, 88, 94, 93, 92, 98, 97, 96,
778
+ 102, 101, 100, 106, 105, 104, 110, 109, 108, 114, 113, 112, 118, 117, 116,
779
+ 122, 121, 120, 126, 125, 124, 130, 129, 128, 134, 133, 132, 138, 137, 136,
780
+ 142, 141, 140, 146, 145, 144, 150, 149, 148, 154, 153, 152, 158, 157, 156,
781
+ 162, 161, 160, 166, 165, 164, 170, 169, 168, 174, 173, 172, 178, 177, 176,
782
+ 182, 181, 180, 186, 185, 184, 190, 189, 188, 194, 193, 192, 198, 197, 196,
783
+ 202, 201, 200, 206, 205, 204, 210, 209, 208, 214, 213, 212, 218, 217, 216,
784
+ 222, 221, 220, 226, 225, 224, 230, 229, 228, 234, 233, 232, 238, 237, 236,
785
+ 242, 241, 240, 246, 245, 244, 250, 249, 248, 254, 253, 252,
786
+ };
787
+
788
+ void ARGBToRGB24Row_SVE2(const uint8_t* src_argb, uint8_t* dst_rgb, int width) {
789
+ ARGBToXYZRow_SVE2(src_argb, dst_rgb, width, kARGBToRGB24RowIndices);
790
+ }
791
+
792
+ void ARGBToRAWRow_SVE2(const uint8_t* src_argb, uint8_t* dst_rgb, int width) {
793
+ ARGBToXYZRow_SVE2(src_argb, dst_rgb, width, kARGBToRAWRowIndices);
794
+ }
795
+
796
+ void DivideRow_16_SVE2(const uint16_t* src_y,
797
+ uint16_t* dst_y,
798
+ int scale,
799
+ int width) {
800
+ uint64_t vl;
801
+ asm volatile(
802
+ "cnth %x[vl] \n"
803
+ "dup z0.h, %w[scale] \n"
804
+ "subs %w[width], %w[width], %w[vl], lsl #1 \n"
805
+ "b.le 2f \n"
806
+
807
+ // Run bulk of computation with the same predicates to avoid predicate
808
+ // generation overhead.
809
+ "ptrue p0.h \n"
810
+ "1: \n"
811
+ "ld1h {z1.h}, p0/z, [%[src]] \n"
812
+ "ld1h {z2.h}, p0/z, [%[src], #1, mul vl] \n"
813
+ "incb %[src], all, mul #2 \n"
814
+ "umulh z1.h, z1.h, z0.h \n"
815
+ "umulh z2.h, z2.h, z0.h \n"
816
+ "subs %w[width], %w[width], %w[vl], lsl #1 \n"
817
+ "st1h {z1.h}, p0, [%[dst]] \n"
818
+ "st1h {z2.h}, p0, [%[dst], #1, mul vl] \n"
819
+ "incb %[dst], all, mul #2 \n"
820
+ "b.gt 1b \n"
821
+
822
+ "2: \n"
823
+ "adds %w[width], %w[width], %w[vl], lsl #1 \n"
824
+ "b.eq 99f \n"
825
+
826
+ // Calculate a pair of predicates for the final iteration to deal with
827
+ // the tail.
828
+ "whilelt p0.h, wzr, %w[width] \n"
829
+ "whilelt p1.h, %w[vl], %w[width] \n"
830
+ "ld1h {z1.h}, p0/z, [%[src]] \n"
831
+ "ld1h {z2.h}, p1/z, [%[src], #1, mul vl] \n"
832
+ "umulh z1.h, z1.h, z0.h \n"
833
+ "umulh z2.h, z2.h, z0.h \n"
834
+ "st1h {z1.h}, p0, [%[dst]] \n"
835
+ "st1h {z2.h}, p1, [%[dst], #1, mul vl] \n"
836
+
837
+ "99: \n"
838
+ : [src] "+r"(src_y), // %[src]
839
+ [dst] "+r"(dst_y), // %[dst]
840
+ [width] "+r"(width), // %[width]
841
+ [vl] "=&r"(vl) // %[vl]
842
+ : [scale] "r"(scale) // %[scale]
843
+ : "cc", "memory", "z0", "z1", "z2", "p0", "p1");
844
+ }
845
+
846
+ #define HALFFLOAT_SVE \
847
+ "scvtf z0.s, p0/m, z0.s \n" \
848
+ "scvtf z1.s, p0/m, z1.s \n" \
849
+ "scvtf z2.s, p0/m, z2.s \n" \
850
+ "scvtf z3.s, p0/m, z3.s \n" \
851
+ "fmul z0.s, z0.s, z4.s \n" \
852
+ "fmul z1.s, z1.s, z4.s \n" \
853
+ "fmul z2.s, z2.s, z4.s \n" \
854
+ "fmul z3.s, z3.s, z4.s \n" \
855
+ "uqshrnb z0.h, z0.s, #13 \n" \
856
+ "uqshrnb z1.h, z1.s, #13 \n" \
857
+ "uqshrnb z2.h, z2.s, #13 \n" \
858
+ "uqshrnb z3.h, z3.s, #13 \n"
859
+
860
+ void HalfFloatRow_SVE2(const uint16_t* src,
861
+ uint16_t* dst,
862
+ float scale,
863
+ int width) {
864
+ uint64_t vl;
865
+ asm("cntw %x0" : "=r"(vl));
866
+ asm volatile(
867
+ "mov z4.s, %s[scale] \n"
868
+ "subs %w[width], %w[width], %w[vl], lsl #2 \n"
869
+ "b.lt 2f \n"
870
+
871
+ // Run bulk of computation with all-true predicates to avoid predicate
872
+ // generation overhead.
873
+ "ptrue p0.s \n"
874
+ "1: \n"
875
+ "ld1h {z0.s}, p0/z, [%[src]] \n"
876
+ "ld1h {z1.s}, p0/z, [%[src], #1, mul vl] \n"
877
+ "ld1h {z2.s}, p0/z, [%[src], #2, mul vl] \n"
878
+ "ld1h {z3.s}, p0/z, [%[src], #3, mul vl] \n"
879
+ "incb %[src], all, mul #2 \n" //
880
+ HALFFLOAT_SVE
881
+ "subs %w[width], %w[width], %w[vl], lsl #2 \n"
882
+ "st1h {z0.s}, p0, [%[dst]] \n"
883
+ "st1h {z1.s}, p0, [%[dst], #1, mul vl] \n"
884
+ "st1h {z2.s}, p0, [%[dst], #2, mul vl] \n"
885
+ "st1h {z3.s}, p0, [%[dst], #3, mul vl] \n"
886
+ "incb %[dst], all, mul #2 \n"
887
+ "b.ge 1b \n"
888
+
889
+ "2: \n"
890
+ "adds %w[width], %w[width], %w[vl], lsl #2 \n"
891
+ "b.eq 99f \n"
892
+
893
+ // Calculate predicates for the final iteration to deal with the tail.
894
+ "whilelt p0.s, wzr, %w[width] \n"
895
+ "whilelt p1.s, %w[vl], %w[width] \n"
896
+ "whilelt p2.s, %w[vl2], %w[width] \n"
897
+ "whilelt p3.s, %w[vl3], %w[width] \n"
898
+ "ld1h {z0.s}, p0/z, [%[src]] \n"
899
+ "ld1h {z1.s}, p1/z, [%[src], #1, mul vl] \n"
900
+ "ld1h {z2.s}, p2/z, [%[src], #2, mul vl] \n"
901
+ "ld1h {z3.s}, p3/z, [%[src], #3, mul vl] \n" //
902
+ HALFFLOAT_SVE
903
+ "st1h {z0.s}, p0, [%[dst]] \n"
904
+ "st1h {z1.s}, p1, [%[dst], #1, mul vl] \n"
905
+ "st1h {z2.s}, p2, [%[dst], #2, mul vl] \n"
906
+ "st1h {z3.s}, p3, [%[dst], #3, mul vl] \n"
907
+
908
+ "99: \n"
909
+ : [src] "+r"(src), // %[src]
910
+ [dst] "+r"(dst), // %[dst]
911
+ [width] "+r"(width) // %[width]
912
+ : [vl] "r"(vl), // %[vl]
913
+ [vl2] "r"(vl * 2), // %[vl2]
914
+ [vl3] "r"(vl * 3), // %[vl3]
915
+ [scale] "w"(scale * 1.9259299444e-34f) // %[scale]
916
+ : "cc", "memory", "z0", "z1", "z2", "z3", "z4", "p0", "p1", "p2", "p3");
917
+ }
918
+
919
+ void HalfFloat1Row_SVE2(const uint16_t* src,
920
+ uint16_t* dst,
921
+ float scale,
922
+ int width) {
923
+ uint64_t vl;
924
+ asm volatile(
925
+ "cnth %x[vl] \n"
926
+ "subs %w[width], %w[width], %w[vl], lsl #1 \n"
927
+ "b.lt 2f \n"
928
+
929
+ // Run bulk of computation with all-true predicates to avoid predicate
930
+ // generation overhead.
931
+ "ptrue p0.h \n"
932
+ "1: \n"
933
+ "ld1h {z0.h}, p0/z, [%[src]] \n"
934
+ "ld1h {z1.h}, p0/z, [%[src], #1, mul vl] \n"
935
+ "incb %[src], all, mul #2 \n"
936
+ "ucvtf z0.h, p0/m, z0.h \n"
937
+ "ucvtf z1.h, p0/m, z1.h \n"
938
+ "subs %w[width], %w[width], %w[vl], lsl #1 \n"
939
+ "st1h {z0.h}, p0, [%[dst]] \n"
940
+ "st1h {z1.h}, p0, [%[dst], #1, mul vl] \n"
941
+ "incb %[dst], all, mul #2 \n"
942
+ "b.ge 1b \n"
943
+
944
+ "2: \n"
945
+ "adds %w[width], %w[width], %w[vl], lsl #1 \n"
946
+ "b.eq 99f \n"
947
+
948
+ // Calculate predicates for the final iteration to deal with the tail.
949
+ "whilelt p0.h, wzr, %w[width] \n"
950
+ "whilelt p1.h, %w[vl], %w[width] \n"
951
+ "ld1h {z0.h}, p0/z, [%[src]] \n"
952
+ "ld1h {z1.h}, p1/z, [%[src], #1, mul vl] \n"
953
+ "ucvtf z0.h, p0/m, z0.h \n"
954
+ "ucvtf z1.h, p0/m, z1.h \n"
955
+ "st1h {z0.h}, p0, [%[dst]] \n"
956
+ "st1h {z1.h}, p1, [%[dst], #1, mul vl] \n"
957
+
958
+ "99: \n"
959
+ : [src] "+r"(src), // %[src]
960
+ [dst] "+r"(dst), // %[dst]
961
+ [width] "+r"(width), // %[width]
962
+ [vl] "=&r"(vl) // %[vl]
963
+ :
964
+ : "cc", "memory", "z0", "z1", "p0", "p1");
965
+ }
966
+
967
+ void I210ToARGBRow_SVE2(const uint16_t* src_y,
968
+ const uint16_t* src_u,
969
+ const uint16_t* src_v,
970
+ uint8_t* dst_argb,
971
+ const struct YuvConstants* yuvconstants,
972
+ int width) {
973
+ I210ToARGBRow_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
974
+ }
975
+
976
+ void I210AlphaToARGBRow_SVE2(const uint16_t* src_y,
977
+ const uint16_t* src_u,
978
+ const uint16_t* src_v,
979
+ const uint16_t* src_a,
980
+ uint8_t* dst_argb,
981
+ const struct YuvConstants* yuvconstants,
982
+ int width) {
983
+ I210AlphaToARGBRow_SVE_SC(src_y, src_u, src_v, src_a, dst_argb, yuvconstants,
984
+ width);
985
+ }
986
+
987
+ void I210ToAR30Row_SVE2(const uint16_t* src_y,
988
+ const uint16_t* src_u,
989
+ const uint16_t* src_v,
990
+ uint8_t* dst_ar30,
991
+ const struct YuvConstants* yuvconstants,
992
+ int width) {
993
+ I210ToAR30Row_SVE_SC(src_y, src_u, src_v, dst_ar30, yuvconstants, width);
994
+ }
995
+
996
+ void P210ToARGBRow_SVE2(const uint16_t* src_y,
997
+ const uint16_t* src_uv,
998
+ uint8_t* dst_argb,
999
+ const struct YuvConstants* yuvconstants,
1000
+ int width) {
1001
+ P210ToARGBRow_SVE_SC(src_y, src_uv, dst_argb, yuvconstants, width);
1002
+ }
1003
+
1004
+ void P210ToAR30Row_SVE2(const uint16_t* src_y,
1005
+ const uint16_t* src_uv,
1006
+ uint8_t* dst_ar30,
1007
+ const struct YuvConstants* yuvconstants,
1008
+ int width) {
1009
+ P210ToAR30Row_SVE_SC(src_y, src_uv, dst_ar30, yuvconstants, width);
1010
+ }
1011
+
1012
+ void I410ToARGBRow_SVE2(const uint16_t* src_y,
1013
+ const uint16_t* src_u,
1014
+ const uint16_t* src_v,
1015
+ uint8_t* dst_argb,
1016
+ const struct YuvConstants* yuvconstants,
1017
+ int width) {
1018
+ I410ToARGBRow_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
1019
+ }
1020
+
1021
+ void I410AlphaToARGBRow_SVE2(const uint16_t* src_y,
1022
+ const uint16_t* src_u,
1023
+ const uint16_t* src_v,
1024
+ const uint16_t* src_a,
1025
+ uint8_t* dst_argb,
1026
+ const struct YuvConstants* yuvconstants,
1027
+ int width) {
1028
+ I410AlphaToARGBRow_SVE_SC(src_y, src_u, src_v, src_a, dst_argb, yuvconstants,
1029
+ width);
1030
+ }
1031
+
1032
+ void I410ToAR30Row_SVE2(const uint16_t* src_y,
1033
+ const uint16_t* src_u,
1034
+ const uint16_t* src_v,
1035
+ uint8_t* dst_ar30,
1036
+ const struct YuvConstants* yuvconstants,
1037
+ int width) {
1038
+ I410ToAR30Row_SVE_SC(src_y, src_u, src_v, dst_ar30, yuvconstants, width);
1039
+ }
1040
+
1041
+ void P410ToARGBRow_SVE2(const uint16_t* src_y,
1042
+ const uint16_t* src_uv,
1043
+ uint8_t* dst_argb,
1044
+ const struct YuvConstants* yuvconstants,
1045
+ int width) {
1046
+ P410ToARGBRow_SVE_SC(src_y, src_uv, dst_argb, yuvconstants, width);
1047
+ }
1048
+
1049
+ void P410ToAR30Row_SVE2(const uint16_t* src_y,
1050
+ const uint16_t* src_uv,
1051
+ uint8_t* dst_ar30,
1052
+ const struct YuvConstants* yuvconstants,
1053
+ int width) {
1054
+ P410ToAR30Row_SVE_SC(src_y, src_uv, dst_ar30, yuvconstants, width);
1055
+ }
1056
+
1057
+ void I212ToAR30Row_SVE2(const uint16_t* src_y,
1058
+ const uint16_t* src_u,
1059
+ const uint16_t* src_v,
1060
+ uint8_t* dst_ar30,
1061
+ const struct YuvConstants* yuvconstants,
1062
+ int width) {
1063
+ I212ToAR30Row_SVE_SC(src_y, src_u, src_v, dst_ar30, yuvconstants, width);
1064
+ }
1065
+
1066
+ void I212ToARGBRow_SVE2(const uint16_t* src_y,
1067
+ const uint16_t* src_u,
1068
+ const uint16_t* src_v,
1069
+ uint8_t* dst_argb,
1070
+ const struct YuvConstants* yuvconstants,
1071
+ int width) {
1072
+ I212ToARGBRow_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
1073
+ }
1074
+
1075
+ void Convert8To8Row_SVE2(const uint8_t* src_y,
1076
+ uint8_t* dst_y,
1077
+ int scale,
1078
+ int bias,
1079
+ int width) {
1080
+ Convert8To8Row_SVE_SC(src_y, dst_y, scale, bias, width);
1081
+ }
1082
+
1083
+ #endif // !defined(LIBYUV_DISABLE_SVE) && defined(__aarch64__)
1084
+
1085
+ #ifdef __cplusplus
1086
+ } // extern "C"
1087
+ } // namespace libyuv
1088
+ #endif