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,1183 +1,1183 @@
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.h"
12
- #include "libyuv/row_sve.h"
13
-
14
- #ifdef __cplusplus
15
- namespace libyuv {
16
- extern "C" {
17
- #endif
18
-
19
- #if !defined(LIBYUV_DISABLE_SME) && defined(CLANG_HAS_SME) && \
20
- defined(__aarch64__)
21
-
22
- #define RGBTOARGB8_SVE_2X \
23
- /* Inputs: B: z16.h, G: z17.h, R: z18.h, A: z19.b */ \
24
- "uqshrnb z16.b, z16.h, #6 \n" /* B0 */ \
25
- "uqshrnb z17.b, z17.h, #6 \n" /* G0 */ \
26
- "uqshrnb z18.b, z18.h, #6 \n" /* R0 */ \
27
- "uqshrnt z16.b, z20.h, #6 \n" /* B1 */ \
28
- "uqshrnt z17.b, z21.h, #6 \n" /* G1 */ \
29
- "uqshrnt z18.b, z22.h, #6 \n" /* R1 */
30
-
31
- __arm_locally_streaming void I444ToARGBRow_SME(
32
- const uint8_t* src_y,
33
- const uint8_t* src_u,
34
- const uint8_t* src_v,
35
- uint8_t* dst_argb,
36
- const struct YuvConstants* yuvconstants,
37
- int width) {
38
- // Streaming-SVE only, no use of ZA tile.
39
- uint64_t vl;
40
- asm volatile(
41
- "cntb %[vl] \n"
42
- "ptrue p0.b \n" //
43
- YUVTORGB_SVE_SETUP
44
- "dup z19.b, #255 \n" // A
45
- "subs %w[width], %w[width], %w[vl] \n"
46
- "b.lt 2f \n"
47
-
48
- // Run bulk of computation with an all-true predicate to avoid predicate
49
- // generation overhead.
50
- "ptrue p1.b \n"
51
- "1: \n" //
52
- READYUV444_SVE_2X I444TORGB_SVE_2X RGBTOARGB8_SVE_2X
53
- "subs %w[width], %w[width], %w[vl] \n"
54
- "st4b {z16.b, z17.b, z18.b, z19.b}, p1, [%[dst_argb]] \n"
55
- "incb %[dst_argb], all, mul #4 \n"
56
- "b.ge 1b \n"
57
-
58
- "2: \n"
59
- "adds %w[width], %w[width], %w[vl] \n"
60
- "b.eq 99f \n"
61
-
62
- // Calculate a predicate for the final iteration to deal with the tail.
63
- "whilelt p1.b, wzr, %w[width] \n" //
64
- READYUV444_SVE_2X I444TORGB_SVE_2X RGBTOARGB8_SVE_2X
65
- "st4b {z16.b, z17.b, z18.b, z19.b}, p1, [%[dst_argb]] \n"
66
-
67
- "99: \n"
68
- : [src_y] "+r"(src_y), // %[src_y]
69
- [src_u] "+r"(src_u), // %[src_u]
70
- [src_v] "+r"(src_v), // %[src_v]
71
- [dst_argb] "+r"(dst_argb), // %[dst_argb]
72
- [width] "+r"(width), // %[width]
73
- [vl] "=&r"(vl) // %[vl]
74
- : [kUVCoeff] "r"(&yuvconstants->kUVCoeff), // %[kUVCoeff]
75
- [kRGBCoeffBias] "r"(&yuvconstants->kRGBCoeffBias) // %[kRGBCoeffBias]
76
- : "cc", "memory", YUVTORGB_SVE_REGS);
77
- }
78
-
79
- __arm_locally_streaming void I444ToRGB24Row_SME(
80
- const uint8_t* src_y,
81
- const uint8_t* src_u,
82
- const uint8_t* src_v,
83
- uint8_t* dst_rgb24,
84
- const struct YuvConstants* yuvconstants,
85
- int width) {
86
- I444ToRGB24Row_SVE_SC(src_y, src_u, src_v, dst_rgb24, yuvconstants, width);
87
- }
88
-
89
- __arm_locally_streaming void I400ToARGBRow_SME(
90
- const uint8_t* src_y,
91
- uint8_t* dst_argb,
92
- const struct YuvConstants* yuvconstants,
93
- int width) {
94
- // Streaming-SVE only, no use of ZA tile.
95
- I400ToARGBRow_SVE_SC(src_y, dst_argb, yuvconstants, width);
96
- }
97
-
98
- __arm_locally_streaming void I422ToARGBRow_SME(
99
- const uint8_t* src_y,
100
- const uint8_t* src_u,
101
- const uint8_t* src_v,
102
- uint8_t* dst_argb,
103
- const struct YuvConstants* yuvconstants,
104
- int width) {
105
- // Streaming-SVE only, no use of ZA tile.
106
- I422ToARGBRow_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
107
- }
108
-
109
- __arm_locally_streaming void I422ToRGB24Row_SME(
110
- 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
- __arm_locally_streaming void I422ToRGB565Row_SME(
120
- const uint8_t* src_y,
121
- const uint8_t* src_u,
122
- const uint8_t* src_v,
123
- uint8_t* dst_rgb565,
124
- const struct YuvConstants* yuvconstants,
125
- int width) {
126
- I422ToRGB565Row_SVE_SC(src_y, src_u, src_v, dst_rgb565, yuvconstants, width);
127
- }
128
-
129
- __arm_locally_streaming void I422ToARGB1555Row_SME(
130
- const uint8_t* src_y,
131
- const uint8_t* src_u,
132
- const uint8_t* src_v,
133
- uint8_t* dst_argb1555,
134
- const struct YuvConstants* yuvconstants,
135
- int width) {
136
- I422ToARGB1555Row_SVE_SC(src_y, src_u, src_v, dst_argb1555, yuvconstants,
137
- width);
138
- }
139
-
140
- __arm_locally_streaming void I422ToARGB4444Row_SME(
141
- const uint8_t* src_y,
142
- const uint8_t* src_u,
143
- const uint8_t* src_v,
144
- uint8_t* dst_argb4444,
145
- const struct YuvConstants* yuvconstants,
146
- int width) {
147
- I422ToARGB4444Row_SVE_SC(src_y, src_u, src_v, dst_argb4444, yuvconstants,
148
- width);
149
- }
150
-
151
- __arm_locally_streaming void I422ToRGBARow_SME(
152
- const uint8_t* src_y,
153
- const uint8_t* src_u,
154
- const uint8_t* src_v,
155
- uint8_t* dst_argb,
156
- const struct YuvConstants* yuvconstants,
157
- int width) {
158
- I422ToRGBARow_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
159
- }
160
-
161
- __arm_locally_streaming void I422ToAR30Row_SME(
162
- const uint8_t* src_y,
163
- const uint8_t* src_u,
164
- const uint8_t* src_v,
165
- uint8_t* dst_argb,
166
- const struct YuvConstants* yuvconstants,
167
- int width) {
168
- I422ToAR30Row_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
169
- }
170
-
171
- __arm_locally_streaming void I422AlphaToARGBRow_SME(
172
- const uint8_t* src_y,
173
- const uint8_t* src_u,
174
- const uint8_t* src_v,
175
- const uint8_t* src_a,
176
- uint8_t* dst_argb,
177
- const struct YuvConstants* yuvconstants,
178
- int width) {
179
- I422AlphaToARGBRow_SVE_SC(src_y, src_u, src_v, src_a, dst_argb, yuvconstants,
180
- width);
181
- }
182
-
183
- __arm_locally_streaming void I444AlphaToARGBRow_SME(
184
- const uint8_t* src_y,
185
- const uint8_t* src_u,
186
- const uint8_t* src_v,
187
- const uint8_t* src_a,
188
- uint8_t* dst_argb,
189
- const struct YuvConstants* yuvconstants,
190
- int width) {
191
- I444AlphaToARGBRow_SVE_SC(src_y, src_u, src_v, src_a, dst_argb, yuvconstants,
192
- width);
193
- }
194
-
195
- __arm_locally_streaming void NV12ToARGBRow_SME(
196
- const uint8_t* src_y,
197
- const uint8_t* src_uv,
198
- uint8_t* dst_argb,
199
- const struct YuvConstants* yuvconstants,
200
- int width) {
201
- NV12ToARGBRow_SVE_SC(src_y, src_uv, dst_argb, yuvconstants, width);
202
- }
203
-
204
- __arm_locally_streaming void NV21ToARGBRow_SME(
205
- const uint8_t* src_y,
206
- const uint8_t* src_vu,
207
- uint8_t* dst_argb,
208
- const struct YuvConstants* yuvconstants,
209
- int width) {
210
- NV21ToARGBRow_SVE_SC(src_y, src_vu, dst_argb, yuvconstants, width);
211
- }
212
-
213
- __arm_locally_streaming void NV12ToRGB24Row_SME(
214
- const uint8_t* src_y,
215
- const uint8_t* src_uv,
216
- uint8_t* dst_rgb24,
217
- const struct YuvConstants* yuvconstants,
218
- int width) {
219
- NV12ToRGB24Row_SVE_SC(src_y, src_uv, dst_rgb24, yuvconstants, width);
220
- }
221
-
222
- __arm_locally_streaming void NV21ToRGB24Row_SME(
223
- const uint8_t* src_y,
224
- const uint8_t* src_vu,
225
- uint8_t* dst_rgb24,
226
- const struct YuvConstants* yuvconstants,
227
- int width) {
228
- NV21ToRGB24Row_SVE_SC(src_y, src_vu, dst_rgb24, yuvconstants, width);
229
- }
230
-
231
- __arm_locally_streaming void YUY2ToARGBRow_SME(
232
- const uint8_t* src_yuy2,
233
- uint8_t* dst_argb,
234
- const struct YuvConstants* yuvconstants,
235
- int width) {
236
- YUY2ToARGBRow_SVE_SC(src_yuy2, dst_argb, yuvconstants, width);
237
- }
238
-
239
- __arm_locally_streaming void UYVYToARGBRow_SME(
240
- const uint8_t* src_uyvy,
241
- uint8_t* dst_argb,
242
- const struct YuvConstants* yuvconstants,
243
- int width) {
244
- UYVYToARGBRow_SVE_SC(src_uyvy, dst_argb, yuvconstants, width);
245
- }
246
-
247
- __arm_locally_streaming void I210ToARGBRow_SME(
248
- const uint16_t* src_y,
249
- const uint16_t* src_u,
250
- const uint16_t* src_v,
251
- uint8_t* dst_argb,
252
- const struct YuvConstants* yuvconstants,
253
- int width) {
254
- I210ToARGBRow_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
255
- }
256
-
257
- __arm_locally_streaming void I210AlphaToARGBRow_SME(
258
- const uint16_t* src_y,
259
- const uint16_t* src_u,
260
- const uint16_t* src_v,
261
- const uint16_t* src_a,
262
- uint8_t* dst_argb,
263
- const struct YuvConstants* yuvconstants,
264
- int width) {
265
- I210AlphaToARGBRow_SVE_SC(src_y, src_u, src_v, src_a, dst_argb, yuvconstants,
266
- width);
267
- }
268
-
269
- __arm_locally_streaming void I210ToAR30Row_SME(
270
- const uint16_t* src_y,
271
- const uint16_t* src_u,
272
- const uint16_t* src_v,
273
- uint8_t* dst_ar30,
274
- const struct YuvConstants* yuvconstants,
275
- int width) {
276
- I210ToAR30Row_SVE_SC(src_y, src_u, src_v, dst_ar30, yuvconstants, width);
277
- }
278
-
279
- __arm_locally_streaming void P210ToARGBRow_SME(
280
- const uint16_t* src_y,
281
- const uint16_t* src_uv,
282
- uint8_t* dst_argb,
283
- const struct YuvConstants* yuvconstants,
284
- int width) {
285
- P210ToARGBRow_SVE_SC(src_y, src_uv, dst_argb, yuvconstants, width);
286
- }
287
-
288
- __arm_locally_streaming void P210ToAR30Row_SME(
289
- const uint16_t* src_y,
290
- const uint16_t* src_uv,
291
- uint8_t* dst_ar30,
292
- const struct YuvConstants* yuvconstants,
293
- int width) {
294
- P210ToAR30Row_SVE_SC(src_y, src_uv, dst_ar30, yuvconstants, width);
295
- }
296
-
297
- __arm_locally_streaming void I410ToARGBRow_SME(
298
- const uint16_t* src_y,
299
- const uint16_t* src_u,
300
- const uint16_t* src_v,
301
- uint8_t* dst_argb,
302
- const struct YuvConstants* yuvconstants,
303
- int width) {
304
- I410ToARGBRow_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
305
- }
306
-
307
- __arm_locally_streaming void I410AlphaToARGBRow_SME(
308
- const uint16_t* src_y,
309
- const uint16_t* src_u,
310
- const uint16_t* src_v,
311
- const uint16_t* src_a,
312
- uint8_t* dst_argb,
313
- const struct YuvConstants* yuvconstants,
314
- int width) {
315
- I410AlphaToARGBRow_SVE_SC(src_y, src_u, src_v, src_a, dst_argb, yuvconstants,
316
- width);
317
- }
318
-
319
- __arm_locally_streaming void I410ToAR30Row_SME(
320
- const uint16_t* src_y,
321
- const uint16_t* src_u,
322
- const uint16_t* src_v,
323
- uint8_t* dst_ar30,
324
- const struct YuvConstants* yuvconstants,
325
- int width) {
326
- I410ToAR30Row_SVE_SC(src_y, src_u, src_v, dst_ar30, yuvconstants, width);
327
- }
328
-
329
- __arm_locally_streaming void P410ToARGBRow_SME(
330
- const uint16_t* src_y,
331
- const uint16_t* src_uv,
332
- uint8_t* dst_argb,
333
- const struct YuvConstants* yuvconstants,
334
- int width) {
335
- P410ToARGBRow_SVE_SC(src_y, src_uv, dst_argb, yuvconstants, width);
336
- }
337
-
338
- __arm_locally_streaming void P410ToAR30Row_SME(
339
- const uint16_t* src_y,
340
- const uint16_t* src_uv,
341
- uint8_t* dst_ar30,
342
- const struct YuvConstants* yuvconstants,
343
- int width) {
344
- P410ToAR30Row_SVE_SC(src_y, src_uv, dst_ar30, yuvconstants, width);
345
- }
346
-
347
- __arm_locally_streaming void I212ToAR30Row_SME(
348
- const uint16_t* src_y,
349
- const uint16_t* src_u,
350
- const uint16_t* src_v,
351
- uint8_t* dst_ar30,
352
- const struct YuvConstants* yuvconstants,
353
- int width) {
354
- I212ToAR30Row_SVE_SC(src_y, src_u, src_v, dst_ar30, yuvconstants, width);
355
- }
356
-
357
- __arm_locally_streaming void I212ToARGBRow_SME(
358
- const uint16_t* src_y,
359
- const uint16_t* src_u,
360
- const uint16_t* src_v,
361
- uint8_t* dst_argb,
362
- const struct YuvConstants* yuvconstants,
363
- int width) {
364
- I212ToARGBRow_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
365
- }
366
-
367
- __arm_locally_streaming void MultiplyRow_16_SME(const uint16_t* src_y,
368
- uint16_t* dst_y,
369
- int scale,
370
- int width) {
371
- // Streaming-SVE only, no use of ZA tile.
372
- int vl;
373
- asm volatile(
374
- "cnth %x[vl] \n"
375
- "mov z0.h, %w[scale] \n"
376
- "subs %w[width], %w[width], %w[vl] \n"
377
- "b.lt 2f \n"
378
-
379
- // Run bulk of computation with an all-true predicate to avoid predicate
380
- // generation overhead.
381
- "ptrue p0.h \n"
382
- "1: \n"
383
- "ld1h {z1.h}, p0/z, [%[src_y]] \n"
384
- "incb %[src_y] \n"
385
- "mul z1.h, z0.h, z1.h \n"
386
- "subs %w[width], %w[width], %w[vl] \n"
387
- "st1h {z1.h}, p0, [%[dst_y]] \n"
388
- "incb %[dst_y] \n"
389
- "b.ge 1b \n"
390
-
391
- "2: \n"
392
- "adds %w[width], %w[width], %w[vl] \n"
393
- "b.eq 99f \n"
394
-
395
- // Calculate a predicate for the final iteration to deal with the tail.
396
- "whilelt p0.h, wzr, %w[width] \n"
397
- "ld1h {z1.h}, p0/z, [%[src_y]] \n"
398
- "mul z1.h, z0.h, z1.h \n"
399
- "st1h {z1.h}, p0, [%[dst_y]] \n"
400
-
401
- "99: \n"
402
- : [src_y] "+r"(src_y), // %[src_y]
403
- [dst_y] "+r"(dst_y), // %[dst_y]
404
- [width] "+r"(width), // %[width]
405
- [vl] "=&r"(vl) // %[vl]
406
- : [scale] "r"(scale) // %[scale]
407
- : "memory", "cc", "z0", "z1", "p0");
408
- }
409
-
410
- __arm_locally_streaming void ARGBMultiplyRow_SME(const uint8_t* src_argb,
411
- const uint8_t* src_argb1,
412
- uint8_t* dst_argb,
413
- int width) {
414
- // Streaming-SVE only, no use of ZA tile.
415
- width *= 4;
416
- int vl;
417
- asm volatile(
418
- "cntb %x[vl] \n"
419
- "subs %w[width], %w[width], %w[vl] \n"
420
- "b.lt 2f \n"
421
-
422
- // Run bulk of computation with an all-true predicate to avoid predicate
423
- // generation overhead.
424
- "ptrue p0.b \n"
425
- "1: \n"
426
- "ld1b {z0.b}, p0/z, [%[src_argb]] \n"
427
- "ld1b {z1.b}, p0/z, [%[src_argb1]] \n"
428
- "incb %[src_argb] \n"
429
- "incb %[src_argb1] \n"
430
- "umullb z2.h, z0.b, z1.b \n"
431
- "umullt z1.h, z0.b, z1.b \n"
432
- "rshrnb z0.b, z2.h, #8 \n"
433
- "rshrnt z0.b, z1.h, #8 \n"
434
- "subs %w[width], %w[width], %w[vl] \n"
435
- "st1b {z0.b}, p0, [%[dst_argb]] \n"
436
- "incb %[dst_argb] \n"
437
- "b.ge 1b \n"
438
-
439
- "2: \n"
440
- "adds %w[width], %w[width], %w[vl] \n"
441
- "b.eq 99f \n"
442
-
443
- // Calculate a predicate for the final iteration to deal with the tail.
444
- "whilelt p0.b, wzr, %w[width] \n"
445
- "ld1b {z0.b}, p0/z, [%[src_argb]] \n"
446
- "ld1b {z1.b}, p0/z, [%[src_argb1]] \n"
447
- "umullb z2.h, z0.b, z1.b \n"
448
- "umullt z1.h, z0.b, z1.b \n"
449
- "rshrnb z0.b, z2.h, #8 \n"
450
- "rshrnt z0.b, z1.h, #8 \n"
451
- "st1b {z0.b}, p0, [%[dst_argb]] \n"
452
-
453
- "99: \n"
454
- : [src_argb] "+r"(src_argb), // %[src_argb]
455
- [src_argb1] "+r"(src_argb1), // %[src_argb1]
456
- [dst_argb] "+r"(dst_argb), // %[dst_argb]
457
- [width] "+r"(width), // %[width]
458
- [vl] "=&r"(vl) // %[vl]
459
- :
460
- : "memory", "cc", "z0", "z1", "z2", "p0", "p1");
461
- }
462
-
463
- __arm_locally_streaming void MergeUVRow_SME(const uint8_t* src_u,
464
- const uint8_t* src_v,
465
- uint8_t* dst_uv,
466
- int width) {
467
- // Streaming-SVE only, no use of ZA tile.
468
- int vl;
469
- asm volatile(
470
- "cntb %x[vl] \n"
471
- "subs %w[width], %w[width], %w[vl] \n"
472
- "b.lt 2f \n"
473
-
474
- // Run bulk of computation with an all-true predicate to avoid predicate
475
- // generation overhead.
476
- "ptrue p0.b \n"
477
- "1: \n"
478
- "ld1b {z1.b}, p0/z, [%[src_u]] \n"
479
- "ld1b {z2.b}, p0/z, [%[src_v]] \n"
480
- "incb %[src_u] \n"
481
- "incb %[src_v] \n"
482
- "subs %w[width], %w[width], %w[vl] \n"
483
- "st2b {z1.b, z2.b}, p0, [%[dst_uv]] \n"
484
- "incb %[dst_uv], all, mul #2 \n"
485
- "b.ge 1b \n"
486
-
487
- "2: \n"
488
- "adds %w[width], %w[width], %w[vl] \n"
489
- "b.eq 99f \n"
490
-
491
- // Calculate a predicate for the final iteration to deal with the tail.
492
- "whilelt p0.b, wzr, %w[width] \n"
493
- "ld1b {z1.b}, p0/z, [%[src_u]] \n"
494
- "ld1b {z2.b}, p0/z, [%[src_v]] \n"
495
- "subs %w[width], %w[width], %w[vl] \n"
496
- "st2b {z1.b, z2.b}, p0, [%[dst_uv]] \n"
497
-
498
- "99: \n"
499
- : [src_u] "+r"(src_u), // %[src_u]
500
- [src_v] "+r"(src_v), // %[src_v]
501
- [dst_uv] "+r"(dst_uv), // %[dst_uv]
502
- [width] "+r"(width), // %[width]
503
- [vl] "=&r"(vl) // %[vl]
504
- :
505
- : "memory", "cc", "z0", "z1", "z2", "p0");
506
- }
507
-
508
- __arm_locally_streaming void MergeUVRow_16_SME(const uint16_t* src_u,
509
- const uint16_t* src_v,
510
- uint16_t* dst_uv,
511
- int depth,
512
- int width) {
513
- int shift = 16 - depth;
514
- // Streaming-SVE only, no use of ZA tile.
515
- int vl;
516
- asm volatile(
517
- "cnth %x[vl] \n"
518
- "mov z0.h, %w[shift] \n"
519
- "subs %w[width], %w[width], %w[vl] \n"
520
- "b.lt 2f \n"
521
-
522
- // Run bulk of computation with an all-true predicate to avoid predicate
523
- // generation overhead.
524
- "ptrue p0.h \n"
525
- "1: \n"
526
- "ld1h {z1.h}, p0/z, [%[src_u]] \n"
527
- "ld1h {z2.h}, p0/z, [%[src_v]] \n"
528
- "incb %[src_u] \n"
529
- "incb %[src_v] \n"
530
- "lsl z1.h, p0/m, z1.h, z0.h \n"
531
- "lsl z2.h, p0/m, z2.h, z0.h \n"
532
- "subs %w[width], %w[width], %w[vl] \n"
533
- "st2h {z1.h, z2.h}, p0, [%[dst_uv]] \n"
534
- "incb %[dst_uv], all, mul #2 \n"
535
- "b.ge 1b \n"
536
-
537
- "2: \n"
538
- "adds %w[width], %w[width], %w[vl] \n"
539
- "b.eq 99f \n"
540
-
541
- // Calculate a predicate for the final iteration to deal with the tail.
542
- "whilelt p0.h, wzr, %w[width] \n"
543
- "ld1h {z1.h}, p0/z, [%[src_u]] \n"
544
- "ld1h {z2.h}, p0/z, [%[src_v]] \n"
545
- "lsl z1.h, p0/m, z1.h, z0.h \n"
546
- "lsl z2.h, p0/m, z2.h, z0.h \n"
547
- "subs %w[width], %w[width], %w[vl] \n"
548
- "st2h {z1.h, z2.h}, p0, [%[dst_uv]] \n"
549
-
550
- "99: \n"
551
- : [src_u] "+r"(src_u), // %[src_u]
552
- [src_v] "+r"(src_v), // %[src_v]
553
- [dst_uv] "+r"(dst_uv), // %[dst_uv]
554
- [width] "+r"(width), // %[width]
555
- [vl] "=&r"(vl) // %[vl]
556
- : [shift] "r"(shift) // %[shift]
557
- : "memory", "cc", "z0", "z1", "z2", "p0");
558
- }
559
-
560
- // Use scale to convert lsb formats to msb, depending how many bits there are:
561
- // 32768 = 9 bits = shr 1
562
- // 16384 = 10 bits = shr 2
563
- // 4096 = 12 bits = shr 4
564
- // 256 = 16 bits = shr 8
565
- __arm_locally_streaming void Convert16To8Row_SME(const uint16_t* src_y,
566
- uint8_t* dst_y,
567
- int scale,
568
- int width) {
569
- // 15 - clz(scale), + 8 to shift result into the high half of the lane to
570
- // saturate, then we can just use UZP2 to narrow rather than a pair of
571
- // saturating narrow instructions.
572
- const int shift = 23 - __builtin_clz((int32_t)scale);
573
- int vl;
574
- asm volatile(
575
- "cntb %x[vl] \n"
576
- "dup z0.h, %w[shift] \n"
577
- "subs %w[width], %w[width], %w[vl] \n"
578
- "b.lt 2f \n"
579
-
580
- // Run bulk of computation with an all-true predicate to avoid predicate
581
- // generation overhead.
582
- "ptrue p0.b \n"
583
- "1: \n"
584
- "ld1h {z1.h}, p0/z, [%[src_y]] \n"
585
- "ld1h {z2.h}, p0/z, [%[src_y], #1, mul vl] \n"
586
- "incb %[src_y], all, mul #2 \n"
587
- "uqshl z1.h, p0/m, z1.h, z0.h \n"
588
- "uqshl z2.h, p0/m, z2.h, z0.h \n"
589
- "subs %w[width], %w[width], %w[vl] \n"
590
- "uzp2 z1.b, z1.b, z2.b \n"
591
- "st1b {z1.b}, p0, [%[dst_y]] \n"
592
- "incb %[dst_y] \n"
593
- "b.ge 1b \n"
594
-
595
- "2: \n"
596
- "adds %w[width], %w[width], %w[vl] \n"
597
- "b.eq 99f \n"
598
-
599
- // Calculate a predicate for the final iteration to deal with the tail.
600
- // We need separate predicates for the load and store instructions since
601
- // they are operating on different element sizes (.b vs .h).
602
- "cnth %x[vl] \n"
603
- "whilelt p0.h, wzr, %w[width] \n"
604
- "whilelt p1.h, %w[vl], %w[width] \n"
605
- "whilelt p2.b, wzr, %w[width] \n"
606
- "ld1h {z1.h}, p0/z, [%[src_y]] \n"
607
- "ld1h {z2.h}, p1/z, [%[src_y], #1, mul vl] \n"
608
- "uqshl z1.h, p0/m, z1.h, z0.h \n"
609
- "uqshl z2.h, p1/m, z2.h, z0.h \n"
610
- "uzp2 z1.b, z1.b, z2.b \n"
611
- "st1b {z1.b}, p2, [%[dst_y]] \n"
612
-
613
- "99: \n"
614
- : [src_y] "+r"(src_y), // %[src_y]
615
- [dst_y] "+r"(dst_y), // %[dst_y]
616
- [width] "+r"(width), // %[width]
617
- [vl] "=&r"(vl) // %[vl]
618
- : [shift] "r"(shift) // %[shift]
619
- : "cc", "memory", "z0", "z1", "z2", "p0", "p1", "p2");
620
- }
621
-
622
- __arm_locally_streaming void CopyRow_SME(const uint8_t* src,
623
- uint8_t* dst,
624
- int width) {
625
- // Streaming-SVE only, no use of ZA tile.
626
- int vl;
627
- asm volatile(
628
- "cntb %x[vl] \n"
629
- "subs %w[width], %w[width], %w[vl] \n"
630
- "b.lt 2f \n"
631
-
632
- // Run bulk of computation with an all-true predicate to avoid predicate
633
- // generation overhead.
634
- "ptrue p0.b \n"
635
- "1: \n"
636
- "ld1b {z0.b}, p0/z, [%[src]] \n"
637
- "incb %[src] \n"
638
- "subs %w[width], %w[width], %w[vl] \n"
639
- "st1b {z0.b}, p0, [%[dst]] \n"
640
- "incb %[dst] \n"
641
- "b.ge 1b \n"
642
-
643
- "2: \n"
644
- "adds %w[width], %w[width], %w[vl] \n"
645
- "b.eq 99f \n"
646
-
647
- // Calculate a predicate for the final iteration to deal with the tail.
648
- "whilelt p0.b, wzr, %w[width] \n"
649
- "ld1b {z0.b}, p0/z, [%[src]] \n"
650
- "st1b {z0.b}, p0, [%[dst]] \n"
651
-
652
- "99: \n"
653
- : [src] "+r"(src), // %[src]
654
- [dst] "+r"(dst), // %[dst]
655
- [width] "+r"(width), // %[width]
656
- [vl] "=&r"(vl) // %[vl]
657
- :
658
- : "memory", "cc", "z0", "p0");
659
- }
660
-
661
- __arm_locally_streaming static void HalfRow_SME(uint8_t* dst_ptr,
662
- const uint8_t* src_ptr,
663
- ptrdiff_t src_stride,
664
- int width) {
665
- const uint8_t* src_ptr1 = src_ptr + src_stride;
666
-
667
- int vl;
668
- asm volatile(
669
- "cntb %x[vl] \n"
670
- "subs %w[width], %w[width], %w[vl] \n"
671
- "b.lt 2f \n"
672
-
673
- // Run bulk of computation with an all-true predicate to avoid predicate
674
- // generation overhead.
675
- "ptrue p0.b \n"
676
- "1: \n"
677
- "ld1b {z2.b}, p0/z, [%[src_ptr]] \n"
678
- "ld1b {z3.b}, p0/z, [%[src_ptr1]] \n"
679
- "incb %[src_ptr] \n"
680
- "incb %[src_ptr1] \n"
681
- "urhadd z2.b, p0/m, z2.b, z3.b \n"
682
- "subs %w[width], %w[width], %w[vl] \n"
683
- "st1b {z2.b}, p0, [%[dst_ptr]] \n"
684
- "incb %[dst_ptr] \n"
685
- "b.ge 1b \n"
686
-
687
- "2: \n"
688
- "adds %w[width], %w[width], %w[vl] \n"
689
- "b.eq 99f \n"
690
-
691
- // Calculate a predicate for the final iteration to deal with the tail.
692
- "whilelt p0.b, wzr, %w[width] \n"
693
- "ld1b {z2.b}, p0/z, [%[src_ptr]] \n"
694
- "ld1b {z3.b}, p0/z, [%[src_ptr1]] \n"
695
- "urhadd z2.b, p0/m, z2.b, z3.b \n"
696
- "subs %w[width], %w[width], %w[vl] \n"
697
- "st1b {z2.b}, p0, [%[dst_ptr]] \n"
698
-
699
- "99: \n"
700
- : [src_ptr] "+r"(src_ptr), // %[src_ptr]
701
- [src_ptr1] "+r"(src_ptr1), // %[src_ptr1]
702
- [dst_ptr] "+r"(dst_ptr), // %[dst_ptr]
703
- [width] "+r"(width), // %[width]
704
- [vl] "=&r"(vl) // %[vl]
705
- :
706
- : "cc", "memory", "z0", "z1", "z2", "z3", "p0");
707
- }
708
-
709
- __arm_locally_streaming void InterpolateRow_SME(uint8_t* dst_ptr,
710
- const uint8_t* src_ptr,
711
- ptrdiff_t src_stride,
712
- int width,
713
- int source_y_fraction) {
714
- int y1_fraction = source_y_fraction;
715
- int y0_fraction = 256 - y1_fraction;
716
- const uint8_t* src_ptr1 = src_ptr + src_stride;
717
-
718
- if (y0_fraction == 0) {
719
- CopyRow_SME(src_ptr1, dst_ptr, width);
720
- return;
721
- }
722
- if (y0_fraction == 128) {
723
- HalfRow_SME(dst_ptr, src_ptr, src_stride, width);
724
- return;
725
- }
726
- if (y0_fraction == 256) {
727
- CopyRow_SME(src_ptr, dst_ptr, width);
728
- return;
729
- }
730
-
731
- int vl;
732
- asm volatile(
733
- "cntb %x[vl] \n"
734
- "dup z0.b, %w[y0_fraction] \n"
735
- "dup z1.b, %w[y1_fraction] \n"
736
- "subs %w[width], %w[width], %w[vl] \n"
737
- "b.lt 2f \n"
738
-
739
- // Run bulk of computation with an all-true predicate to avoid predicate
740
- // generation overhead.
741
- "ptrue p0.b \n"
742
- "1: \n"
743
- "ld1b {z2.b}, p0/z, [%[src_ptr]] \n"
744
- "ld1b {z3.b}, p0/z, [%[src_ptr1]] \n"
745
- "incb %[src_ptr] \n"
746
- "incb %[src_ptr1] \n"
747
- "umullb z4.h, z2.b, z0.b \n"
748
- "umullt z2.h, z2.b, z0.b \n"
749
- "subs %w[width], %w[width], %w[vl] \n"
750
- "umlalb z4.h, z3.b, z1.b \n"
751
- "umlalt z2.h, z3.b, z1.b \n"
752
- "rshrnb z3.b, z4.h, #8 \n"
753
- "rshrnt z3.b, z2.h, #8 \n"
754
- "st1b {z3.b}, p0, [%[dst_ptr]] \n"
755
- "incb %[dst_ptr] \n"
756
- "b.ge 1b \n"
757
-
758
- "2: \n"
759
- "adds %w[width], %w[width], %w[vl] \n"
760
- "b.eq 99f \n"
761
-
762
- // Calculate a predicate for the final iteration to deal with the tail.
763
- "whilelt p0.b, wzr, %w[width] \n"
764
- "ld1b {z2.b}, p0/z, [%[src_ptr]] \n"
765
- "ld1b {z3.b}, p0/z, [%[src_ptr1]] \n"
766
- "umullb z4.h, z2.b, z0.b \n"
767
- "umullt z2.h, z2.b, z0.b \n"
768
- "umlalb z4.h, z3.b, z1.b \n"
769
- "umlalt z2.h, z3.b, z1.b \n"
770
- "rshrnb z3.b, z4.h, #8 \n"
771
- "rshrnt z3.b, z2.h, #8 \n"
772
- "st1b {z3.b}, p0, [%[dst_ptr]] \n"
773
-
774
- "99: \n"
775
- : [src_ptr] "+r"(src_ptr), // %[src_ptr]
776
- [src_ptr1] "+r"(src_ptr1), // %[src_ptr1]
777
- [dst_ptr] "+r"(dst_ptr), // %[dst_ptr]
778
- [width] "+r"(width), // %[width]
779
- [vl] "=&r"(vl) // %[vl]
780
- : [y0_fraction] "r"(y0_fraction), // %[y0_fraction]
781
- [y1_fraction] "r"(y1_fraction) // %[y1_fraction]
782
- : "cc", "memory", "z0", "z1", "z2", "z3", "z4", "p0");
783
- }
784
-
785
- __arm_locally_streaming static void HalfRow_16_SME(uint16_t* dst_ptr,
786
- const uint16_t* src_ptr,
787
- ptrdiff_t src_stride,
788
- int width) {
789
- const uint16_t* src_ptr1 = src_ptr + src_stride;
790
-
791
- int vl;
792
- asm volatile(
793
- "cnth %x[vl] \n"
794
- "subs %w[width], %w[width], %w[vl] \n"
795
- "b.lt 2f \n"
796
-
797
- // Run bulk of computation with an all-true predicate to avoid predicate
798
- // generation overhead.
799
- "ptrue p0.h \n"
800
- "1: \n"
801
- "ld1h {z2.h}, p0/z, [%[src_ptr]] \n"
802
- "ld1h {z3.h}, p0/z, [%[src_ptr1]] \n"
803
- "incb %[src_ptr] \n"
804
- "incb %[src_ptr1] \n"
805
- "urhadd z2.h, p0/m, z2.h, z3.h \n"
806
- "subs %w[width], %w[width], %w[vl] \n"
807
- "st1h {z2.h}, p0, [%[dst_ptr]] \n"
808
- "incb %[dst_ptr] \n"
809
- "b.ge 1b \n"
810
-
811
- "2: \n"
812
- "adds %w[width], %w[width], %w[vl] \n"
813
- "b.eq 99f \n"
814
-
815
- // Calculate a predicate for the final iteration to deal with the tail.
816
- "whilelt p0.h, wzr, %w[width] \n"
817
- "ld1h {z2.h}, p0/z, [%[src_ptr]] \n"
818
- "ld1h {z3.h}, p0/z, [%[src_ptr1]] \n"
819
- "urhadd z2.h, p0/m, z2.h, z3.h \n"
820
- "st1h {z2.h}, p0, [%[dst_ptr]] \n"
821
-
822
- "99: \n"
823
- : [src_ptr] "+r"(src_ptr), // %[src_ptr]
824
- [src_ptr1] "+r"(src_ptr1), // %[src_ptr1]
825
- [dst_ptr] "+r"(dst_ptr), // %[dst_ptr]
826
- [width] "+r"(width), // %[width]
827
- [vl] "=&r"(vl) // %[vl]
828
- :
829
- : "cc", "memory", "z0", "z1", "z2", "z3", "p0");
830
- }
831
-
832
- __arm_locally_streaming void InterpolateRow_16_SME(uint16_t* dst_ptr,
833
- const uint16_t* src_ptr,
834
- ptrdiff_t src_stride,
835
- int width,
836
- int source_y_fraction) {
837
- int y1_fraction = source_y_fraction;
838
- int y0_fraction = 256 - y1_fraction;
839
- const uint16_t* src_ptr1 = src_ptr + src_stride;
840
-
841
- if (y0_fraction == 0) {
842
- CopyRow_SME((const uint8_t*)src_ptr1, (uint8_t*)dst_ptr,
843
- width * sizeof(uint16_t));
844
- return;
845
- }
846
- if (y0_fraction == 128) {
847
- HalfRow_16_SME(dst_ptr, src_ptr, src_stride, width);
848
- return;
849
- }
850
- if (y0_fraction == 256) {
851
- CopyRow_SME((const uint8_t*)src_ptr, (uint8_t*)dst_ptr,
852
- width * sizeof(uint16_t));
853
- return;
854
- }
855
-
856
- int vl;
857
- asm volatile(
858
- "cnth %x[vl] \n"
859
- "subs %w[width], %w[width], %w[vl] \n"
860
- "dup z0.h, %w[y0_fraction] \n"
861
- "dup z1.h, %w[y1_fraction] \n"
862
- "b.lt 2f \n"
863
-
864
- // Run bulk of computation with an all-true predicate to avoid predicate
865
- // generation overhead.
866
- "ptrue p0.h \n"
867
- "1: \n"
868
- "ld1h {z2.h}, p0/z, [%[src_ptr]] \n"
869
- "ld1h {z3.h}, p0/z, [%[src_ptr1]] \n"
870
- "incb %[src_ptr] \n"
871
- "incb %[src_ptr1] \n"
872
- "umullb z4.s, z2.h, z0.h \n"
873
- "umullt z2.s, z2.h, z0.h \n"
874
- "subs %w[width], %w[width], %w[vl] \n"
875
- "umlalb z4.s, z3.h, z1.h \n"
876
- "umlalt z2.s, z3.h, z1.h \n"
877
- "rshrnb z3.h, z4.s, #8 \n"
878
- "rshrnt z3.h, z2.s, #8 \n"
879
- "st1h {z3.h}, p0, [%[dst_ptr]] \n"
880
- "incb %[dst_ptr] \n"
881
- "b.ge 1b \n"
882
-
883
- "2: \n"
884
- "adds %w[width], %w[width], %w[vl] \n"
885
- "b.eq 99f \n"
886
-
887
- // Calculate a predicate for the final iteration to deal with the tail.
888
- "whilelt p0.h, wzr, %w[width] \n"
889
- "ld1h {z2.h}, p0/z, [%[src_ptr]] \n"
890
- "ld1h {z3.h}, p0/z, [%[src_ptr1]] \n"
891
- "umullb z4.s, z2.h, z0.h \n"
892
- "umullt z2.s, z2.h, z0.h \n"
893
- "umlalb z4.s, z3.h, z1.h \n"
894
- "umlalt z2.s, z3.h, z1.h \n"
895
- "rshrnb z3.h, z4.s, #8 \n"
896
- "rshrnt z3.h, z2.s, #8 \n"
897
- "st1h {z3.h}, p0, [%[dst_ptr]] \n"
898
-
899
- "99: \n"
900
- : [src_ptr] "+r"(src_ptr), // %[src_ptr]
901
- [src_ptr1] "+r"(src_ptr1), // %[src_ptr1]
902
- [dst_ptr] "+r"(dst_ptr), // %[dst_ptr]
903
- [width] "+r"(width), // %[width]
904
- [vl] "=&r"(vl) // %[vl]
905
- : [y0_fraction] "r"(y0_fraction), // %[y0_fraction]
906
- [y1_fraction] "r"(y1_fraction) // %[y1_fraction]
907
- : "cc", "memory", "z0", "z1", "z2", "z3", "z4", "p0");
908
- }
909
-
910
- __arm_locally_streaming static void HalfRow_16To8_SME(uint8_t* dst_ptr,
911
- const uint16_t* src_ptr,
912
- ptrdiff_t src_stride,
913
- int scale,
914
- int width) {
915
- const uint16_t* src_ptr1 = src_ptr + src_stride;
916
-
917
- // 15 - clz(scale), + 8 to shift result into the high half of the lane to
918
- // saturate, then we can just use UZP2 to narrow rather than a pair of
919
- // saturating narrow instructions.
920
- const int shift = 23 - __builtin_clz((int32_t)scale);
921
-
922
- int vl;
923
- asm volatile(
924
- "cnth %x[vl] \n"
925
- "dup z31.h, %w[shift] \n"
926
- "subs %w[width], %w[width], %w[vl] \n"
927
- "b.lt 2f \n"
928
-
929
- // Run bulk of computation with an all-true predicate to avoid predicate
930
- // generation overhead.
931
- "ptrue p0.h \n"
932
- "1: \n"
933
- "ld1h {z2.h}, p0/z, [%[src_ptr]] \n"
934
- "ld1h {z3.h}, p0/z, [%[src_ptr1]] \n"
935
- "incb %[src_ptr] \n"
936
- "incb %[src_ptr1] \n"
937
- "urhadd z2.h, p0/m, z2.h, z3.h \n"
938
- "subs %w[width], %w[width], %w[vl] \n"
939
- "uqshl z2.h, p0/m, z2.h, z31.h \n"
940
- "shrnb z2.b, z2.h, #8 \n"
941
- "st1b {z2.h}, p0, [%[dst_ptr]] \n"
942
- "inch %[dst_ptr] \n"
943
- "b.ge 1b \n"
944
-
945
- "2: \n"
946
- "adds %w[width], %w[width], %w[vl] \n"
947
- "b.eq 99f \n"
948
-
949
- // Calculate a predicate for the final iteration to deal with the tail.
950
- "whilelt p0.h, wzr, %w[width] \n"
951
- "ld1h {z2.h}, p0/z, [%[src_ptr]] \n"
952
- "ld1h {z3.h}, p0/z, [%[src_ptr1]] \n"
953
- "urhadd z2.h, p0/m, z2.h, z3.h \n"
954
- "uqshl z2.h, p0/m, z2.h, z31.h \n"
955
- "shrnb z2.b, z2.h, #8 \n"
956
- "st1b {z2.h}, p0, [%[dst_ptr]] \n"
957
-
958
- "99: \n"
959
- : [src_ptr] "+r"(src_ptr), // %[src_ptr]
960
- [src_ptr1] "+r"(src_ptr1), // %[src_ptr1]
961
- [dst_ptr] "+r"(dst_ptr), // %[dst_ptr]
962
- [width] "+r"(width), // %[width]
963
- [vl] "=&r"(vl) // %[vl]
964
- : [shift] "r"(shift) // %[shift]
965
- : "cc", "memory", "z0", "z1", "z2", "z3", "z31", "p0");
966
- }
967
-
968
- // Use scale to convert lsb formats to msb, depending how many bits there are:
969
- // 32768 = 9 bits
970
- // 16384 = 10 bits
971
- // 4096 = 12 bits
972
- // 256 = 16 bits
973
- // TODO(fbarchard): change scale to bits
974
- __arm_locally_streaming void InterpolateRow_16To8_SME(uint8_t* dst_ptr,
975
- const uint16_t* src_ptr,
976
- ptrdiff_t src_stride,
977
- int scale,
978
- int width,
979
- int source_y_fraction) {
980
- const int y1_fraction = source_y_fraction;
981
- const int y0_fraction = 256 - y1_fraction;
982
- const uint16_t* src_ptr1 = src_ptr + src_stride;
983
-
984
- // y0_fraction == 0 is never called here.
985
- if (y0_fraction == 128) {
986
- HalfRow_16To8_SME(dst_ptr, src_ptr, src_stride, scale, width);
987
- return;
988
- }
989
- if (y0_fraction == 256) {
990
- Convert16To8Row_SME(src_ptr, dst_ptr, scale, width);
991
- return;
992
- }
993
-
994
- // 15 - clz(scale), + 8 to shift result into the high half of the lane to
995
- // saturate, then we can just use UZP2 to narrow rather than a pair of
996
- // saturating narrow instructions.
997
- const int shift = 23 - __builtin_clz((int32_t)scale);
998
-
999
- int vl;
1000
- asm volatile(
1001
- "cnth %x[vl] \n"
1002
- "dup z31.h, %w[shift] \n"
1003
- "dup z0.h, %w[y0_fraction] \n"
1004
- "dup z1.h, %w[y1_fraction] \n"
1005
- "subs %w[width], %w[width], %w[vl] \n"
1006
- "b.lt 2f \n"
1007
-
1008
- // Run bulk of computation with an all-true predicate to avoid predicate
1009
- // generation overhead.
1010
- "ptrue p0.h \n"
1011
- "1: \n"
1012
- "ld1h {z2.h}, p0/z, [%[src_ptr]] \n"
1013
- "ld1h {z3.h}, p0/z, [%[src_ptr1]] \n"
1014
- "incb %[src_ptr] \n"
1015
- "incb %[src_ptr1] \n"
1016
- "umullb z4.s, z2.h, z0.h \n"
1017
- "umullt z2.s, z2.h, z0.h \n"
1018
- "subs %w[width], %w[width], %w[vl] \n"
1019
- "umlalb z4.s, z3.h, z1.h \n"
1020
- "umlalt z2.s, z3.h, z1.h \n"
1021
- "rshrnb z3.h, z4.s, #8 \n"
1022
- "rshrnt z3.h, z2.s, #8 \n"
1023
- "uqshl z3.h, p0/m, z3.h, z31.h \n"
1024
- "shrnb z3.b, z3.h, #8 \n"
1025
- "st1b {z3.h}, p0, [%[dst_ptr]] \n"
1026
- "inch %[dst_ptr] \n"
1027
- "b.ge 1b \n"
1028
-
1029
- "2: \n"
1030
- "adds %w[width], %w[width], %w[vl] \n"
1031
- "b.eq 99f \n"
1032
-
1033
- // Calculate a predicate for the final iteration to deal with the tail.
1034
- "whilelt p0.h, wzr, %w[width] \n"
1035
- "ld1h {z2.h}, p0/z, [%[src_ptr]] \n"
1036
- "ld1h {z3.h}, p0/z, [%[src_ptr1]] \n"
1037
- "umullb z4.s, z2.h, z0.h \n"
1038
- "umullt z2.s, z2.h, z0.h \n"
1039
- "umlalb z4.s, z3.h, z1.h \n"
1040
- "umlalt z2.s, z3.h, z1.h \n"
1041
- "rshrnb z3.h, z4.s, #8 \n"
1042
- "rshrnt z3.h, z2.s, #8 \n"
1043
- "uqshl z3.h, p0/m, z3.h, z31.h \n"
1044
- "shrnb z3.b, z3.h, #8 \n"
1045
- "st1b {z3.h}, p0, [%[dst_ptr]] \n"
1046
-
1047
- "99: \n"
1048
- : [src_ptr] "+r"(src_ptr), // %[src_ptr]
1049
- [src_ptr1] "+r"(src_ptr1), // %[src_ptr1]
1050
- [dst_ptr] "+r"(dst_ptr), // %[dst_ptr]
1051
- [width] "+r"(width), // %[width]
1052
- [vl] "=&r"(vl) // %[vl]
1053
- : [y0_fraction] "r"(y0_fraction), // %[y0_fraction]
1054
- [y1_fraction] "r"(y1_fraction), // %[y1_fraction]
1055
- [shift] "r"(shift) // %[shift]
1056
- : "cc", "memory", "z0", "z1", "z2", "z3", "z4", "z31", "p0");
1057
- }
1058
-
1059
- __arm_locally_streaming void Convert8To8Row_SME(const uint8_t* src_y,
1060
- uint8_t* dst_y,
1061
- int scale,
1062
- int bias,
1063
- int width) {
1064
- Convert8To8Row_SVE_SC(src_y, dst_y, scale, bias, width);
1065
- }
1066
-
1067
- #define CONVERT8TO16_SVE \
1068
- "ld1b {z0.h}, p0/z, [%[src]] \n" \
1069
- "ld1b {z1.h}, p1/z, [%[src], #1, mul vl] \n" \
1070
- "incb %[src] \n" \
1071
- "subs %w[width], %w[width], %w[vl], lsl #1 \n" \
1072
- "trn1 z0.b, z0.b, z0.b \n" \
1073
- "trn1 z1.b, z1.b, z1.b \n" \
1074
- "lsr z0.h, p0/m, z0.h, z2.h \n" \
1075
- "lsr z1.h, p1/m, z1.h, z2.h \n" \
1076
- "prfm pldl1keep, [%[src], 448] \n" \
1077
- "st1h {z0.h}, p0, [%[dst]] \n" \
1078
- "st1h {z1.h}, p1, [%[dst], #1, mul vl] \n" \
1079
- "incb %[dst], all, mul #2 \n"
1080
-
1081
- __arm_locally_streaming void Convert8To16Row_SME(const uint8_t* src_y,
1082
- uint16_t* dst_y,
1083
- int scale,
1084
- int width) {
1085
- // (src * 0x0101 * scale) >> 16.
1086
- // Since scale is a power of two, compute the shift to use to avoid needing
1087
- // to widen to int32.
1088
- const int shift = __builtin_clz(scale) - 15;
1089
-
1090
- uint64_t vl;
1091
- asm volatile(
1092
- "dup z2.h, %w[shift] \n"
1093
- "cnth %[vl] \n"
1094
- "subs %w[width], %w[width], %w[vl], lsl #1 \n"
1095
- "b.lt 2f \n"
1096
-
1097
- // Run bulk of computation with all-true predicates to avoid predicate
1098
- // generation overhead.
1099
- "ptrue p0.h \n"
1100
- "ptrue p1.h \n"
1101
- "1: \n" //
1102
- CONVERT8TO16_SVE
1103
- "b.ge 1b \n"
1104
-
1105
- "2: \n"
1106
- "adds %w[width], %w[width], %w[vl], lsl #1 \n"
1107
- "b.eq 99f \n"
1108
-
1109
- // Calculate predicates for the final iteration to deal with the tail.
1110
- "whilelt p0.h, wzr, %w[width] \n"
1111
- "whilelt p1.h, %w[vl], %w[width] \n" //
1112
- CONVERT8TO16_SVE
1113
-
1114
- "99: \n"
1115
- : [src] "+r"(src_y), // %[src]
1116
- [dst] "+r"(dst_y), // %[dst]
1117
- [width] "+r"(width), // %[width]
1118
- [vl] "=&r"(vl) // %[vl]
1119
- : [shift] "r"(shift) // %[shift]
1120
- : "cc", "memory", "z0", "z1", "z2", "p0", "p1");
1121
- }
1122
-
1123
- __arm_locally_streaming void ARGBToUVRow_SME(const uint8_t* src_argb,
1124
- int src_stride_argb,
1125
- uint8_t* dst_u,
1126
- uint8_t* dst_v,
1127
- int width) {
1128
- ARGBToUVMatrixRow_SVE_SC(src_argb, src_stride_argb, dst_u, dst_v, width,
1129
- kARGBToUVCoefficients);
1130
- }
1131
-
1132
- __arm_locally_streaming void ARGBToUVJRow_SME(const uint8_t* src_argb,
1133
- int src_stride_argb,
1134
- uint8_t* dst_u,
1135
- uint8_t* dst_v,
1136
- int width) {
1137
- ARGBToUVMatrixRow_SVE_SC(src_argb, src_stride_argb, dst_u, dst_v, width,
1138
- kARGBToUVJCoefficients);
1139
- }
1140
-
1141
- __arm_locally_streaming void ABGRToUVJRow_SME(const uint8_t* src_abgr,
1142
- int src_stride_abgr,
1143
- uint8_t* dst_uj,
1144
- uint8_t* dst_vj,
1145
- int width) {
1146
- ARGBToUVMatrixRow_SVE_SC(src_abgr, src_stride_abgr, dst_uj, dst_vj, width,
1147
- kABGRToUVJCoefficients);
1148
- }
1149
-
1150
- __arm_locally_streaming void BGRAToUVRow_SME(const uint8_t* src_bgra,
1151
- int src_stride_bgra,
1152
- uint8_t* dst_u,
1153
- uint8_t* dst_v,
1154
- int width) {
1155
- ARGBToUVMatrixRow_SVE_SC(src_bgra, src_stride_bgra, dst_u, dst_v, width,
1156
- kBGRAToUVCoefficients);
1157
- }
1158
-
1159
- __arm_locally_streaming void ABGRToUVRow_SME(const uint8_t* src_abgr,
1160
- int src_stride_abgr,
1161
- uint8_t* dst_u,
1162
- uint8_t* dst_v,
1163
- int width) {
1164
- ARGBToUVMatrixRow_SVE_SC(src_abgr, src_stride_abgr, dst_u, dst_v, width,
1165
- kABGRToUVCoefficients);
1166
- }
1167
-
1168
- __arm_locally_streaming void RGBAToUVRow_SME(const uint8_t* src_rgba,
1169
- int src_stride_rgba,
1170
- uint8_t* dst_u,
1171
- uint8_t* dst_v,
1172
- int width) {
1173
- ARGBToUVMatrixRow_SVE_SC(src_rgba, src_stride_rgba, dst_u, dst_v, width,
1174
- kRGBAToUVCoefficients);
1175
- }
1176
-
1177
- #endif // !defined(LIBYUV_DISABLE_SME) && defined(CLANG_HAS_SME) &&
1178
- // defined(__aarch64__)
1179
-
1180
- #ifdef __cplusplus
1181
- } // extern "C"
1182
- } // namespace libyuv
1183
- #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.h"
12
+ #include "libyuv/row_sve.h"
13
+
14
+ #ifdef __cplusplus
15
+ namespace libyuv {
16
+ extern "C" {
17
+ #endif
18
+
19
+ #if !defined(LIBYUV_DISABLE_SME) && defined(CLANG_HAS_SME) && \
20
+ defined(__aarch64__)
21
+
22
+ #define RGBTOARGB8_SVE_2X \
23
+ /* Inputs: B: z16.h, G: z17.h, R: z18.h, A: z19.b */ \
24
+ "uqshrnb z16.b, z16.h, #6 \n" /* B0 */ \
25
+ "uqshrnb z17.b, z17.h, #6 \n" /* G0 */ \
26
+ "uqshrnb z18.b, z18.h, #6 \n" /* R0 */ \
27
+ "uqshrnt z16.b, z20.h, #6 \n" /* B1 */ \
28
+ "uqshrnt z17.b, z21.h, #6 \n" /* G1 */ \
29
+ "uqshrnt z18.b, z22.h, #6 \n" /* R1 */
30
+
31
+ __arm_locally_streaming void I444ToARGBRow_SME(
32
+ const uint8_t* src_y,
33
+ const uint8_t* src_u,
34
+ const uint8_t* src_v,
35
+ uint8_t* dst_argb,
36
+ const struct YuvConstants* yuvconstants,
37
+ int width) {
38
+ // Streaming-SVE only, no use of ZA tile.
39
+ uint64_t vl;
40
+ asm volatile(
41
+ "cntb %[vl] \n"
42
+ "ptrue p0.b \n" //
43
+ YUVTORGB_SVE_SETUP
44
+ "dup z19.b, #255 \n" // A
45
+ "subs %w[width], %w[width], %w[vl] \n"
46
+ "b.lt 2f \n"
47
+
48
+ // Run bulk of computation with an all-true predicate to avoid predicate
49
+ // generation overhead.
50
+ "ptrue p1.b \n"
51
+ "1: \n" //
52
+ READYUV444_SVE_2X I444TORGB_SVE_2X RGBTOARGB8_SVE_2X
53
+ "subs %w[width], %w[width], %w[vl] \n"
54
+ "st4b {z16.b, z17.b, z18.b, z19.b}, p1, [%[dst_argb]] \n"
55
+ "incb %[dst_argb], all, mul #4 \n"
56
+ "b.ge 1b \n"
57
+
58
+ "2: \n"
59
+ "adds %w[width], %w[width], %w[vl] \n"
60
+ "b.eq 99f \n"
61
+
62
+ // Calculate a predicate for the final iteration to deal with the tail.
63
+ "whilelt p1.b, wzr, %w[width] \n" //
64
+ READYUV444_SVE_2X I444TORGB_SVE_2X RGBTOARGB8_SVE_2X
65
+ "st4b {z16.b, z17.b, z18.b, z19.b}, p1, [%[dst_argb]] \n"
66
+
67
+ "99: \n"
68
+ : [src_y] "+r"(src_y), // %[src_y]
69
+ [src_u] "+r"(src_u), // %[src_u]
70
+ [src_v] "+r"(src_v), // %[src_v]
71
+ [dst_argb] "+r"(dst_argb), // %[dst_argb]
72
+ [width] "+r"(width), // %[width]
73
+ [vl] "=&r"(vl) // %[vl]
74
+ : [kUVCoeff] "r"(&yuvconstants->kUVCoeff), // %[kUVCoeff]
75
+ [kRGBCoeffBias] "r"(&yuvconstants->kRGBCoeffBias) // %[kRGBCoeffBias]
76
+ : "cc", "memory", YUVTORGB_SVE_REGS);
77
+ }
78
+
79
+ __arm_locally_streaming void I444ToRGB24Row_SME(
80
+ const uint8_t* src_y,
81
+ const uint8_t* src_u,
82
+ const uint8_t* src_v,
83
+ uint8_t* dst_rgb24,
84
+ const struct YuvConstants* yuvconstants,
85
+ int width) {
86
+ I444ToRGB24Row_SVE_SC(src_y, src_u, src_v, dst_rgb24, yuvconstants, width);
87
+ }
88
+
89
+ __arm_locally_streaming void I400ToARGBRow_SME(
90
+ const uint8_t* src_y,
91
+ uint8_t* dst_argb,
92
+ const struct YuvConstants* yuvconstants,
93
+ int width) {
94
+ // Streaming-SVE only, no use of ZA tile.
95
+ I400ToARGBRow_SVE_SC(src_y, dst_argb, yuvconstants, width);
96
+ }
97
+
98
+ __arm_locally_streaming void I422ToARGBRow_SME(
99
+ const uint8_t* src_y,
100
+ const uint8_t* src_u,
101
+ const uint8_t* src_v,
102
+ uint8_t* dst_argb,
103
+ const struct YuvConstants* yuvconstants,
104
+ int width) {
105
+ // Streaming-SVE only, no use of ZA tile.
106
+ I422ToARGBRow_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
107
+ }
108
+
109
+ __arm_locally_streaming void I422ToRGB24Row_SME(
110
+ 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
+ __arm_locally_streaming void I422ToRGB565Row_SME(
120
+ const uint8_t* src_y,
121
+ const uint8_t* src_u,
122
+ const uint8_t* src_v,
123
+ uint8_t* dst_rgb565,
124
+ const struct YuvConstants* yuvconstants,
125
+ int width) {
126
+ I422ToRGB565Row_SVE_SC(src_y, src_u, src_v, dst_rgb565, yuvconstants, width);
127
+ }
128
+
129
+ __arm_locally_streaming void I422ToARGB1555Row_SME(
130
+ const uint8_t* src_y,
131
+ const uint8_t* src_u,
132
+ const uint8_t* src_v,
133
+ uint8_t* dst_argb1555,
134
+ const struct YuvConstants* yuvconstants,
135
+ int width) {
136
+ I422ToARGB1555Row_SVE_SC(src_y, src_u, src_v, dst_argb1555, yuvconstants,
137
+ width);
138
+ }
139
+
140
+ __arm_locally_streaming void I422ToARGB4444Row_SME(
141
+ const uint8_t* src_y,
142
+ const uint8_t* src_u,
143
+ const uint8_t* src_v,
144
+ uint8_t* dst_argb4444,
145
+ const struct YuvConstants* yuvconstants,
146
+ int width) {
147
+ I422ToARGB4444Row_SVE_SC(src_y, src_u, src_v, dst_argb4444, yuvconstants,
148
+ width);
149
+ }
150
+
151
+ __arm_locally_streaming void I422ToRGBARow_SME(
152
+ const uint8_t* src_y,
153
+ const uint8_t* src_u,
154
+ const uint8_t* src_v,
155
+ uint8_t* dst_argb,
156
+ const struct YuvConstants* yuvconstants,
157
+ int width) {
158
+ I422ToRGBARow_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
159
+ }
160
+
161
+ __arm_locally_streaming void I422ToAR30Row_SME(
162
+ const uint8_t* src_y,
163
+ const uint8_t* src_u,
164
+ const uint8_t* src_v,
165
+ uint8_t* dst_argb,
166
+ const struct YuvConstants* yuvconstants,
167
+ int width) {
168
+ I422ToAR30Row_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
169
+ }
170
+
171
+ __arm_locally_streaming void I422AlphaToARGBRow_SME(
172
+ const uint8_t* src_y,
173
+ const uint8_t* src_u,
174
+ const uint8_t* src_v,
175
+ const uint8_t* src_a,
176
+ uint8_t* dst_argb,
177
+ const struct YuvConstants* yuvconstants,
178
+ int width) {
179
+ I422AlphaToARGBRow_SVE_SC(src_y, src_u, src_v, src_a, dst_argb, yuvconstants,
180
+ width);
181
+ }
182
+
183
+ __arm_locally_streaming void I444AlphaToARGBRow_SME(
184
+ const uint8_t* src_y,
185
+ const uint8_t* src_u,
186
+ const uint8_t* src_v,
187
+ const uint8_t* src_a,
188
+ uint8_t* dst_argb,
189
+ const struct YuvConstants* yuvconstants,
190
+ int width) {
191
+ I444AlphaToARGBRow_SVE_SC(src_y, src_u, src_v, src_a, dst_argb, yuvconstants,
192
+ width);
193
+ }
194
+
195
+ __arm_locally_streaming void NV12ToARGBRow_SME(
196
+ const uint8_t* src_y,
197
+ const uint8_t* src_uv,
198
+ uint8_t* dst_argb,
199
+ const struct YuvConstants* yuvconstants,
200
+ int width) {
201
+ NV12ToARGBRow_SVE_SC(src_y, src_uv, dst_argb, yuvconstants, width);
202
+ }
203
+
204
+ __arm_locally_streaming void NV21ToARGBRow_SME(
205
+ const uint8_t* src_y,
206
+ const uint8_t* src_vu,
207
+ uint8_t* dst_argb,
208
+ const struct YuvConstants* yuvconstants,
209
+ int width) {
210
+ NV21ToARGBRow_SVE_SC(src_y, src_vu, dst_argb, yuvconstants, width);
211
+ }
212
+
213
+ __arm_locally_streaming void NV12ToRGB24Row_SME(
214
+ const uint8_t* src_y,
215
+ const uint8_t* src_uv,
216
+ uint8_t* dst_rgb24,
217
+ const struct YuvConstants* yuvconstants,
218
+ int width) {
219
+ NV12ToRGB24Row_SVE_SC(src_y, src_uv, dst_rgb24, yuvconstants, width);
220
+ }
221
+
222
+ __arm_locally_streaming void NV21ToRGB24Row_SME(
223
+ const uint8_t* src_y,
224
+ const uint8_t* src_vu,
225
+ uint8_t* dst_rgb24,
226
+ const struct YuvConstants* yuvconstants,
227
+ int width) {
228
+ NV21ToRGB24Row_SVE_SC(src_y, src_vu, dst_rgb24, yuvconstants, width);
229
+ }
230
+
231
+ __arm_locally_streaming void YUY2ToARGBRow_SME(
232
+ const uint8_t* src_yuy2,
233
+ uint8_t* dst_argb,
234
+ const struct YuvConstants* yuvconstants,
235
+ int width) {
236
+ YUY2ToARGBRow_SVE_SC(src_yuy2, dst_argb, yuvconstants, width);
237
+ }
238
+
239
+ __arm_locally_streaming void UYVYToARGBRow_SME(
240
+ const uint8_t* src_uyvy,
241
+ uint8_t* dst_argb,
242
+ const struct YuvConstants* yuvconstants,
243
+ int width) {
244
+ UYVYToARGBRow_SVE_SC(src_uyvy, dst_argb, yuvconstants, width);
245
+ }
246
+
247
+ __arm_locally_streaming void I210ToARGBRow_SME(
248
+ const uint16_t* src_y,
249
+ const uint16_t* src_u,
250
+ const uint16_t* src_v,
251
+ uint8_t* dst_argb,
252
+ const struct YuvConstants* yuvconstants,
253
+ int width) {
254
+ I210ToARGBRow_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
255
+ }
256
+
257
+ __arm_locally_streaming void I210AlphaToARGBRow_SME(
258
+ const uint16_t* src_y,
259
+ const uint16_t* src_u,
260
+ const uint16_t* src_v,
261
+ const uint16_t* src_a,
262
+ uint8_t* dst_argb,
263
+ const struct YuvConstants* yuvconstants,
264
+ int width) {
265
+ I210AlphaToARGBRow_SVE_SC(src_y, src_u, src_v, src_a, dst_argb, yuvconstants,
266
+ width);
267
+ }
268
+
269
+ __arm_locally_streaming void I210ToAR30Row_SME(
270
+ const uint16_t* src_y,
271
+ const uint16_t* src_u,
272
+ const uint16_t* src_v,
273
+ uint8_t* dst_ar30,
274
+ const struct YuvConstants* yuvconstants,
275
+ int width) {
276
+ I210ToAR30Row_SVE_SC(src_y, src_u, src_v, dst_ar30, yuvconstants, width);
277
+ }
278
+
279
+ __arm_locally_streaming void P210ToARGBRow_SME(
280
+ const uint16_t* src_y,
281
+ const uint16_t* src_uv,
282
+ uint8_t* dst_argb,
283
+ const struct YuvConstants* yuvconstants,
284
+ int width) {
285
+ P210ToARGBRow_SVE_SC(src_y, src_uv, dst_argb, yuvconstants, width);
286
+ }
287
+
288
+ __arm_locally_streaming void P210ToAR30Row_SME(
289
+ const uint16_t* src_y,
290
+ const uint16_t* src_uv,
291
+ uint8_t* dst_ar30,
292
+ const struct YuvConstants* yuvconstants,
293
+ int width) {
294
+ P210ToAR30Row_SVE_SC(src_y, src_uv, dst_ar30, yuvconstants, width);
295
+ }
296
+
297
+ __arm_locally_streaming void I410ToARGBRow_SME(
298
+ const uint16_t* src_y,
299
+ const uint16_t* src_u,
300
+ const uint16_t* src_v,
301
+ uint8_t* dst_argb,
302
+ const struct YuvConstants* yuvconstants,
303
+ int width) {
304
+ I410ToARGBRow_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
305
+ }
306
+
307
+ __arm_locally_streaming void I410AlphaToARGBRow_SME(
308
+ const uint16_t* src_y,
309
+ const uint16_t* src_u,
310
+ const uint16_t* src_v,
311
+ const uint16_t* src_a,
312
+ uint8_t* dst_argb,
313
+ const struct YuvConstants* yuvconstants,
314
+ int width) {
315
+ I410AlphaToARGBRow_SVE_SC(src_y, src_u, src_v, src_a, dst_argb, yuvconstants,
316
+ width);
317
+ }
318
+
319
+ __arm_locally_streaming void I410ToAR30Row_SME(
320
+ const uint16_t* src_y,
321
+ const uint16_t* src_u,
322
+ const uint16_t* src_v,
323
+ uint8_t* dst_ar30,
324
+ const struct YuvConstants* yuvconstants,
325
+ int width) {
326
+ I410ToAR30Row_SVE_SC(src_y, src_u, src_v, dst_ar30, yuvconstants, width);
327
+ }
328
+
329
+ __arm_locally_streaming void P410ToARGBRow_SME(
330
+ const uint16_t* src_y,
331
+ const uint16_t* src_uv,
332
+ uint8_t* dst_argb,
333
+ const struct YuvConstants* yuvconstants,
334
+ int width) {
335
+ P410ToARGBRow_SVE_SC(src_y, src_uv, dst_argb, yuvconstants, width);
336
+ }
337
+
338
+ __arm_locally_streaming void P410ToAR30Row_SME(
339
+ const uint16_t* src_y,
340
+ const uint16_t* src_uv,
341
+ uint8_t* dst_ar30,
342
+ const struct YuvConstants* yuvconstants,
343
+ int width) {
344
+ P410ToAR30Row_SVE_SC(src_y, src_uv, dst_ar30, yuvconstants, width);
345
+ }
346
+
347
+ __arm_locally_streaming void I212ToAR30Row_SME(
348
+ const uint16_t* src_y,
349
+ const uint16_t* src_u,
350
+ const uint16_t* src_v,
351
+ uint8_t* dst_ar30,
352
+ const struct YuvConstants* yuvconstants,
353
+ int width) {
354
+ I212ToAR30Row_SVE_SC(src_y, src_u, src_v, dst_ar30, yuvconstants, width);
355
+ }
356
+
357
+ __arm_locally_streaming void I212ToARGBRow_SME(
358
+ const uint16_t* src_y,
359
+ const uint16_t* src_u,
360
+ const uint16_t* src_v,
361
+ uint8_t* dst_argb,
362
+ const struct YuvConstants* yuvconstants,
363
+ int width) {
364
+ I212ToARGBRow_SVE_SC(src_y, src_u, src_v, dst_argb, yuvconstants, width);
365
+ }
366
+
367
+ __arm_locally_streaming void MultiplyRow_16_SME(const uint16_t* src_y,
368
+ uint16_t* dst_y,
369
+ int scale,
370
+ int width) {
371
+ // Streaming-SVE only, no use of ZA tile.
372
+ int vl;
373
+ asm volatile(
374
+ "cnth %x[vl] \n"
375
+ "mov z0.h, %w[scale] \n"
376
+ "subs %w[width], %w[width], %w[vl] \n"
377
+ "b.lt 2f \n"
378
+
379
+ // Run bulk of computation with an all-true predicate to avoid predicate
380
+ // generation overhead.
381
+ "ptrue p0.h \n"
382
+ "1: \n"
383
+ "ld1h {z1.h}, p0/z, [%[src_y]] \n"
384
+ "incb %[src_y] \n"
385
+ "mul z1.h, z0.h, z1.h \n"
386
+ "subs %w[width], %w[width], %w[vl] \n"
387
+ "st1h {z1.h}, p0, [%[dst_y]] \n"
388
+ "incb %[dst_y] \n"
389
+ "b.ge 1b \n"
390
+
391
+ "2: \n"
392
+ "adds %w[width], %w[width], %w[vl] \n"
393
+ "b.eq 99f \n"
394
+
395
+ // Calculate a predicate for the final iteration to deal with the tail.
396
+ "whilelt p0.h, wzr, %w[width] \n"
397
+ "ld1h {z1.h}, p0/z, [%[src_y]] \n"
398
+ "mul z1.h, z0.h, z1.h \n"
399
+ "st1h {z1.h}, p0, [%[dst_y]] \n"
400
+
401
+ "99: \n"
402
+ : [src_y] "+r"(src_y), // %[src_y]
403
+ [dst_y] "+r"(dst_y), // %[dst_y]
404
+ [width] "+r"(width), // %[width]
405
+ [vl] "=&r"(vl) // %[vl]
406
+ : [scale] "r"(scale) // %[scale]
407
+ : "memory", "cc", "z0", "z1", "p0");
408
+ }
409
+
410
+ __arm_locally_streaming void ARGBMultiplyRow_SME(const uint8_t* src_argb,
411
+ const uint8_t* src_argb1,
412
+ uint8_t* dst_argb,
413
+ int width) {
414
+ // Streaming-SVE only, no use of ZA tile.
415
+ width *= 4;
416
+ int vl;
417
+ asm volatile(
418
+ "cntb %x[vl] \n"
419
+ "subs %w[width], %w[width], %w[vl] \n"
420
+ "b.lt 2f \n"
421
+
422
+ // Run bulk of computation with an all-true predicate to avoid predicate
423
+ // generation overhead.
424
+ "ptrue p0.b \n"
425
+ "1: \n"
426
+ "ld1b {z0.b}, p0/z, [%[src_argb]] \n"
427
+ "ld1b {z1.b}, p0/z, [%[src_argb1]] \n"
428
+ "incb %[src_argb] \n"
429
+ "incb %[src_argb1] \n"
430
+ "umullb z2.h, z0.b, z1.b \n"
431
+ "umullt z1.h, z0.b, z1.b \n"
432
+ "rshrnb z0.b, z2.h, #8 \n"
433
+ "rshrnt z0.b, z1.h, #8 \n"
434
+ "subs %w[width], %w[width], %w[vl] \n"
435
+ "st1b {z0.b}, p0, [%[dst_argb]] \n"
436
+ "incb %[dst_argb] \n"
437
+ "b.ge 1b \n"
438
+
439
+ "2: \n"
440
+ "adds %w[width], %w[width], %w[vl] \n"
441
+ "b.eq 99f \n"
442
+
443
+ // Calculate a predicate for the final iteration to deal with the tail.
444
+ "whilelt p0.b, wzr, %w[width] \n"
445
+ "ld1b {z0.b}, p0/z, [%[src_argb]] \n"
446
+ "ld1b {z1.b}, p0/z, [%[src_argb1]] \n"
447
+ "umullb z2.h, z0.b, z1.b \n"
448
+ "umullt z1.h, z0.b, z1.b \n"
449
+ "rshrnb z0.b, z2.h, #8 \n"
450
+ "rshrnt z0.b, z1.h, #8 \n"
451
+ "st1b {z0.b}, p0, [%[dst_argb]] \n"
452
+
453
+ "99: \n"
454
+ : [src_argb] "+r"(src_argb), // %[src_argb]
455
+ [src_argb1] "+r"(src_argb1), // %[src_argb1]
456
+ [dst_argb] "+r"(dst_argb), // %[dst_argb]
457
+ [width] "+r"(width), // %[width]
458
+ [vl] "=&r"(vl) // %[vl]
459
+ :
460
+ : "memory", "cc", "z0", "z1", "z2", "p0", "p1");
461
+ }
462
+
463
+ __arm_locally_streaming void MergeUVRow_SME(const uint8_t* src_u,
464
+ const uint8_t* src_v,
465
+ uint8_t* dst_uv,
466
+ int width) {
467
+ // Streaming-SVE only, no use of ZA tile.
468
+ int vl;
469
+ asm volatile(
470
+ "cntb %x[vl] \n"
471
+ "subs %w[width], %w[width], %w[vl] \n"
472
+ "b.lt 2f \n"
473
+
474
+ // Run bulk of computation with an all-true predicate to avoid predicate
475
+ // generation overhead.
476
+ "ptrue p0.b \n"
477
+ "1: \n"
478
+ "ld1b {z1.b}, p0/z, [%[src_u]] \n"
479
+ "ld1b {z2.b}, p0/z, [%[src_v]] \n"
480
+ "incb %[src_u] \n"
481
+ "incb %[src_v] \n"
482
+ "subs %w[width], %w[width], %w[vl] \n"
483
+ "st2b {z1.b, z2.b}, p0, [%[dst_uv]] \n"
484
+ "incb %[dst_uv], all, mul #2 \n"
485
+ "b.ge 1b \n"
486
+
487
+ "2: \n"
488
+ "adds %w[width], %w[width], %w[vl] \n"
489
+ "b.eq 99f \n"
490
+
491
+ // Calculate a predicate for the final iteration to deal with the tail.
492
+ "whilelt p0.b, wzr, %w[width] \n"
493
+ "ld1b {z1.b}, p0/z, [%[src_u]] \n"
494
+ "ld1b {z2.b}, p0/z, [%[src_v]] \n"
495
+ "subs %w[width], %w[width], %w[vl] \n"
496
+ "st2b {z1.b, z2.b}, p0, [%[dst_uv]] \n"
497
+
498
+ "99: \n"
499
+ : [src_u] "+r"(src_u), // %[src_u]
500
+ [src_v] "+r"(src_v), // %[src_v]
501
+ [dst_uv] "+r"(dst_uv), // %[dst_uv]
502
+ [width] "+r"(width), // %[width]
503
+ [vl] "=&r"(vl) // %[vl]
504
+ :
505
+ : "memory", "cc", "z0", "z1", "z2", "p0");
506
+ }
507
+
508
+ __arm_locally_streaming void MergeUVRow_16_SME(const uint16_t* src_u,
509
+ const uint16_t* src_v,
510
+ uint16_t* dst_uv,
511
+ int depth,
512
+ int width) {
513
+ int shift = 16 - depth;
514
+ // Streaming-SVE only, no use of ZA tile.
515
+ int vl;
516
+ asm volatile(
517
+ "cnth %x[vl] \n"
518
+ "mov z0.h, %w[shift] \n"
519
+ "subs %w[width], %w[width], %w[vl] \n"
520
+ "b.lt 2f \n"
521
+
522
+ // Run bulk of computation with an all-true predicate to avoid predicate
523
+ // generation overhead.
524
+ "ptrue p0.h \n"
525
+ "1: \n"
526
+ "ld1h {z1.h}, p0/z, [%[src_u]] \n"
527
+ "ld1h {z2.h}, p0/z, [%[src_v]] \n"
528
+ "incb %[src_u] \n"
529
+ "incb %[src_v] \n"
530
+ "lsl z1.h, p0/m, z1.h, z0.h \n"
531
+ "lsl z2.h, p0/m, z2.h, z0.h \n"
532
+ "subs %w[width], %w[width], %w[vl] \n"
533
+ "st2h {z1.h, z2.h}, p0, [%[dst_uv]] \n"
534
+ "incb %[dst_uv], all, mul #2 \n"
535
+ "b.ge 1b \n"
536
+
537
+ "2: \n"
538
+ "adds %w[width], %w[width], %w[vl] \n"
539
+ "b.eq 99f \n"
540
+
541
+ // Calculate a predicate for the final iteration to deal with the tail.
542
+ "whilelt p0.h, wzr, %w[width] \n"
543
+ "ld1h {z1.h}, p0/z, [%[src_u]] \n"
544
+ "ld1h {z2.h}, p0/z, [%[src_v]] \n"
545
+ "lsl z1.h, p0/m, z1.h, z0.h \n"
546
+ "lsl z2.h, p0/m, z2.h, z0.h \n"
547
+ "subs %w[width], %w[width], %w[vl] \n"
548
+ "st2h {z1.h, z2.h}, p0, [%[dst_uv]] \n"
549
+
550
+ "99: \n"
551
+ : [src_u] "+r"(src_u), // %[src_u]
552
+ [src_v] "+r"(src_v), // %[src_v]
553
+ [dst_uv] "+r"(dst_uv), // %[dst_uv]
554
+ [width] "+r"(width), // %[width]
555
+ [vl] "=&r"(vl) // %[vl]
556
+ : [shift] "r"(shift) // %[shift]
557
+ : "memory", "cc", "z0", "z1", "z2", "p0");
558
+ }
559
+
560
+ // Use scale to convert lsb formats to msb, depending how many bits there are:
561
+ // 32768 = 9 bits = shr 1
562
+ // 16384 = 10 bits = shr 2
563
+ // 4096 = 12 bits = shr 4
564
+ // 256 = 16 bits = shr 8
565
+ __arm_locally_streaming void Convert16To8Row_SME(const uint16_t* src_y,
566
+ uint8_t* dst_y,
567
+ int scale,
568
+ int width) {
569
+ // 15 - clz(scale), + 8 to shift result into the high half of the lane to
570
+ // saturate, then we can just use UZP2 to narrow rather than a pair of
571
+ // saturating narrow instructions.
572
+ const int shift = 23 - __builtin_clz((int32_t)scale);
573
+ int vl;
574
+ asm volatile(
575
+ "cntb %x[vl] \n"
576
+ "dup z0.h, %w[shift] \n"
577
+ "subs %w[width], %w[width], %w[vl] \n"
578
+ "b.lt 2f \n"
579
+
580
+ // Run bulk of computation with an all-true predicate to avoid predicate
581
+ // generation overhead.
582
+ "ptrue p0.b \n"
583
+ "1: \n"
584
+ "ld1h {z1.h}, p0/z, [%[src_y]] \n"
585
+ "ld1h {z2.h}, p0/z, [%[src_y], #1, mul vl] \n"
586
+ "incb %[src_y], all, mul #2 \n"
587
+ "uqshl z1.h, p0/m, z1.h, z0.h \n"
588
+ "uqshl z2.h, p0/m, z2.h, z0.h \n"
589
+ "subs %w[width], %w[width], %w[vl] \n"
590
+ "uzp2 z1.b, z1.b, z2.b \n"
591
+ "st1b {z1.b}, p0, [%[dst_y]] \n"
592
+ "incb %[dst_y] \n"
593
+ "b.ge 1b \n"
594
+
595
+ "2: \n"
596
+ "adds %w[width], %w[width], %w[vl] \n"
597
+ "b.eq 99f \n"
598
+
599
+ // Calculate a predicate for the final iteration to deal with the tail.
600
+ // We need separate predicates for the load and store instructions since
601
+ // they are operating on different element sizes (.b vs .h).
602
+ "cnth %x[vl] \n"
603
+ "whilelt p0.h, wzr, %w[width] \n"
604
+ "whilelt p1.h, %w[vl], %w[width] \n"
605
+ "whilelt p2.b, wzr, %w[width] \n"
606
+ "ld1h {z1.h}, p0/z, [%[src_y]] \n"
607
+ "ld1h {z2.h}, p1/z, [%[src_y], #1, mul vl] \n"
608
+ "uqshl z1.h, p0/m, z1.h, z0.h \n"
609
+ "uqshl z2.h, p1/m, z2.h, z0.h \n"
610
+ "uzp2 z1.b, z1.b, z2.b \n"
611
+ "st1b {z1.b}, p2, [%[dst_y]] \n"
612
+
613
+ "99: \n"
614
+ : [src_y] "+r"(src_y), // %[src_y]
615
+ [dst_y] "+r"(dst_y), // %[dst_y]
616
+ [width] "+r"(width), // %[width]
617
+ [vl] "=&r"(vl) // %[vl]
618
+ : [shift] "r"(shift) // %[shift]
619
+ : "cc", "memory", "z0", "z1", "z2", "p0", "p1", "p2");
620
+ }
621
+
622
+ __arm_locally_streaming void CopyRow_SME(const uint8_t* src,
623
+ uint8_t* dst,
624
+ int width) {
625
+ // Streaming-SVE only, no use of ZA tile.
626
+ int vl;
627
+ asm volatile(
628
+ "cntb %x[vl] \n"
629
+ "subs %w[width], %w[width], %w[vl] \n"
630
+ "b.lt 2f \n"
631
+
632
+ // Run bulk of computation with an all-true predicate to avoid predicate
633
+ // generation overhead.
634
+ "ptrue p0.b \n"
635
+ "1: \n"
636
+ "ld1b {z0.b}, p0/z, [%[src]] \n"
637
+ "incb %[src] \n"
638
+ "subs %w[width], %w[width], %w[vl] \n"
639
+ "st1b {z0.b}, p0, [%[dst]] \n"
640
+ "incb %[dst] \n"
641
+ "b.ge 1b \n"
642
+
643
+ "2: \n"
644
+ "adds %w[width], %w[width], %w[vl] \n"
645
+ "b.eq 99f \n"
646
+
647
+ // Calculate a predicate for the final iteration to deal with the tail.
648
+ "whilelt p0.b, wzr, %w[width] \n"
649
+ "ld1b {z0.b}, p0/z, [%[src]] \n"
650
+ "st1b {z0.b}, p0, [%[dst]] \n"
651
+
652
+ "99: \n"
653
+ : [src] "+r"(src), // %[src]
654
+ [dst] "+r"(dst), // %[dst]
655
+ [width] "+r"(width), // %[width]
656
+ [vl] "=&r"(vl) // %[vl]
657
+ :
658
+ : "memory", "cc", "z0", "p0");
659
+ }
660
+
661
+ __arm_locally_streaming static void HalfRow_SME(uint8_t* dst_ptr,
662
+ const uint8_t* src_ptr,
663
+ ptrdiff_t src_stride,
664
+ int width) {
665
+ const uint8_t* src_ptr1 = src_ptr + src_stride;
666
+
667
+ int vl;
668
+ asm volatile(
669
+ "cntb %x[vl] \n"
670
+ "subs %w[width], %w[width], %w[vl] \n"
671
+ "b.lt 2f \n"
672
+
673
+ // Run bulk of computation with an all-true predicate to avoid predicate
674
+ // generation overhead.
675
+ "ptrue p0.b \n"
676
+ "1: \n"
677
+ "ld1b {z2.b}, p0/z, [%[src_ptr]] \n"
678
+ "ld1b {z3.b}, p0/z, [%[src_ptr1]] \n"
679
+ "incb %[src_ptr] \n"
680
+ "incb %[src_ptr1] \n"
681
+ "urhadd z2.b, p0/m, z2.b, z3.b \n"
682
+ "subs %w[width], %w[width], %w[vl] \n"
683
+ "st1b {z2.b}, p0, [%[dst_ptr]] \n"
684
+ "incb %[dst_ptr] \n"
685
+ "b.ge 1b \n"
686
+
687
+ "2: \n"
688
+ "adds %w[width], %w[width], %w[vl] \n"
689
+ "b.eq 99f \n"
690
+
691
+ // Calculate a predicate for the final iteration to deal with the tail.
692
+ "whilelt p0.b, wzr, %w[width] \n"
693
+ "ld1b {z2.b}, p0/z, [%[src_ptr]] \n"
694
+ "ld1b {z3.b}, p0/z, [%[src_ptr1]] \n"
695
+ "urhadd z2.b, p0/m, z2.b, z3.b \n"
696
+ "subs %w[width], %w[width], %w[vl] \n"
697
+ "st1b {z2.b}, p0, [%[dst_ptr]] \n"
698
+
699
+ "99: \n"
700
+ : [src_ptr] "+r"(src_ptr), // %[src_ptr]
701
+ [src_ptr1] "+r"(src_ptr1), // %[src_ptr1]
702
+ [dst_ptr] "+r"(dst_ptr), // %[dst_ptr]
703
+ [width] "+r"(width), // %[width]
704
+ [vl] "=&r"(vl) // %[vl]
705
+ :
706
+ : "cc", "memory", "z0", "z1", "z2", "z3", "p0");
707
+ }
708
+
709
+ __arm_locally_streaming void InterpolateRow_SME(uint8_t* dst_ptr,
710
+ const uint8_t* src_ptr,
711
+ ptrdiff_t src_stride,
712
+ int width,
713
+ int source_y_fraction) {
714
+ int y1_fraction = source_y_fraction;
715
+ int y0_fraction = 256 - y1_fraction;
716
+ const uint8_t* src_ptr1 = src_ptr + src_stride;
717
+
718
+ if (y0_fraction == 0) {
719
+ CopyRow_SME(src_ptr1, dst_ptr, width);
720
+ return;
721
+ }
722
+ if (y0_fraction == 128) {
723
+ HalfRow_SME(dst_ptr, src_ptr, src_stride, width);
724
+ return;
725
+ }
726
+ if (y0_fraction == 256) {
727
+ CopyRow_SME(src_ptr, dst_ptr, width);
728
+ return;
729
+ }
730
+
731
+ int vl;
732
+ asm volatile(
733
+ "cntb %x[vl] \n"
734
+ "dup z0.b, %w[y0_fraction] \n"
735
+ "dup z1.b, %w[y1_fraction] \n"
736
+ "subs %w[width], %w[width], %w[vl] \n"
737
+ "b.lt 2f \n"
738
+
739
+ // Run bulk of computation with an all-true predicate to avoid predicate
740
+ // generation overhead.
741
+ "ptrue p0.b \n"
742
+ "1: \n"
743
+ "ld1b {z2.b}, p0/z, [%[src_ptr]] \n"
744
+ "ld1b {z3.b}, p0/z, [%[src_ptr1]] \n"
745
+ "incb %[src_ptr] \n"
746
+ "incb %[src_ptr1] \n"
747
+ "umullb z4.h, z2.b, z0.b \n"
748
+ "umullt z2.h, z2.b, z0.b \n"
749
+ "subs %w[width], %w[width], %w[vl] \n"
750
+ "umlalb z4.h, z3.b, z1.b \n"
751
+ "umlalt z2.h, z3.b, z1.b \n"
752
+ "rshrnb z3.b, z4.h, #8 \n"
753
+ "rshrnt z3.b, z2.h, #8 \n"
754
+ "st1b {z3.b}, p0, [%[dst_ptr]] \n"
755
+ "incb %[dst_ptr] \n"
756
+ "b.ge 1b \n"
757
+
758
+ "2: \n"
759
+ "adds %w[width], %w[width], %w[vl] \n"
760
+ "b.eq 99f \n"
761
+
762
+ // Calculate a predicate for the final iteration to deal with the tail.
763
+ "whilelt p0.b, wzr, %w[width] \n"
764
+ "ld1b {z2.b}, p0/z, [%[src_ptr]] \n"
765
+ "ld1b {z3.b}, p0/z, [%[src_ptr1]] \n"
766
+ "umullb z4.h, z2.b, z0.b \n"
767
+ "umullt z2.h, z2.b, z0.b \n"
768
+ "umlalb z4.h, z3.b, z1.b \n"
769
+ "umlalt z2.h, z3.b, z1.b \n"
770
+ "rshrnb z3.b, z4.h, #8 \n"
771
+ "rshrnt z3.b, z2.h, #8 \n"
772
+ "st1b {z3.b}, p0, [%[dst_ptr]] \n"
773
+
774
+ "99: \n"
775
+ : [src_ptr] "+r"(src_ptr), // %[src_ptr]
776
+ [src_ptr1] "+r"(src_ptr1), // %[src_ptr1]
777
+ [dst_ptr] "+r"(dst_ptr), // %[dst_ptr]
778
+ [width] "+r"(width), // %[width]
779
+ [vl] "=&r"(vl) // %[vl]
780
+ : [y0_fraction] "r"(y0_fraction), // %[y0_fraction]
781
+ [y1_fraction] "r"(y1_fraction) // %[y1_fraction]
782
+ : "cc", "memory", "z0", "z1", "z2", "z3", "z4", "p0");
783
+ }
784
+
785
+ __arm_locally_streaming static void HalfRow_16_SME(uint16_t* dst_ptr,
786
+ const uint16_t* src_ptr,
787
+ ptrdiff_t src_stride,
788
+ int width) {
789
+ const uint16_t* src_ptr1 = src_ptr + src_stride;
790
+
791
+ int vl;
792
+ asm volatile(
793
+ "cnth %x[vl] \n"
794
+ "subs %w[width], %w[width], %w[vl] \n"
795
+ "b.lt 2f \n"
796
+
797
+ // Run bulk of computation with an all-true predicate to avoid predicate
798
+ // generation overhead.
799
+ "ptrue p0.h \n"
800
+ "1: \n"
801
+ "ld1h {z2.h}, p0/z, [%[src_ptr]] \n"
802
+ "ld1h {z3.h}, p0/z, [%[src_ptr1]] \n"
803
+ "incb %[src_ptr] \n"
804
+ "incb %[src_ptr1] \n"
805
+ "urhadd z2.h, p0/m, z2.h, z3.h \n"
806
+ "subs %w[width], %w[width], %w[vl] \n"
807
+ "st1h {z2.h}, p0, [%[dst_ptr]] \n"
808
+ "incb %[dst_ptr] \n"
809
+ "b.ge 1b \n"
810
+
811
+ "2: \n"
812
+ "adds %w[width], %w[width], %w[vl] \n"
813
+ "b.eq 99f \n"
814
+
815
+ // Calculate a predicate for the final iteration to deal with the tail.
816
+ "whilelt p0.h, wzr, %w[width] \n"
817
+ "ld1h {z2.h}, p0/z, [%[src_ptr]] \n"
818
+ "ld1h {z3.h}, p0/z, [%[src_ptr1]] \n"
819
+ "urhadd z2.h, p0/m, z2.h, z3.h \n"
820
+ "st1h {z2.h}, p0, [%[dst_ptr]] \n"
821
+
822
+ "99: \n"
823
+ : [src_ptr] "+r"(src_ptr), // %[src_ptr]
824
+ [src_ptr1] "+r"(src_ptr1), // %[src_ptr1]
825
+ [dst_ptr] "+r"(dst_ptr), // %[dst_ptr]
826
+ [width] "+r"(width), // %[width]
827
+ [vl] "=&r"(vl) // %[vl]
828
+ :
829
+ : "cc", "memory", "z0", "z1", "z2", "z3", "p0");
830
+ }
831
+
832
+ __arm_locally_streaming void InterpolateRow_16_SME(uint16_t* dst_ptr,
833
+ const uint16_t* src_ptr,
834
+ ptrdiff_t src_stride,
835
+ int width,
836
+ int source_y_fraction) {
837
+ int y1_fraction = source_y_fraction;
838
+ int y0_fraction = 256 - y1_fraction;
839
+ const uint16_t* src_ptr1 = src_ptr + src_stride;
840
+
841
+ if (y0_fraction == 0) {
842
+ CopyRow_SME((const uint8_t*)src_ptr1, (uint8_t*)dst_ptr,
843
+ width * sizeof(uint16_t));
844
+ return;
845
+ }
846
+ if (y0_fraction == 128) {
847
+ HalfRow_16_SME(dst_ptr, src_ptr, src_stride, width);
848
+ return;
849
+ }
850
+ if (y0_fraction == 256) {
851
+ CopyRow_SME((const uint8_t*)src_ptr, (uint8_t*)dst_ptr,
852
+ width * sizeof(uint16_t));
853
+ return;
854
+ }
855
+
856
+ int vl;
857
+ asm volatile(
858
+ "cnth %x[vl] \n"
859
+ "subs %w[width], %w[width], %w[vl] \n"
860
+ "dup z0.h, %w[y0_fraction] \n"
861
+ "dup z1.h, %w[y1_fraction] \n"
862
+ "b.lt 2f \n"
863
+
864
+ // Run bulk of computation with an all-true predicate to avoid predicate
865
+ // generation overhead.
866
+ "ptrue p0.h \n"
867
+ "1: \n"
868
+ "ld1h {z2.h}, p0/z, [%[src_ptr]] \n"
869
+ "ld1h {z3.h}, p0/z, [%[src_ptr1]] \n"
870
+ "incb %[src_ptr] \n"
871
+ "incb %[src_ptr1] \n"
872
+ "umullb z4.s, z2.h, z0.h \n"
873
+ "umullt z2.s, z2.h, z0.h \n"
874
+ "subs %w[width], %w[width], %w[vl] \n"
875
+ "umlalb z4.s, z3.h, z1.h \n"
876
+ "umlalt z2.s, z3.h, z1.h \n"
877
+ "rshrnb z3.h, z4.s, #8 \n"
878
+ "rshrnt z3.h, z2.s, #8 \n"
879
+ "st1h {z3.h}, p0, [%[dst_ptr]] \n"
880
+ "incb %[dst_ptr] \n"
881
+ "b.ge 1b \n"
882
+
883
+ "2: \n"
884
+ "adds %w[width], %w[width], %w[vl] \n"
885
+ "b.eq 99f \n"
886
+
887
+ // Calculate a predicate for the final iteration to deal with the tail.
888
+ "whilelt p0.h, wzr, %w[width] \n"
889
+ "ld1h {z2.h}, p0/z, [%[src_ptr]] \n"
890
+ "ld1h {z3.h}, p0/z, [%[src_ptr1]] \n"
891
+ "umullb z4.s, z2.h, z0.h \n"
892
+ "umullt z2.s, z2.h, z0.h \n"
893
+ "umlalb z4.s, z3.h, z1.h \n"
894
+ "umlalt z2.s, z3.h, z1.h \n"
895
+ "rshrnb z3.h, z4.s, #8 \n"
896
+ "rshrnt z3.h, z2.s, #8 \n"
897
+ "st1h {z3.h}, p0, [%[dst_ptr]] \n"
898
+
899
+ "99: \n"
900
+ : [src_ptr] "+r"(src_ptr), // %[src_ptr]
901
+ [src_ptr1] "+r"(src_ptr1), // %[src_ptr1]
902
+ [dst_ptr] "+r"(dst_ptr), // %[dst_ptr]
903
+ [width] "+r"(width), // %[width]
904
+ [vl] "=&r"(vl) // %[vl]
905
+ : [y0_fraction] "r"(y0_fraction), // %[y0_fraction]
906
+ [y1_fraction] "r"(y1_fraction) // %[y1_fraction]
907
+ : "cc", "memory", "z0", "z1", "z2", "z3", "z4", "p0");
908
+ }
909
+
910
+ __arm_locally_streaming static void HalfRow_16To8_SME(uint8_t* dst_ptr,
911
+ const uint16_t* src_ptr,
912
+ ptrdiff_t src_stride,
913
+ int scale,
914
+ int width) {
915
+ const uint16_t* src_ptr1 = src_ptr + src_stride;
916
+
917
+ // 15 - clz(scale), + 8 to shift result into the high half of the lane to
918
+ // saturate, then we can just use UZP2 to narrow rather than a pair of
919
+ // saturating narrow instructions.
920
+ const int shift = 23 - __builtin_clz((int32_t)scale);
921
+
922
+ int vl;
923
+ asm volatile(
924
+ "cnth %x[vl] \n"
925
+ "dup z31.h, %w[shift] \n"
926
+ "subs %w[width], %w[width], %w[vl] \n"
927
+ "b.lt 2f \n"
928
+
929
+ // Run bulk of computation with an all-true predicate to avoid predicate
930
+ // generation overhead.
931
+ "ptrue p0.h \n"
932
+ "1: \n"
933
+ "ld1h {z2.h}, p0/z, [%[src_ptr]] \n"
934
+ "ld1h {z3.h}, p0/z, [%[src_ptr1]] \n"
935
+ "incb %[src_ptr] \n"
936
+ "incb %[src_ptr1] \n"
937
+ "urhadd z2.h, p0/m, z2.h, z3.h \n"
938
+ "subs %w[width], %w[width], %w[vl] \n"
939
+ "uqshl z2.h, p0/m, z2.h, z31.h \n"
940
+ "shrnb z2.b, z2.h, #8 \n"
941
+ "st1b {z2.h}, p0, [%[dst_ptr]] \n"
942
+ "inch %[dst_ptr] \n"
943
+ "b.ge 1b \n"
944
+
945
+ "2: \n"
946
+ "adds %w[width], %w[width], %w[vl] \n"
947
+ "b.eq 99f \n"
948
+
949
+ // Calculate a predicate for the final iteration to deal with the tail.
950
+ "whilelt p0.h, wzr, %w[width] \n"
951
+ "ld1h {z2.h}, p0/z, [%[src_ptr]] \n"
952
+ "ld1h {z3.h}, p0/z, [%[src_ptr1]] \n"
953
+ "urhadd z2.h, p0/m, z2.h, z3.h \n"
954
+ "uqshl z2.h, p0/m, z2.h, z31.h \n"
955
+ "shrnb z2.b, z2.h, #8 \n"
956
+ "st1b {z2.h}, p0, [%[dst_ptr]] \n"
957
+
958
+ "99: \n"
959
+ : [src_ptr] "+r"(src_ptr), // %[src_ptr]
960
+ [src_ptr1] "+r"(src_ptr1), // %[src_ptr1]
961
+ [dst_ptr] "+r"(dst_ptr), // %[dst_ptr]
962
+ [width] "+r"(width), // %[width]
963
+ [vl] "=&r"(vl) // %[vl]
964
+ : [shift] "r"(shift) // %[shift]
965
+ : "cc", "memory", "z0", "z1", "z2", "z3", "z31", "p0");
966
+ }
967
+
968
+ // Use scale to convert lsb formats to msb, depending how many bits there are:
969
+ // 32768 = 9 bits
970
+ // 16384 = 10 bits
971
+ // 4096 = 12 bits
972
+ // 256 = 16 bits
973
+ // TODO(fbarchard): change scale to bits
974
+ __arm_locally_streaming void InterpolateRow_16To8_SME(uint8_t* dst_ptr,
975
+ const uint16_t* src_ptr,
976
+ ptrdiff_t src_stride,
977
+ int scale,
978
+ int width,
979
+ int source_y_fraction) {
980
+ const int y1_fraction = source_y_fraction;
981
+ const int y0_fraction = 256 - y1_fraction;
982
+ const uint16_t* src_ptr1 = src_ptr + src_stride;
983
+
984
+ // y0_fraction == 0 is never called here.
985
+ if (y0_fraction == 128) {
986
+ HalfRow_16To8_SME(dst_ptr, src_ptr, src_stride, scale, width);
987
+ return;
988
+ }
989
+ if (y0_fraction == 256) {
990
+ Convert16To8Row_SME(src_ptr, dst_ptr, scale, width);
991
+ return;
992
+ }
993
+
994
+ // 15 - clz(scale), + 8 to shift result into the high half of the lane to
995
+ // saturate, then we can just use UZP2 to narrow rather than a pair of
996
+ // saturating narrow instructions.
997
+ const int shift = 23 - __builtin_clz((int32_t)scale);
998
+
999
+ int vl;
1000
+ asm volatile(
1001
+ "cnth %x[vl] \n"
1002
+ "dup z31.h, %w[shift] \n"
1003
+ "dup z0.h, %w[y0_fraction] \n"
1004
+ "dup z1.h, %w[y1_fraction] \n"
1005
+ "subs %w[width], %w[width], %w[vl] \n"
1006
+ "b.lt 2f \n"
1007
+
1008
+ // Run bulk of computation with an all-true predicate to avoid predicate
1009
+ // generation overhead.
1010
+ "ptrue p0.h \n"
1011
+ "1: \n"
1012
+ "ld1h {z2.h}, p0/z, [%[src_ptr]] \n"
1013
+ "ld1h {z3.h}, p0/z, [%[src_ptr1]] \n"
1014
+ "incb %[src_ptr] \n"
1015
+ "incb %[src_ptr1] \n"
1016
+ "umullb z4.s, z2.h, z0.h \n"
1017
+ "umullt z2.s, z2.h, z0.h \n"
1018
+ "subs %w[width], %w[width], %w[vl] \n"
1019
+ "umlalb z4.s, z3.h, z1.h \n"
1020
+ "umlalt z2.s, z3.h, z1.h \n"
1021
+ "rshrnb z3.h, z4.s, #8 \n"
1022
+ "rshrnt z3.h, z2.s, #8 \n"
1023
+ "uqshl z3.h, p0/m, z3.h, z31.h \n"
1024
+ "shrnb z3.b, z3.h, #8 \n"
1025
+ "st1b {z3.h}, p0, [%[dst_ptr]] \n"
1026
+ "inch %[dst_ptr] \n"
1027
+ "b.ge 1b \n"
1028
+
1029
+ "2: \n"
1030
+ "adds %w[width], %w[width], %w[vl] \n"
1031
+ "b.eq 99f \n"
1032
+
1033
+ // Calculate a predicate for the final iteration to deal with the tail.
1034
+ "whilelt p0.h, wzr, %w[width] \n"
1035
+ "ld1h {z2.h}, p0/z, [%[src_ptr]] \n"
1036
+ "ld1h {z3.h}, p0/z, [%[src_ptr1]] \n"
1037
+ "umullb z4.s, z2.h, z0.h \n"
1038
+ "umullt z2.s, z2.h, z0.h \n"
1039
+ "umlalb z4.s, z3.h, z1.h \n"
1040
+ "umlalt z2.s, z3.h, z1.h \n"
1041
+ "rshrnb z3.h, z4.s, #8 \n"
1042
+ "rshrnt z3.h, z2.s, #8 \n"
1043
+ "uqshl z3.h, p0/m, z3.h, z31.h \n"
1044
+ "shrnb z3.b, z3.h, #8 \n"
1045
+ "st1b {z3.h}, p0, [%[dst_ptr]] \n"
1046
+
1047
+ "99: \n"
1048
+ : [src_ptr] "+r"(src_ptr), // %[src_ptr]
1049
+ [src_ptr1] "+r"(src_ptr1), // %[src_ptr1]
1050
+ [dst_ptr] "+r"(dst_ptr), // %[dst_ptr]
1051
+ [width] "+r"(width), // %[width]
1052
+ [vl] "=&r"(vl) // %[vl]
1053
+ : [y0_fraction] "r"(y0_fraction), // %[y0_fraction]
1054
+ [y1_fraction] "r"(y1_fraction), // %[y1_fraction]
1055
+ [shift] "r"(shift) // %[shift]
1056
+ : "cc", "memory", "z0", "z1", "z2", "z3", "z4", "z31", "p0");
1057
+ }
1058
+
1059
+ __arm_locally_streaming void Convert8To8Row_SME(const uint8_t* src_y,
1060
+ uint8_t* dst_y,
1061
+ int scale,
1062
+ int bias,
1063
+ int width) {
1064
+ Convert8To8Row_SVE_SC(src_y, dst_y, scale, bias, width);
1065
+ }
1066
+
1067
+ #define CONVERT8TO16_SVE \
1068
+ "ld1b {z0.h}, p0/z, [%[src]] \n" \
1069
+ "ld1b {z1.h}, p1/z, [%[src], #1, mul vl] \n" \
1070
+ "incb %[src] \n" \
1071
+ "subs %w[width], %w[width], %w[vl], lsl #1 \n" \
1072
+ "trn1 z0.b, z0.b, z0.b \n" \
1073
+ "trn1 z1.b, z1.b, z1.b \n" \
1074
+ "lsr z0.h, p0/m, z0.h, z2.h \n" \
1075
+ "lsr z1.h, p1/m, z1.h, z2.h \n" \
1076
+ "prfm pldl1keep, [%[src], 448] \n" \
1077
+ "st1h {z0.h}, p0, [%[dst]] \n" \
1078
+ "st1h {z1.h}, p1, [%[dst], #1, mul vl] \n" \
1079
+ "incb %[dst], all, mul #2 \n"
1080
+
1081
+ __arm_locally_streaming void Convert8To16Row_SME(const uint8_t* src_y,
1082
+ uint16_t* dst_y,
1083
+ int scale,
1084
+ int width) {
1085
+ // (src * 0x0101 * scale) >> 16.
1086
+ // Since scale is a power of two, compute the shift to use to avoid needing
1087
+ // to widen to int32.
1088
+ const int shift = __builtin_clz(scale) - 15;
1089
+
1090
+ uint64_t vl;
1091
+ asm volatile(
1092
+ "dup z2.h, %w[shift] \n"
1093
+ "cnth %[vl] \n"
1094
+ "subs %w[width], %w[width], %w[vl], lsl #1 \n"
1095
+ "b.lt 2f \n"
1096
+
1097
+ // Run bulk of computation with all-true predicates to avoid predicate
1098
+ // generation overhead.
1099
+ "ptrue p0.h \n"
1100
+ "ptrue p1.h \n"
1101
+ "1: \n" //
1102
+ CONVERT8TO16_SVE
1103
+ "b.ge 1b \n"
1104
+
1105
+ "2: \n"
1106
+ "adds %w[width], %w[width], %w[vl], lsl #1 \n"
1107
+ "b.eq 99f \n"
1108
+
1109
+ // Calculate predicates for the final iteration to deal with the tail.
1110
+ "whilelt p0.h, wzr, %w[width] \n"
1111
+ "whilelt p1.h, %w[vl], %w[width] \n" //
1112
+ CONVERT8TO16_SVE
1113
+
1114
+ "99: \n"
1115
+ : [src] "+r"(src_y), // %[src]
1116
+ [dst] "+r"(dst_y), // %[dst]
1117
+ [width] "+r"(width), // %[width]
1118
+ [vl] "=&r"(vl) // %[vl]
1119
+ : [shift] "r"(shift) // %[shift]
1120
+ : "cc", "memory", "z0", "z1", "z2", "p0", "p1");
1121
+ }
1122
+
1123
+ __arm_locally_streaming void ARGBToUVRow_SME(const uint8_t* src_argb,
1124
+ int src_stride_argb,
1125
+ uint8_t* dst_u,
1126
+ uint8_t* dst_v,
1127
+ int width) {
1128
+ ARGBToUVMatrixRow_SVE_SC(src_argb, src_stride_argb, dst_u, dst_v, width,
1129
+ kARGBToUVCoefficients);
1130
+ }
1131
+
1132
+ __arm_locally_streaming void ARGBToUVJRow_SME(const uint8_t* src_argb,
1133
+ int src_stride_argb,
1134
+ uint8_t* dst_u,
1135
+ uint8_t* dst_v,
1136
+ int width) {
1137
+ ARGBToUVMatrixRow_SVE_SC(src_argb, src_stride_argb, dst_u, dst_v, width,
1138
+ kARGBToUVJCoefficients);
1139
+ }
1140
+
1141
+ __arm_locally_streaming void ABGRToUVJRow_SME(const uint8_t* src_abgr,
1142
+ int src_stride_abgr,
1143
+ uint8_t* dst_uj,
1144
+ uint8_t* dst_vj,
1145
+ int width) {
1146
+ ARGBToUVMatrixRow_SVE_SC(src_abgr, src_stride_abgr, dst_uj, dst_vj, width,
1147
+ kABGRToUVJCoefficients);
1148
+ }
1149
+
1150
+ __arm_locally_streaming void BGRAToUVRow_SME(const uint8_t* src_bgra,
1151
+ int src_stride_bgra,
1152
+ uint8_t* dst_u,
1153
+ uint8_t* dst_v,
1154
+ int width) {
1155
+ ARGBToUVMatrixRow_SVE_SC(src_bgra, src_stride_bgra, dst_u, dst_v, width,
1156
+ kBGRAToUVCoefficients);
1157
+ }
1158
+
1159
+ __arm_locally_streaming void ABGRToUVRow_SME(const uint8_t* src_abgr,
1160
+ int src_stride_abgr,
1161
+ uint8_t* dst_u,
1162
+ uint8_t* dst_v,
1163
+ int width) {
1164
+ ARGBToUVMatrixRow_SVE_SC(src_abgr, src_stride_abgr, dst_u, dst_v, width,
1165
+ kABGRToUVCoefficients);
1166
+ }
1167
+
1168
+ __arm_locally_streaming void RGBAToUVRow_SME(const uint8_t* src_rgba,
1169
+ int src_stride_rgba,
1170
+ uint8_t* dst_u,
1171
+ uint8_t* dst_v,
1172
+ int width) {
1173
+ ARGBToUVMatrixRow_SVE_SC(src_rgba, src_stride_rgba, dst_u, dst_v, width,
1174
+ kRGBAToUVCoefficients);
1175
+ }
1176
+
1177
+ #endif // !defined(LIBYUV_DISABLE_SME) && defined(CLANG_HAS_SME) &&
1178
+ // defined(__aarch64__)
1179
+
1180
+ #ifdef __cplusplus
1181
+ } // extern "C"
1182
+ } // namespace libyuv
1183
+ #endif