react-native-vision-camera-spoof-detector 1.1.22 → 1.1.24

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 (201) hide show
  1. package/android/CMakeLists.txt +12 -0
  2. package/android/build.gradle +10 -9
  3. package/android/src/main/cpp/cpp-adapter.cpp +6 -3
  4. package/android/src/main/java/com/faceantispoof/FaceAntiSpoofingAdvanced.kt +83 -0
  5. package/android/src/main/java/com/margelo/nitro/camera/spoofdetector/HybridSpoofDetectorOutput.kt +26 -11
  6. package/package.json +1 -1
  7. package/android/src/main/cpp/CMakeLists.txt +0 -33
  8. package/android/src/main/cpp/FaceAntiSpoofJSI.cpp +0 -142
  9. package/android/src/main/cpp/FastYuvJni.cpp +0 -111
  10. package/android/src/main/cpp/fast_yuv.cpp +0 -342
  11. package/android/src/main/cpp/fast_yuv.h +0 -23
  12. package/android/src/main/cpp/libyuv/.clang-format +0 -6
  13. package/android/src/main/cpp/libyuv/.gn +0 -40
  14. package/android/src/main/cpp/libyuv/.vpython3 +0 -410
  15. package/android/src/main/cpp/libyuv/AUTHORS +0 -7
  16. package/android/src/main/cpp/libyuv/Android.bp +0 -202
  17. package/android/src/main/cpp/libyuv/Android.mk +0 -106
  18. package/android/src/main/cpp/libyuv/BUILD.gn +0 -490
  19. package/android/src/main/cpp/libyuv/CM_linux_packages.cmake +0 -70
  20. package/android/src/main/cpp/libyuv/CMakeLists.txt +0 -259
  21. package/android/src/main/cpp/libyuv/DEPS +0 -935
  22. package/android/src/main/cpp/libyuv/DIR_METADATA +0 -3
  23. package/android/src/main/cpp/libyuv/LICENSE +0 -29
  24. package/android/src/main/cpp/libyuv/OWNERS +0 -11
  25. package/android/src/main/cpp/libyuv/PATENTS +0 -24
  26. package/android/src/main/cpp/libyuv/PRESUBMIT.py +0 -65
  27. package/android/src/main/cpp/libyuv/README.chromium +0 -11
  28. package/android/src/main/cpp/libyuv/README.md +0 -19
  29. package/android/src/main/cpp/libyuv/build_overrides/build.gni +0 -60
  30. package/android/src/main/cpp/libyuv/build_overrides/gtest.gni +0 -19
  31. package/android/src/main/cpp/libyuv/build_overrides/partition_alloc.gni +0 -17
  32. package/android/src/main/cpp/libyuv/codereview.settings +0 -5
  33. package/android/src/main/cpp/libyuv/docs/deprecated_builds.md +0 -409
  34. package/android/src/main/cpp/libyuv/docs/environment_variables.md +0 -64
  35. package/android/src/main/cpp/libyuv/docs/feature_detection.md +0 -108
  36. package/android/src/main/cpp/libyuv/docs/filtering.md +0 -196
  37. package/android/src/main/cpp/libyuv/docs/formats.md +0 -208
  38. package/android/src/main/cpp/libyuv/docs/getting_started.md +0 -296
  39. package/android/src/main/cpp/libyuv/docs/rotation.md +0 -107
  40. package/android/src/main/cpp/libyuv/download_vs_toolchain.py +0 -29
  41. package/android/src/main/cpp/libyuv/include/libyuv/basic_types.h +0 -68
  42. package/android/src/main/cpp/libyuv/include/libyuv/compare.h +0 -111
  43. package/android/src/main/cpp/libyuv/include/libyuv/compare_row.h +0 -112
  44. package/android/src/main/cpp/libyuv/include/libyuv/convert.h +0 -1117
  45. package/android/src/main/cpp/libyuv/include/libyuv/convert_argb.h +0 -2335
  46. package/android/src/main/cpp/libyuv/include/libyuv/convert_from.h +0 -203
  47. package/android/src/main/cpp/libyuv/include/libyuv/convert_from_argb.h +0 -394
  48. package/android/src/main/cpp/libyuv/include/libyuv/cpu_id.h +0 -147
  49. package/android/src/main/cpp/libyuv/include/libyuv/cpu_support.h +0 -99
  50. package/android/src/main/cpp/libyuv/include/libyuv/loongson_intrinsics.h +0 -1949
  51. package/android/src/main/cpp/libyuv/include/libyuv/mjpeg_decoder.h +0 -195
  52. package/android/src/main/cpp/libyuv/include/libyuv/planar_functions.h +0 -1131
  53. package/android/src/main/cpp/libyuv/include/libyuv/rotate.h +0 -296
  54. package/android/src/main/cpp/libyuv/include/libyuv/rotate_argb.h +0 -37
  55. package/android/src/main/cpp/libyuv/include/libyuv/rotate_row.h +0 -265
  56. package/android/src/main/cpp/libyuv/include/libyuv/row.h +0 -6738
  57. package/android/src/main/cpp/libyuv/include/libyuv/row_sve.h +0 -2154
  58. package/android/src/main/cpp/libyuv/include/libyuv/scale.h +0 -336
  59. package/android/src/main/cpp/libyuv/include/libyuv/scale_argb.h +0 -76
  60. package/android/src/main/cpp/libyuv/include/libyuv/scale_rgb.h +0 -42
  61. package/android/src/main/cpp/libyuv/include/libyuv/scale_row.h +0 -1726
  62. package/android/src/main/cpp/libyuv/include/libyuv/scale_uv.h +0 -51
  63. package/android/src/main/cpp/libyuv/include/libyuv/version.h +0 -16
  64. package/android/src/main/cpp/libyuv/include/libyuv/video_common.h +0 -222
  65. package/android/src/main/cpp/libyuv/include/libyuv.h +0 -33
  66. package/android/src/main/cpp/libyuv/infra/config/OWNERS +0 -3
  67. package/android/src/main/cpp/libyuv/infra/config/PRESUBMIT.py +0 -17
  68. package/android/src/main/cpp/libyuv/infra/config/README.md +0 -2
  69. package/android/src/main/cpp/libyuv/infra/config/codereview.settings +0 -6
  70. package/android/src/main/cpp/libyuv/infra/config/commit-queue.cfg +0 -144
  71. package/android/src/main/cpp/libyuv/infra/config/cr-buildbucket.cfg +0 -1185
  72. package/android/src/main/cpp/libyuv/infra/config/luci-logdog.cfg +0 -9
  73. package/android/src/main/cpp/libyuv/infra/config/luci-milo.cfg +0 -246
  74. package/android/src/main/cpp/libyuv/infra/config/luci-scheduler.cfg +0 -385
  75. package/android/src/main/cpp/libyuv/infra/config/main.star +0 -402
  76. package/android/src/main/cpp/libyuv/infra/config/project.cfg +0 -16
  77. package/android/src/main/cpp/libyuv/infra/config/realms.cfg +0 -111
  78. package/android/src/main/cpp/libyuv/libyuv.gni +0 -34
  79. package/android/src/main/cpp/libyuv/libyuv.gyp +0 -149
  80. package/android/src/main/cpp/libyuv/libyuv.gypi +0 -87
  81. package/android/src/main/cpp/libyuv/linux.mk +0 -96
  82. package/android/src/main/cpp/libyuv/public.mk +0 -13
  83. package/android/src/main/cpp/libyuv/pylintrc +0 -49
  84. package/android/src/main/cpp/libyuv/riscv_script/prepare_toolchain_qemu.sh +0 -74
  85. package/android/src/main/cpp/libyuv/riscv_script/riscv-clang.cmake +0 -56
  86. package/android/src/main/cpp/libyuv/riscv_script/run_qemu.sh +0 -15
  87. package/android/src/main/cpp/libyuv/source/compare.cc +0 -435
  88. package/android/src/main/cpp/libyuv/source/compare_common.cc +0 -74
  89. package/android/src/main/cpp/libyuv/source/compare_gcc.cc +0 -362
  90. package/android/src/main/cpp/libyuv/source/compare_neon.cc +0 -96
  91. package/android/src/main/cpp/libyuv/source/compare_neon64.cc +0 -223
  92. package/android/src/main/cpp/libyuv/source/compare_win.cc +0 -241
  93. package/android/src/main/cpp/libyuv/source/convert.cc +0 -4746
  94. package/android/src/main/cpp/libyuv/source/convert_argb.cc +0 -9179
  95. package/android/src/main/cpp/libyuv/source/convert_from.cc +0 -866
  96. package/android/src/main/cpp/libyuv/source/convert_from_argb.cc +0 -3671
  97. package/android/src/main/cpp/libyuv/source/convert_jpeg.cc +0 -602
  98. package/android/src/main/cpp/libyuv/source/convert_to_argb.cc +0 -391
  99. package/android/src/main/cpp/libyuv/source/convert_to_i420.cc +0 -288
  100. package/android/src/main/cpp/libyuv/source/cpu_id.cc +0 -496
  101. package/android/src/main/cpp/libyuv/source/mjpeg_decoder.cc +0 -580
  102. package/android/src/main/cpp/libyuv/source/mjpeg_validate.cc +0 -71
  103. package/android/src/main/cpp/libyuv/source/planar_functions.cc +0 -5663
  104. package/android/src/main/cpp/libyuv/source/rotate.cc +0 -1241
  105. package/android/src/main/cpp/libyuv/source/rotate_any.cc +0 -76
  106. package/android/src/main/cpp/libyuv/source/rotate_argb.cc +0 -259
  107. package/android/src/main/cpp/libyuv/source/rotate_common.cc +0 -208
  108. package/android/src/main/cpp/libyuv/source/rotate_gcc.cc +0 -505
  109. package/android/src/main/cpp/libyuv/source/rotate_lsx.cc +0 -233
  110. package/android/src/main/cpp/libyuv/source/rotate_neon.cc +0 -219
  111. package/android/src/main/cpp/libyuv/source/rotate_neon64.cc +0 -273
  112. package/android/src/main/cpp/libyuv/source/rotate_sme.cc +0 -174
  113. package/android/src/main/cpp/libyuv/source/rotate_win.cc +0 -253
  114. package/android/src/main/cpp/libyuv/source/row_any.cc +0 -2519
  115. package/android/src/main/cpp/libyuv/source/row_common.cc +0 -4461
  116. package/android/src/main/cpp/libyuv/source/row_gcc.cc +0 -9570
  117. package/android/src/main/cpp/libyuv/source/row_lasx.cc +0 -2343
  118. package/android/src/main/cpp/libyuv/source/row_lsx.cc +0 -3030
  119. package/android/src/main/cpp/libyuv/source/row_neon.cc +0 -4026
  120. package/android/src/main/cpp/libyuv/source/row_neon64.cc +0 -5617
  121. package/android/src/main/cpp/libyuv/source/row_rvv.cc +0 -2599
  122. package/android/src/main/cpp/libyuv/source/row_sme.cc +0 -1183
  123. package/android/src/main/cpp/libyuv/source/row_sve.cc +0 -1088
  124. package/android/src/main/cpp/libyuv/source/row_win.cc +0 -6453
  125. package/android/src/main/cpp/libyuv/source/scale.cc +0 -2710
  126. package/android/src/main/cpp/libyuv/source/scale_any.cc +0 -991
  127. package/android/src/main/cpp/libyuv/source/scale_argb.cc +0 -1158
  128. package/android/src/main/cpp/libyuv/source/scale_common.cc +0 -1977
  129. package/android/src/main/cpp/libyuv/source/scale_gcc.cc +0 -2947
  130. package/android/src/main/cpp/libyuv/source/scale_lsx.cc +0 -739
  131. package/android/src/main/cpp/libyuv/source/scale_neon.cc +0 -1449
  132. package/android/src/main/cpp/libyuv/source/scale_neon64.cc +0 -1552
  133. package/android/src/main/cpp/libyuv/source/scale_rgb.cc +0 -82
  134. package/android/src/main/cpp/libyuv/source/scale_rvv.cc +0 -1971
  135. package/android/src/main/cpp/libyuv/source/scale_sme.cc +0 -555
  136. package/android/src/main/cpp/libyuv/source/scale_uv.cc +0 -1159
  137. package/android/src/main/cpp/libyuv/source/scale_win.cc +0 -1392
  138. package/android/src/main/cpp/libyuv/source/test.sh +0 -35
  139. package/android/src/main/cpp/libyuv/source/video_common.cc +0 -62
  140. package/android/src/main/cpp/libyuv/tools_libyuv/OWNERS +0 -4
  141. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/roll_deps.py +0 -931
  142. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/roll_deps_test.py +0 -164
  143. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS +0 -21
  144. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.new +0 -13
  145. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.old +0 -13
  146. package/android/src/main/cpp/libyuv/tools_libyuv/get_landmines.py +0 -38
  147. package/android/src/main/cpp/libyuv/tools_libyuv/msan/OWNERS +0 -3
  148. package/android/src/main/cpp/libyuv/tools_libyuv/msan/blacklist.txt +0 -9
  149. package/android/src/main/cpp/libyuv/tools_libyuv/ubsan/OWNERS +0 -3
  150. package/android/src/main/cpp/libyuv/tools_libyuv/ubsan/blacklist.txt +0 -15
  151. package/android/src/main/cpp/libyuv/tools_libyuv/ubsan/vptr_blacklist.txt +0 -25
  152. package/android/src/main/cpp/libyuv/unit_test/basictypes_test.cc +0 -43
  153. package/android/src/main/cpp/libyuv/unit_test/color_test.cc +0 -848
  154. package/android/src/main/cpp/libyuv/unit_test/compare_test.cc +0 -739
  155. package/android/src/main/cpp/libyuv/unit_test/convert_argb_test.cc +0 -2867
  156. package/android/src/main/cpp/libyuv/unit_test/convert_test.cc +0 -2133
  157. package/android/src/main/cpp/libyuv/unit_test/cpu_test.cc +0 -427
  158. package/android/src/main/cpp/libyuv/unit_test/cpu_thread_test.cc +0 -63
  159. package/android/src/main/cpp/libyuv/unit_test/math_test.cc +0 -160
  160. package/android/src/main/cpp/libyuv/unit_test/planar_test.cc +0 -4731
  161. package/android/src/main/cpp/libyuv/unit_test/rotate_argb_test.cc +0 -334
  162. package/android/src/main/cpp/libyuv/unit_test/rotate_test.cc +0 -962
  163. package/android/src/main/cpp/libyuv/unit_test/scale_argb_test.cc +0 -590
  164. package/android/src/main/cpp/libyuv/unit_test/scale_plane_test.cc +0 -465
  165. package/android/src/main/cpp/libyuv/unit_test/scale_rgb_test.cc +0 -280
  166. package/android/src/main/cpp/libyuv/unit_test/scale_test.cc +0 -1135
  167. package/android/src/main/cpp/libyuv/unit_test/scale_uv_test.cc +0 -249
  168. package/android/src/main/cpp/libyuv/unit_test/testdata/arm_v7.txt +0 -12
  169. package/android/src/main/cpp/libyuv/unit_test/testdata/mips.txt +0 -7
  170. package/android/src/main/cpp/libyuv/unit_test/testdata/mips_loongson2k.txt +0 -5
  171. package/android/src/main/cpp/libyuv/unit_test/testdata/mips_loongson3.txt +0 -10
  172. package/android/src/main/cpp/libyuv/unit_test/testdata/mips_loongson_mmi.txt +0 -7
  173. package/android/src/main/cpp/libyuv/unit_test/testdata/riscv64.txt +0 -4
  174. package/android/src/main/cpp/libyuv/unit_test/testdata/riscv64_rvv.txt +0 -4
  175. package/android/src/main/cpp/libyuv/unit_test/testdata/riscv64_rvv_zvfh.txt +0 -4
  176. package/android/src/main/cpp/libyuv/unit_test/testdata/tegra3.txt +0 -23
  177. package/android/src/main/cpp/libyuv/unit_test/testdata/test0.jpg +0 -0
  178. package/android/src/main/cpp/libyuv/unit_test/testdata/test1.jpg +0 -0
  179. package/android/src/main/cpp/libyuv/unit_test/testdata/test2.jpg +0 -0
  180. package/android/src/main/cpp/libyuv/unit_test/testdata/test3.jpg +0 -0
  181. package/android/src/main/cpp/libyuv/unit_test/testdata/test4.jpg +0 -0
  182. package/android/src/main/cpp/libyuv/unit_test/unit_test.cc +0 -581
  183. package/android/src/main/cpp/libyuv/unit_test/unit_test.h +0 -232
  184. package/android/src/main/cpp/libyuv/unit_test/video_common_test.cc +0 -112
  185. package/android/src/main/cpp/libyuv/util/Makefile +0 -9
  186. package/android/src/main/cpp/libyuv/util/color.cc +0 -120
  187. package/android/src/main/cpp/libyuv/util/compare.cc +0 -67
  188. package/android/src/main/cpp/libyuv/util/cpuid.c +0 -211
  189. package/android/src/main/cpp/libyuv/util/i444tonv12_eg.cc +0 -28
  190. package/android/src/main/cpp/libyuv/util/psnr.cc +0 -291
  191. package/android/src/main/cpp/libyuv/util/psnr.h +0 -47
  192. package/android/src/main/cpp/libyuv/util/psnr_main.cc +0 -620
  193. package/android/src/main/cpp/libyuv/util/ssim.cc +0 -364
  194. package/android/src/main/cpp/libyuv/util/ssim.h +0 -38
  195. package/android/src/main/cpp/libyuv/util/yuvconstants.c +0 -114
  196. package/android/src/main/cpp/libyuv/util/yuvconvert.cc +0 -367
  197. package/android/src/main/cpp/libyuv/winarm.mk +0 -47
  198. package/android/src/main/java/com/faceantispoof/ByteBufferPool.kt +0 -68
  199. package/android/src/main/java/com/faceantispoof/FastYuv.kt +0 -51
  200. package/android/src/main/java/com/faceantispoof/YuvToFloatArrayConverter.kt +0 -584
  201. package/android/src/main/java/com/faceantispoof/YuvToRgbConverter.kt +0 -73
@@ -1,2343 +0,0 @@
1
- /*
2
- * Copyright 2022 The LibYuv Project Authors. All rights reserved.
3
- *
4
- * Copyright (c) 2022 Loongson Technology Corporation Limited
5
- *
6
- * Use of this source code is governed by a BSD-style license
7
- * that can be found in the LICENSE file in the root of the source
8
- * tree. An additional intellectual property rights grant can be found
9
- * in the file PATENTS. All contributing project authors may
10
- * be found in the AUTHORS file in the root of the source tree.
11
- */
12
-
13
- #include "libyuv/row.h"
14
-
15
- #if !defined(LIBYUV_DISABLE_LASX) && defined(__loongarch_asx)
16
- #include "libyuv/loongson_intrinsics.h"
17
-
18
- #ifdef __cplusplus
19
- namespace libyuv {
20
- extern "C" {
21
- #endif
22
-
23
- #define ALPHA_VAL (-1)
24
-
25
- // Fill YUV -> RGB conversion constants into vectors
26
- #define YUVTORGB_SETUP(yuvconst, ub, vr, ug, vg, yg, yb) \
27
- { \
28
- ub = __lasx_xvreplgr2vr_h(yuvconst->kUVToB[0]); \
29
- vr = __lasx_xvreplgr2vr_h(yuvconst->kUVToR[1]); \
30
- ug = __lasx_xvreplgr2vr_h(yuvconst->kUVToG[0]); \
31
- vg = __lasx_xvreplgr2vr_h(yuvconst->kUVToG[1]); \
32
- yg = __lasx_xvreplgr2vr_h(yuvconst->kYToRgb[0]); \
33
- yb = __lasx_xvreplgr2vr_w(yuvconst->kYBiasToRgb[0]); \
34
- }
35
-
36
- // Load 32 YUV422 pixel data
37
- #define READYUV422_D(psrc_y, psrc_u, psrc_v, out_y, uv_l, uv_h) \
38
- { \
39
- __m256i temp0, temp1; \
40
- \
41
- DUP2_ARG2(__lasx_xvld, psrc_y, 0, psrc_u, 0, out_y, temp0); \
42
- temp1 = __lasx_xvld(psrc_v, 0); \
43
- temp0 = __lasx_xvsub_b(temp0, const_0x80); \
44
- temp1 = __lasx_xvsub_b(temp1, const_0x80); \
45
- temp0 = __lasx_vext2xv_h_b(temp0); \
46
- temp1 = __lasx_vext2xv_h_b(temp1); \
47
- uv_l = __lasx_xvilvl_h(temp0, temp1); \
48
- uv_h = __lasx_xvilvh_h(temp0, temp1); \
49
- }
50
-
51
- // Load 16 YUV422 pixel data
52
- #define READYUV422(psrc_y, psrc_u, psrc_v, out_y, uv) \
53
- { \
54
- __m256i temp0, temp1; \
55
- \
56
- out_y = __lasx_xvld(psrc_y, 0); \
57
- temp0 = __lasx_xvldrepl_d(psrc_u, 0); \
58
- temp1 = __lasx_xvldrepl_d(psrc_v, 0); \
59
- uv = __lasx_xvilvl_b(temp0, temp1); \
60
- uv = __lasx_xvsub_b(uv, const_0x80); \
61
- uv = __lasx_vext2xv_h_b(uv); \
62
- }
63
-
64
- // Convert 16 pixels of YUV420 to RGB.
65
- #define YUVTORGB_D(in_y, in_uvl, in_uvh, ubvr, ugvg, yg, yb, b_l, b_h, g_l, \
66
- g_h, r_l, r_h) \
67
- { \
68
- __m256i u_l, u_h, v_l, v_h; \
69
- __m256i yl_ev, yl_od, yh_ev, yh_od; \
70
- __m256i temp0, temp1, temp2, temp3; \
71
- \
72
- temp0 = __lasx_xvilvl_b(in_y, in_y); \
73
- temp1 = __lasx_xvilvh_b(in_y, in_y); \
74
- yl_ev = __lasx_xvmulwev_w_hu_h(temp0, yg); \
75
- yl_od = __lasx_xvmulwod_w_hu_h(temp0, yg); \
76
- yh_ev = __lasx_xvmulwev_w_hu_h(temp1, yg); \
77
- yh_od = __lasx_xvmulwod_w_hu_h(temp1, yg); \
78
- DUP4_ARG2(__lasx_xvsrai_w, yl_ev, 16, yl_od, 16, yh_ev, 16, yh_od, 16, \
79
- yl_ev, yl_od, yh_ev, yh_od); \
80
- yl_ev = __lasx_xvadd_w(yl_ev, yb); \
81
- yl_od = __lasx_xvadd_w(yl_od, yb); \
82
- yh_ev = __lasx_xvadd_w(yh_ev, yb); \
83
- yh_od = __lasx_xvadd_w(yh_od, yb); \
84
- v_l = __lasx_xvmulwev_w_h(in_uvl, ubvr); \
85
- u_l = __lasx_xvmulwod_w_h(in_uvl, ubvr); \
86
- v_h = __lasx_xvmulwev_w_h(in_uvh, ubvr); \
87
- u_h = __lasx_xvmulwod_w_h(in_uvh, ubvr); \
88
- temp0 = __lasx_xvadd_w(yl_ev, u_l); \
89
- temp1 = __lasx_xvadd_w(yl_od, u_l); \
90
- temp2 = __lasx_xvadd_w(yh_ev, u_h); \
91
- temp3 = __lasx_xvadd_w(yh_od, u_h); \
92
- DUP4_ARG2(__lasx_xvsrai_w, temp0, 6, temp1, 6, temp2, 6, temp3, 6, temp0, \
93
- temp1, temp2, temp3); \
94
- DUP4_ARG1(__lasx_xvclip255_w, temp0, temp1, temp2, temp3, temp0, temp1, \
95
- temp2, temp3); \
96
- b_l = __lasx_xvpackev_h(temp1, temp0); \
97
- b_h = __lasx_xvpackev_h(temp3, temp2); \
98
- temp0 = __lasx_xvadd_w(yl_ev, v_l); \
99
- temp1 = __lasx_xvadd_w(yl_od, v_l); \
100
- temp2 = __lasx_xvadd_w(yh_ev, v_h); \
101
- temp3 = __lasx_xvadd_w(yh_od, v_h); \
102
- DUP4_ARG2(__lasx_xvsrai_w, temp0, 6, temp1, 6, temp2, 6, temp3, 6, temp0, \
103
- temp1, temp2, temp3); \
104
- DUP4_ARG1(__lasx_xvclip255_w, temp0, temp1, temp2, temp3, temp0, temp1, \
105
- temp2, temp3); \
106
- r_l = __lasx_xvpackev_h(temp1, temp0); \
107
- r_h = __lasx_xvpackev_h(temp3, temp2); \
108
- DUP2_ARG2(__lasx_xvdp2_w_h, in_uvl, ugvg, in_uvh, ugvg, u_l, u_h); \
109
- temp0 = __lasx_xvsub_w(yl_ev, u_l); \
110
- temp1 = __lasx_xvsub_w(yl_od, u_l); \
111
- temp2 = __lasx_xvsub_w(yh_ev, u_h); \
112
- temp3 = __lasx_xvsub_w(yh_od, u_h); \
113
- DUP4_ARG2(__lasx_xvsrai_w, temp0, 6, temp1, 6, temp2, 6, temp3, 6, temp0, \
114
- temp1, temp2, temp3); \
115
- DUP4_ARG1(__lasx_xvclip255_w, temp0, temp1, temp2, temp3, temp0, temp1, \
116
- temp2, temp3); \
117
- g_l = __lasx_xvpackev_h(temp1, temp0); \
118
- g_h = __lasx_xvpackev_h(temp3, temp2); \
119
- }
120
-
121
- // Convert 8 pixels of YUV420 to RGB.
122
- #define YUVTORGB(in_y, in_uv, ubvr, ugvg, yg, yb, out_b, out_g, out_r) \
123
- { \
124
- __m256i u_l, v_l, yl_ev, yl_od; \
125
- __m256i temp0, temp1; \
126
- \
127
- in_y = __lasx_xvpermi_d(in_y, 0xD8); \
128
- temp0 = __lasx_xvilvl_b(in_y, in_y); \
129
- yl_ev = __lasx_xvmulwev_w_hu_h(temp0, yg); \
130
- yl_od = __lasx_xvmulwod_w_hu_h(temp0, yg); \
131
- DUP2_ARG2(__lasx_xvsrai_w, yl_ev, 16, yl_od, 16, yl_ev, yl_od); \
132
- yl_ev = __lasx_xvadd_w(yl_ev, yb); \
133
- yl_od = __lasx_xvadd_w(yl_od, yb); \
134
- v_l = __lasx_xvmulwev_w_h(in_uv, ubvr); \
135
- u_l = __lasx_xvmulwod_w_h(in_uv, ubvr); \
136
- temp0 = __lasx_xvadd_w(yl_ev, u_l); \
137
- temp1 = __lasx_xvadd_w(yl_od, u_l); \
138
- DUP2_ARG2(__lasx_xvsrai_w, temp0, 6, temp1, 6, temp0, temp1); \
139
- DUP2_ARG1(__lasx_xvclip255_w, temp0, temp1, temp0, temp1); \
140
- out_b = __lasx_xvpackev_h(temp1, temp0); \
141
- temp0 = __lasx_xvadd_w(yl_ev, v_l); \
142
- temp1 = __lasx_xvadd_w(yl_od, v_l); \
143
- DUP2_ARG2(__lasx_xvsrai_w, temp0, 6, temp1, 6, temp0, temp1); \
144
- DUP2_ARG1(__lasx_xvclip255_w, temp0, temp1, temp0, temp1); \
145
- out_r = __lasx_xvpackev_h(temp1, temp0); \
146
- u_l = __lasx_xvdp2_w_h(in_uv, ugvg); \
147
- temp0 = __lasx_xvsub_w(yl_ev, u_l); \
148
- temp1 = __lasx_xvsub_w(yl_od, u_l); \
149
- DUP2_ARG2(__lasx_xvsrai_w, temp0, 6, temp1, 6, temp0, temp1); \
150
- DUP2_ARG1(__lasx_xvclip255_w, temp0, temp1, temp0, temp1); \
151
- out_g = __lasx_xvpackev_h(temp1, temp0); \
152
- }
153
-
154
- // Pack and Store 16 ARGB values.
155
- #define STOREARGB_D(a_l, a_h, r_l, r_h, g_l, g_h, b_l, b_h, pdst_argb) \
156
- { \
157
- __m256i temp0, temp1, temp2, temp3; \
158
- \
159
- temp0 = __lasx_xvpackev_b(g_l, b_l); \
160
- temp1 = __lasx_xvpackev_b(a_l, r_l); \
161
- temp2 = __lasx_xvpackev_b(g_h, b_h); \
162
- temp3 = __lasx_xvpackev_b(a_h, r_h); \
163
- r_l = __lasx_xvilvl_h(temp1, temp0); \
164
- r_h = __lasx_xvilvh_h(temp1, temp0); \
165
- g_l = __lasx_xvilvl_h(temp3, temp2); \
166
- g_h = __lasx_xvilvh_h(temp3, temp2); \
167
- temp0 = __lasx_xvpermi_q(r_h, r_l, 0x20); \
168
- temp1 = __lasx_xvpermi_q(g_h, g_l, 0x20); \
169
- temp2 = __lasx_xvpermi_q(r_h, r_l, 0x31); \
170
- temp3 = __lasx_xvpermi_q(g_h, g_l, 0x31); \
171
- __lasx_xvst(temp0, pdst_argb, 0); \
172
- __lasx_xvst(temp1, pdst_argb, 32); \
173
- __lasx_xvst(temp2, pdst_argb, 64); \
174
- __lasx_xvst(temp3, pdst_argb, 96); \
175
- pdst_argb += 128; \
176
- }
177
-
178
- // Pack and Store 8 ARGB values.
179
- #define STOREARGB(in_a, in_r, in_g, in_b, pdst_argb) \
180
- { \
181
- __m256i temp0, temp1, temp2, temp3; \
182
- \
183
- temp0 = __lasx_xvpackev_b(in_g, in_b); \
184
- temp1 = __lasx_xvpackev_b(in_a, in_r); \
185
- temp2 = __lasx_xvilvl_h(temp1, temp0); \
186
- temp3 = __lasx_xvilvh_h(temp1, temp0); \
187
- temp0 = __lasx_xvpermi_q(temp3, temp2, 0x20); \
188
- temp1 = __lasx_xvpermi_q(temp3, temp2, 0x31); \
189
- __lasx_xvst(temp0, pdst_argb, 0); \
190
- __lasx_xvst(temp1, pdst_argb, 32); \
191
- pdst_argb += 64; \
192
- }
193
-
194
- #define RGBTOUV(_tmpb, _tmpg, _tmpr, _nexb, _nexg, _nexr, _reg0, _reg1) \
195
- { \
196
- __m256i _tmp0, _tmp1, _tmp2, _tmp3, _tmp4, _tmp5; \
197
- _tmp0 = __lasx_xvaddwev_h_bu(_tmpb, _nexb); \
198
- _tmp1 = __lasx_xvaddwod_h_bu(_tmpb, _nexb); \
199
- _tmp2 = __lasx_xvaddwev_h_bu(_tmpg, _nexg); \
200
- _tmp3 = __lasx_xvaddwod_h_bu(_tmpg, _nexg); \
201
- _reg0 = __lasx_xvaddwev_h_bu(_tmpr, _nexr); \
202
- _reg1 = __lasx_xvaddwod_h_bu(_tmpr, _nexr); \
203
- _tmp4 = __lasx_xvaddwev_w_hu(_tmp0, _tmp1); \
204
- _tmp5 = __lasx_xvaddwod_w_hu(_tmp0, _tmp1); \
205
- _tmp0 = __lasx_xvilvl_w(_tmp5, _tmp4); \
206
- _tmp1 = __lasx_xvilvh_w(_tmp5, _tmp4); \
207
- _tmpb = __lasx_xvssrarni_hu_w(_tmp1, _tmp0, 2); \
208
- _tmp4 = __lasx_xvaddwev_w_hu(_tmp2, _tmp3); \
209
- _tmp5 = __lasx_xvaddwod_w_hu(_tmp2, _tmp3); \
210
- _tmp2 = __lasx_xvilvl_w(_tmp5, _tmp4); \
211
- _tmp3 = __lasx_xvilvh_w(_tmp5, _tmp4); \
212
- _tmpg = __lasx_xvssrarni_hu_w(_tmp3, _tmp2, 2); \
213
- _tmp4 = __lasx_xvaddwev_w_hu(_reg0, _reg1); \
214
- _tmp5 = __lasx_xvaddwod_w_hu(_reg0, _reg1); \
215
- _tmp0 = __lasx_xvilvl_w(_tmp5, _tmp4); \
216
- _tmp1 = __lasx_xvilvh_w(_tmp5, _tmp4); \
217
- _tmpr = __lasx_xvssrarni_hu_w(_tmp1, _tmp0, 2); \
218
- _reg0 = __lasx_xvmadd_h(const_8000, const_112, _tmpb); \
219
- _reg1 = __lasx_xvmadd_h(const_8000, const_112, _tmpr); \
220
- _reg0 = __lasx_xvmsub_h(_reg0, const_74, _tmpg); \
221
- _reg1 = __lasx_xvmsub_h(_reg1, const_94, _tmpg); \
222
- _reg0 = __lasx_xvmsub_h(_reg0, const_38, _tmpr); \
223
- _reg1 = __lasx_xvmsub_h(_reg1, const_18, _tmpb); \
224
- }
225
-
226
- void MirrorRow_LASX(const uint8_t* src, uint8_t* dst, int width) {
227
- int x;
228
- int len = width / 64;
229
- __m256i src0, src1;
230
- __m256i shuffler = {0x08090A0B0C0D0E0F, 0x0001020304050607,
231
- 0x08090A0B0C0D0E0F, 0x0001020304050607};
232
- src += width - 64;
233
- for (x = 0; x < len; x++) {
234
- DUP2_ARG2(__lasx_xvld, src, 0, src, 32, src0, src1);
235
- DUP2_ARG3(__lasx_xvshuf_b, src0, src0, shuffler, src1, src1, shuffler, src0,
236
- src1);
237
- src0 = __lasx_xvpermi_q(src0, src0, 0x01);
238
- src1 = __lasx_xvpermi_q(src1, src1, 0x01);
239
- __lasx_xvst(src1, dst, 0);
240
- __lasx_xvst(src0, dst, 32);
241
- dst += 64;
242
- src -= 64;
243
- }
244
- }
245
-
246
- void MirrorUVRow_LASX(const uint8_t* src_uv, uint8_t* dst_uv, int width) {
247
- int x;
248
- int len = width / 16;
249
- __m256i src, dst;
250
- __m256i shuffler = {0x0004000500060007, 0x0000000100020003,
251
- 0x0004000500060007, 0x0000000100020003};
252
-
253
- src_uv += (width - 16) << 1;
254
- for (x = 0; x < len; x++) {
255
- src = __lasx_xvld(src_uv, 0);
256
- dst = __lasx_xvshuf_h(shuffler, src, src);
257
- dst = __lasx_xvpermi_q(dst, dst, 0x01);
258
- __lasx_xvst(dst, dst_uv, 0);
259
- src_uv -= 32;
260
- dst_uv += 32;
261
- }
262
- }
263
-
264
- void ARGBMirrorRow_LASX(const uint8_t* src, uint8_t* dst, int width) {
265
- int x;
266
- int len = width / 16;
267
- __m256i src0, src1;
268
- __m256i dst0, dst1;
269
- __m256i shuffler = {0x0B0A09080F0E0D0C, 0x0302010007060504,
270
- 0x0B0A09080F0E0D0C, 0x0302010007060504};
271
- src += (width * 4) - 64;
272
- for (x = 0; x < len; x++) {
273
- DUP2_ARG2(__lasx_xvld, src, 0, src, 32, src0, src1);
274
- DUP2_ARG3(__lasx_xvshuf_b, src0, src0, shuffler, src1, src1, shuffler, src0,
275
- src1);
276
- dst1 = __lasx_xvpermi_q(src0, src0, 0x01);
277
- dst0 = __lasx_xvpermi_q(src1, src1, 0x01);
278
- __lasx_xvst(dst0, dst, 0);
279
- __lasx_xvst(dst1, dst, 32);
280
- dst += 64;
281
- src -= 64;
282
- }
283
- }
284
-
285
- void I422ToYUY2Row_LASX(const uint8_t* src_y,
286
- const uint8_t* src_u,
287
- const uint8_t* src_v,
288
- uint8_t* dst_yuy2,
289
- int width) {
290
- int x;
291
- int len = width / 32;
292
- __m256i src_u0, src_v0, src_y0, vec_uv0;
293
- __m256i vec_yuy2_0, vec_yuy2_1;
294
- __m256i dst_yuy2_0, dst_yuy2_1;
295
-
296
- for (x = 0; x < len; x++) {
297
- DUP2_ARG2(__lasx_xvld, src_u, 0, src_v, 0, src_u0, src_v0);
298
- src_y0 = __lasx_xvld(src_y, 0);
299
- src_u0 = __lasx_xvpermi_d(src_u0, 0xD8);
300
- src_v0 = __lasx_xvpermi_d(src_v0, 0xD8);
301
- vec_uv0 = __lasx_xvilvl_b(src_v0, src_u0);
302
- vec_yuy2_0 = __lasx_xvilvl_b(vec_uv0, src_y0);
303
- vec_yuy2_1 = __lasx_xvilvh_b(vec_uv0, src_y0);
304
- dst_yuy2_0 = __lasx_xvpermi_q(vec_yuy2_1, vec_yuy2_0, 0x20);
305
- dst_yuy2_1 = __lasx_xvpermi_q(vec_yuy2_1, vec_yuy2_0, 0x31);
306
- __lasx_xvst(dst_yuy2_0, dst_yuy2, 0);
307
- __lasx_xvst(dst_yuy2_1, dst_yuy2, 32);
308
- src_u += 16;
309
- src_v += 16;
310
- src_y += 32;
311
- dst_yuy2 += 64;
312
- }
313
- }
314
-
315
- void I422ToUYVYRow_LASX(const uint8_t* src_y,
316
- const uint8_t* src_u,
317
- const uint8_t* src_v,
318
- uint8_t* dst_uyvy,
319
- int width) {
320
- int x;
321
- int len = width / 32;
322
- __m256i src_u0, src_v0, src_y0, vec_uv0;
323
- __m256i vec_uyvy0, vec_uyvy1;
324
- __m256i dst_uyvy0, dst_uyvy1;
325
-
326
- for (x = 0; x < len; x++) {
327
- DUP2_ARG2(__lasx_xvld, src_u, 0, src_v, 0, src_u0, src_v0);
328
- src_y0 = __lasx_xvld(src_y, 0);
329
- src_u0 = __lasx_xvpermi_d(src_u0, 0xD8);
330
- src_v0 = __lasx_xvpermi_d(src_v0, 0xD8);
331
- vec_uv0 = __lasx_xvilvl_b(src_v0, src_u0);
332
- vec_uyvy0 = __lasx_xvilvl_b(src_y0, vec_uv0);
333
- vec_uyvy1 = __lasx_xvilvh_b(src_y0, vec_uv0);
334
- dst_uyvy0 = __lasx_xvpermi_q(vec_uyvy1, vec_uyvy0, 0x20);
335
- dst_uyvy1 = __lasx_xvpermi_q(vec_uyvy1, vec_uyvy0, 0x31);
336
- __lasx_xvst(dst_uyvy0, dst_uyvy, 0);
337
- __lasx_xvst(dst_uyvy1, dst_uyvy, 32);
338
- src_u += 16;
339
- src_v += 16;
340
- src_y += 32;
341
- dst_uyvy += 64;
342
- }
343
- }
344
-
345
- void I422ToARGBRow_LASX(const uint8_t* src_y,
346
- const uint8_t* src_u,
347
- const uint8_t* src_v,
348
- uint8_t* dst_argb,
349
- const struct YuvConstants* yuvconstants,
350
- int width) {
351
- int x;
352
- int len = width / 32;
353
- __m256i vec_yb, vec_yg, vec_ub, vec_ug, vec_vr, vec_vg;
354
- __m256i vec_ubvr, vec_ugvg;
355
- __m256i alpha = __lasx_xvldi(0xFF);
356
- __m256i const_0x80 = __lasx_xvldi(0x80);
357
-
358
- YUVTORGB_SETUP(yuvconstants, vec_ub, vec_vr, vec_ug, vec_vg, vec_yg, vec_yb);
359
- vec_ubvr = __lasx_xvilvl_h(vec_ub, vec_vr);
360
- vec_ugvg = __lasx_xvilvl_h(vec_ug, vec_vg);
361
-
362
- for (x = 0; x < len; x++) {
363
- __m256i y, uv_l, uv_h, b_l, b_h, g_l, g_h, r_l, r_h;
364
-
365
- READYUV422_D(src_y, src_u, src_v, y, uv_l, uv_h);
366
- YUVTORGB_D(y, uv_l, uv_h, vec_ubvr, vec_ugvg, vec_yg, vec_yb, b_l, b_h, g_l,
367
- g_h, r_l, r_h);
368
- STOREARGB_D(alpha, alpha, r_l, r_h, g_l, g_h, b_l, b_h, dst_argb);
369
- src_y += 32;
370
- src_u += 16;
371
- src_v += 16;
372
- }
373
- }
374
-
375
- void I422ToRGBARow_LASX(const uint8_t* src_y,
376
- const uint8_t* src_u,
377
- const uint8_t* src_v,
378
- uint8_t* dst_argb,
379
- const struct YuvConstants* yuvconstants,
380
- int width) {
381
- int x;
382
- int len = width / 32;
383
- __m256i vec_yb, vec_yg, vec_ub, vec_vr, vec_ug, vec_vg;
384
- __m256i vec_ubvr, vec_ugvg;
385
- __m256i alpha = __lasx_xvldi(0xFF);
386
- __m256i const_0x80 = __lasx_xvldi(0x80);
387
-
388
- YUVTORGB_SETUP(yuvconstants, vec_ub, vec_vr, vec_ug, vec_vg, vec_yg, vec_yb);
389
- vec_ubvr = __lasx_xvilvl_h(vec_ub, vec_vr);
390
- vec_ugvg = __lasx_xvilvl_h(vec_ug, vec_vg);
391
-
392
- for (x = 0; x < len; x++) {
393
- __m256i y, uv_l, uv_h, b_l, b_h, g_l, g_h, r_l, r_h;
394
-
395
- READYUV422_D(src_y, src_u, src_v, y, uv_l, uv_h);
396
- YUVTORGB_D(y, uv_l, uv_h, vec_ubvr, vec_ugvg, vec_yg, vec_yb, b_l, b_h, g_l,
397
- g_h, r_l, r_h);
398
- STOREARGB_D(r_l, r_h, g_l, g_h, b_l, b_h, alpha, alpha, dst_argb);
399
- src_y += 32;
400
- src_u += 16;
401
- src_v += 16;
402
- }
403
- }
404
-
405
- void I422AlphaToARGBRow_LASX(const uint8_t* src_y,
406
- const uint8_t* src_u,
407
- const uint8_t* src_v,
408
- const uint8_t* src_a,
409
- uint8_t* dst_argb,
410
- const struct YuvConstants* yuvconstants,
411
- int width) {
412
- int x;
413
- int len = width / 32;
414
- int res = width & 31;
415
- __m256i vec_yb, vec_yg, vec_ub, vec_vr, vec_ug, vec_vg;
416
- __m256i vec_ubvr, vec_ugvg;
417
- __m256i zero = __lasx_xvldi(0);
418
- __m256i const_0x80 = __lasx_xvldi(0x80);
419
-
420
- YUVTORGB_SETUP(yuvconstants, vec_ub, vec_vr, vec_ug, vec_vg, vec_yg, vec_yb);
421
- vec_ubvr = __lasx_xvilvl_h(vec_ub, vec_vr);
422
- vec_ugvg = __lasx_xvilvl_h(vec_ug, vec_vg);
423
-
424
- for (x = 0; x < len; x++) {
425
- __m256i y, uv_l, uv_h, b_l, b_h, g_l, g_h, r_l, r_h, a_l, a_h;
426
-
427
- y = __lasx_xvld(src_a, 0);
428
- a_l = __lasx_xvilvl_b(zero, y);
429
- a_h = __lasx_xvilvh_b(zero, y);
430
- READYUV422_D(src_y, src_u, src_v, y, uv_l, uv_h);
431
- YUVTORGB_D(y, uv_l, uv_h, vec_ubvr, vec_ugvg, vec_yg, vec_yb, b_l, b_h, g_l,
432
- g_h, r_l, r_h);
433
- STOREARGB_D(a_l, a_h, r_l, r_h, g_l, g_h, b_l, b_h, dst_argb);
434
- src_y += 32;
435
- src_u += 16;
436
- src_v += 16;
437
- src_a += 32;
438
- }
439
- if (res) {
440
- __m256i y, uv, r, g, b, a;
441
- a = __lasx_xvld(src_a, 0);
442
- a = __lasx_vext2xv_hu_bu(a);
443
- READYUV422(src_y, src_u, src_v, y, uv);
444
- YUVTORGB(y, uv, vec_ubvr, vec_ugvg, vec_yg, vec_yb, b, g, r);
445
- STOREARGB(a, r, g, b, dst_argb);
446
- }
447
- }
448
-
449
- void I422ToRGB24Row_LASX(const uint8_t* src_y,
450
- const uint8_t* src_u,
451
- const uint8_t* src_v,
452
- uint8_t* dst_argb,
453
- const struct YuvConstants* yuvconstants,
454
- int32_t width) {
455
- int x;
456
- int len = width / 32;
457
- __m256i vec_yb, vec_yg, vec_ub, vec_vr, vec_ug, vec_vg;
458
- __m256i vec_ubvr, vec_ugvg;
459
- __m256i const_0x80 = __lasx_xvldi(0x80);
460
- __m256i shuffler0 = {0x0504120302100100, 0x0A18090816070614,
461
- 0x0504120302100100, 0x0A18090816070614};
462
- __m256i shuffler1 = {0x1E0F0E1C0D0C1A0B, 0x1E0F0E1C0D0C1A0B,
463
- 0x1E0F0E1C0D0C1A0B, 0x1E0F0E1C0D0C1A0B};
464
-
465
- YUVTORGB_SETUP(yuvconstants, vec_ub, vec_vr, vec_ug, vec_vg, vec_yg, vec_yb);
466
- vec_ubvr = __lasx_xvilvl_h(vec_ub, vec_vr);
467
- vec_ugvg = __lasx_xvilvl_h(vec_ug, vec_vg);
468
-
469
- for (x = 0; x < len; x++) {
470
- __m256i y, uv_l, uv_h, b_l, b_h, g_l, g_h, r_l, r_h;
471
- __m256i temp0, temp1, temp2, temp3;
472
-
473
- READYUV422_D(src_y, src_u, src_v, y, uv_l, uv_h);
474
- YUVTORGB_D(y, uv_l, uv_h, vec_ubvr, vec_ugvg, vec_yg, vec_yb, b_l, b_h, g_l,
475
- g_h, r_l, r_h);
476
- temp0 = __lasx_xvpackev_b(g_l, b_l);
477
- temp1 = __lasx_xvpackev_b(g_h, b_h);
478
- DUP4_ARG3(__lasx_xvshuf_b, r_l, temp0, shuffler1, r_h, temp1, shuffler1,
479
- r_l, temp0, shuffler0, r_h, temp1, shuffler0, temp2, temp3, temp0,
480
- temp1);
481
-
482
- b_l = __lasx_xvilvl_d(temp1, temp2);
483
- b_h = __lasx_xvilvh_d(temp3, temp1);
484
- temp1 = __lasx_xvpermi_q(b_l, temp0, 0x20);
485
- temp2 = __lasx_xvpermi_q(temp0, b_h, 0x30);
486
- temp3 = __lasx_xvpermi_q(b_h, b_l, 0x31);
487
- __lasx_xvst(temp1, dst_argb, 0);
488
- __lasx_xvst(temp2, dst_argb, 32);
489
- __lasx_xvst(temp3, dst_argb, 64);
490
- dst_argb += 96;
491
- src_y += 32;
492
- src_u += 16;
493
- src_v += 16;
494
- }
495
- }
496
-
497
- // TODO(fbarchard): Consider AND instead of shift to isolate 5 upper bits of R.
498
- void I422ToRGB565Row_LASX(const uint8_t* src_y,
499
- const uint8_t* src_u,
500
- const uint8_t* src_v,
501
- uint8_t* dst_rgb565,
502
- const struct YuvConstants* yuvconstants,
503
- int width) {
504
- int x;
505
- int len = width / 32;
506
- __m256i vec_yb, vec_yg, vec_ub, vec_vr, vec_ug, vec_vg;
507
- __m256i vec_ubvr, vec_ugvg;
508
- __m256i const_0x80 = __lasx_xvldi(0x80);
509
-
510
- YUVTORGB_SETUP(yuvconstants, vec_ub, vec_vr, vec_ug, vec_vg, vec_yg, vec_yb);
511
- vec_ubvr = __lasx_xvilvl_h(vec_ub, vec_vr);
512
- vec_ugvg = __lasx_xvilvl_h(vec_ug, vec_vg);
513
-
514
- for (x = 0; x < len; x++) {
515
- __m256i y, uv_l, uv_h, b_l, b_h, g_l, g_h, r_l, r_h;
516
- __m256i dst_l, dst_h;
517
-
518
- READYUV422_D(src_y, src_u, src_v, y, uv_l, uv_h);
519
- YUVTORGB_D(y, uv_l, uv_h, vec_ubvr, vec_ugvg, vec_yg, vec_yb, b_l, b_h, g_l,
520
- g_h, r_l, r_h);
521
- b_l = __lasx_xvsrli_h(b_l, 3);
522
- b_h = __lasx_xvsrli_h(b_h, 3);
523
- g_l = __lasx_xvsrli_h(g_l, 2);
524
- g_h = __lasx_xvsrli_h(g_h, 2);
525
- r_l = __lasx_xvsrli_h(r_l, 3);
526
- r_h = __lasx_xvsrli_h(r_h, 3);
527
- r_l = __lasx_xvslli_h(r_l, 11);
528
- r_h = __lasx_xvslli_h(r_h, 11);
529
- g_l = __lasx_xvslli_h(g_l, 5);
530
- g_h = __lasx_xvslli_h(g_h, 5);
531
- r_l = __lasx_xvor_v(r_l, g_l);
532
- r_l = __lasx_xvor_v(r_l, b_l);
533
- r_h = __lasx_xvor_v(r_h, g_h);
534
- r_h = __lasx_xvor_v(r_h, b_h);
535
- dst_l = __lasx_xvpermi_q(r_h, r_l, 0x20);
536
- dst_h = __lasx_xvpermi_q(r_h, r_l, 0x31);
537
- __lasx_xvst(dst_l, dst_rgb565, 0);
538
- __lasx_xvst(dst_h, dst_rgb565, 32);
539
- dst_rgb565 += 64;
540
- src_y += 32;
541
- src_u += 16;
542
- src_v += 16;
543
- }
544
- }
545
-
546
- // TODO(fbarchard): Consider AND instead of shift to isolate 4 upper bits of G.
547
- void I422ToARGB4444Row_LASX(const uint8_t* src_y,
548
- const uint8_t* src_u,
549
- const uint8_t* src_v,
550
- uint8_t* dst_argb4444,
551
- const struct YuvConstants* yuvconstants,
552
- int width) {
553
- int x;
554
- int len = width / 32;
555
- __m256i vec_yb, vec_yg, vec_ub, vec_vr, vec_ug, vec_vg;
556
- __m256i vec_ubvr, vec_ugvg;
557
- __m256i const_0x80 = __lasx_xvldi(0x80);
558
- __m256i alpha = (__m256i)v4u64{0xF000F000F000F000, 0xF000F000F000F000,
559
- 0xF000F000F000F000, 0xF000F000F000F000};
560
- __m256i mask = {0x00F000F000F000F0, 0x00F000F000F000F0, 0x00F000F000F000F0,
561
- 0x00F000F000F000F0};
562
-
563
- YUVTORGB_SETUP(yuvconstants, vec_ub, vec_vr, vec_ug, vec_vg, vec_yg, vec_yb);
564
- vec_ubvr = __lasx_xvilvl_h(vec_ub, vec_vr);
565
- vec_ugvg = __lasx_xvilvl_h(vec_ug, vec_vg);
566
-
567
- for (x = 0; x < len; x++) {
568
- __m256i y, uv_l, uv_h, b_l, b_h, g_l, g_h, r_l, r_h;
569
- __m256i dst_l, dst_h;
570
-
571
- READYUV422_D(src_y, src_u, src_v, y, uv_l, uv_h);
572
- YUVTORGB_D(y, uv_l, uv_h, vec_ubvr, vec_ugvg, vec_yg, vec_yb, b_l, b_h, g_l,
573
- g_h, r_l, r_h);
574
- b_l = __lasx_xvsrli_h(b_l, 4);
575
- b_h = __lasx_xvsrli_h(b_h, 4);
576
- r_l = __lasx_xvsrli_h(r_l, 4);
577
- r_h = __lasx_xvsrli_h(r_h, 4);
578
- g_l = __lasx_xvand_v(g_l, mask);
579
- g_h = __lasx_xvand_v(g_h, mask);
580
- r_l = __lasx_xvslli_h(r_l, 8);
581
- r_h = __lasx_xvslli_h(r_h, 8);
582
- r_l = __lasx_xvor_v(r_l, alpha);
583
- r_h = __lasx_xvor_v(r_h, alpha);
584
- r_l = __lasx_xvor_v(r_l, g_l);
585
- r_h = __lasx_xvor_v(r_h, g_h);
586
- r_l = __lasx_xvor_v(r_l, b_l);
587
- r_h = __lasx_xvor_v(r_h, b_h);
588
- dst_l = __lasx_xvpermi_q(r_h, r_l, 0x20);
589
- dst_h = __lasx_xvpermi_q(r_h, r_l, 0x31);
590
- __lasx_xvst(dst_l, dst_argb4444, 0);
591
- __lasx_xvst(dst_h, dst_argb4444, 32);
592
- dst_argb4444 += 64;
593
- src_y += 32;
594
- src_u += 16;
595
- src_v += 16;
596
- }
597
- }
598
-
599
- void I422ToARGB1555Row_LASX(const uint8_t* src_y,
600
- const uint8_t* src_u,
601
- const uint8_t* src_v,
602
- uint8_t* dst_argb1555,
603
- const struct YuvConstants* yuvconstants,
604
- int width) {
605
- int x;
606
- int len = width / 32;
607
- __m256i vec_yb, vec_yg, vec_ub, vec_vr, vec_ug, vec_vg;
608
- __m256i vec_ubvr, vec_ugvg;
609
- __m256i const_0x80 = __lasx_xvldi(0x80);
610
- __m256i alpha = (__m256i)v4u64{0x8000800080008000, 0x8000800080008000,
611
- 0x8000800080008000, 0x8000800080008000};
612
-
613
- YUVTORGB_SETUP(yuvconstants, vec_ub, vec_vr, vec_ug, vec_vg, vec_yg, vec_yb);
614
- vec_ubvr = __lasx_xvilvl_h(vec_ub, vec_vr);
615
- vec_ugvg = __lasx_xvilvl_h(vec_ug, vec_vg);
616
-
617
- for (x = 0; x < len; x++) {
618
- __m256i y, uv_l, uv_h, b_l, b_h, g_l, g_h, r_l, r_h;
619
- __m256i dst_l, dst_h;
620
-
621
- READYUV422_D(src_y, src_u, src_v, y, uv_l, uv_h);
622
- YUVTORGB_D(y, uv_l, uv_h, vec_ubvr, vec_ugvg, vec_yg, vec_yb, b_l, b_h, g_l,
623
- g_h, r_l, r_h);
624
- b_l = __lasx_xvsrli_h(b_l, 3);
625
- b_h = __lasx_xvsrli_h(b_h, 3);
626
- g_l = __lasx_xvsrli_h(g_l, 3);
627
- g_h = __lasx_xvsrli_h(g_h, 3);
628
- g_l = __lasx_xvslli_h(g_l, 5);
629
- g_h = __lasx_xvslli_h(g_h, 5);
630
- r_l = __lasx_xvsrli_h(r_l, 3);
631
- r_h = __lasx_xvsrli_h(r_h, 3);
632
- r_l = __lasx_xvslli_h(r_l, 10);
633
- r_h = __lasx_xvslli_h(r_h, 10);
634
- r_l = __lasx_xvor_v(r_l, alpha);
635
- r_h = __lasx_xvor_v(r_h, alpha);
636
- r_l = __lasx_xvor_v(r_l, g_l);
637
- r_h = __lasx_xvor_v(r_h, g_h);
638
- r_l = __lasx_xvor_v(r_l, b_l);
639
- r_h = __lasx_xvor_v(r_h, b_h);
640
- dst_l = __lasx_xvpermi_q(r_h, r_l, 0x20);
641
- dst_h = __lasx_xvpermi_q(r_h, r_l, 0x31);
642
- __lasx_xvst(dst_l, dst_argb1555, 0);
643
- __lasx_xvst(dst_h, dst_argb1555, 32);
644
- dst_argb1555 += 64;
645
- src_y += 32;
646
- src_u += 16;
647
- src_v += 16;
648
- }
649
- }
650
-
651
- void YUY2ToYRow_LASX(const uint8_t* src_yuy2, uint8_t* dst_y, int width) {
652
- int x;
653
- int len = width / 32;
654
- __m256i src0, src1, dst0;
655
-
656
- for (x = 0; x < len; x++) {
657
- DUP2_ARG2(__lasx_xvld, src_yuy2, 0, src_yuy2, 32, src0, src1);
658
- dst0 = __lasx_xvpickev_b(src1, src0);
659
- dst0 = __lasx_xvpermi_d(dst0, 0xD8);
660
- __lasx_xvst(dst0, dst_y, 0);
661
- src_yuy2 += 64;
662
- dst_y += 32;
663
- }
664
- }
665
-
666
- void YUY2ToUVRow_LASX(const uint8_t* src_yuy2,
667
- int src_stride_yuy2,
668
- uint8_t* dst_u,
669
- uint8_t* dst_v,
670
- int width) {
671
- const uint8_t* src_yuy2_next = src_yuy2 + src_stride_yuy2;
672
- int x;
673
- int len = width / 32;
674
- __m256i src0, src1, src2, src3;
675
- __m256i tmp0, dst0, dst1;
676
-
677
- for (x = 0; x < len; x++) {
678
- DUP4_ARG2(__lasx_xvld, src_yuy2, 0, src_yuy2, 32, src_yuy2_next, 0,
679
- src_yuy2_next, 32, src0, src1, src2, src3);
680
- src0 = __lasx_xvpickod_b(src1, src0);
681
- src1 = __lasx_xvpickod_b(src3, src2);
682
- tmp0 = __lasx_xvavgr_bu(src1, src0);
683
- tmp0 = __lasx_xvpermi_d(tmp0, 0xD8);
684
- dst0 = __lasx_xvpickev_b(tmp0, tmp0);
685
- dst1 = __lasx_xvpickod_b(tmp0, tmp0);
686
- __lasx_xvstelm_d(dst0, dst_u, 0, 0);
687
- __lasx_xvstelm_d(dst0, dst_u, 8, 2);
688
- __lasx_xvstelm_d(dst1, dst_v, 0, 0);
689
- __lasx_xvstelm_d(dst1, dst_v, 8, 2);
690
- src_yuy2 += 64;
691
- src_yuy2_next += 64;
692
- dst_u += 16;
693
- dst_v += 16;
694
- }
695
- }
696
-
697
- void YUY2ToUV422Row_LASX(const uint8_t* src_yuy2,
698
- uint8_t* dst_u,
699
- uint8_t* dst_v,
700
- int width) {
701
- int x;
702
- int len = width / 32;
703
- __m256i src0, src1, tmp0, dst0, dst1;
704
-
705
- for (x = 0; x < len; x++) {
706
- DUP2_ARG2(__lasx_xvld, src_yuy2, 0, src_yuy2, 32, src0, src1);
707
- tmp0 = __lasx_xvpickod_b(src1, src0);
708
- tmp0 = __lasx_xvpermi_d(tmp0, 0xD8);
709
- dst0 = __lasx_xvpickev_b(tmp0, tmp0);
710
- dst1 = __lasx_xvpickod_b(tmp0, tmp0);
711
- __lasx_xvstelm_d(dst0, dst_u, 0, 0);
712
- __lasx_xvstelm_d(dst0, dst_u, 8, 2);
713
- __lasx_xvstelm_d(dst1, dst_v, 0, 0);
714
- __lasx_xvstelm_d(dst1, dst_v, 8, 2);
715
- src_yuy2 += 64;
716
- dst_u += 16;
717
- dst_v += 16;
718
- }
719
- }
720
-
721
- void UYVYToYRow_LASX(const uint8_t* src_uyvy, uint8_t* dst_y, int width) {
722
- int x;
723
- int len = width / 32;
724
- __m256i src0, src1, dst0;
725
-
726
- for (x = 0; x < len; x++) {
727
- DUP2_ARG2(__lasx_xvld, src_uyvy, 0, src_uyvy, 32, src0, src1);
728
- dst0 = __lasx_xvpickod_b(src1, src0);
729
- dst0 = __lasx_xvpermi_d(dst0, 0xD8);
730
- __lasx_xvst(dst0, dst_y, 0);
731
- src_uyvy += 64;
732
- dst_y += 32;
733
- }
734
- }
735
-
736
- void UYVYToUVRow_LASX(const uint8_t* src_uyvy,
737
- int src_stride_uyvy,
738
- uint8_t* dst_u,
739
- uint8_t* dst_v,
740
- int width) {
741
- const uint8_t* src_uyvy_next = src_uyvy + src_stride_uyvy;
742
- int x;
743
- int len = width / 32;
744
- __m256i src0, src1, src2, src3, tmp0, dst0, dst1;
745
-
746
- for (x = 0; x < len; x++) {
747
- DUP4_ARG2(__lasx_xvld, src_uyvy, 0, src_uyvy, 32, src_uyvy_next, 0,
748
- src_uyvy_next, 32, src0, src1, src2, src3);
749
- src0 = __lasx_xvpickev_b(src1, src0);
750
- src1 = __lasx_xvpickev_b(src3, src2);
751
- tmp0 = __lasx_xvavgr_bu(src1, src0);
752
- tmp0 = __lasx_xvpermi_d(tmp0, 0xD8);
753
- dst0 = __lasx_xvpickev_b(tmp0, tmp0);
754
- dst1 = __lasx_xvpickod_b(tmp0, tmp0);
755
- __lasx_xvstelm_d(dst0, dst_u, 0, 0);
756
- __lasx_xvstelm_d(dst0, dst_u, 8, 2);
757
- __lasx_xvstelm_d(dst1, dst_v, 0, 0);
758
- __lasx_xvstelm_d(dst1, dst_v, 8, 2);
759
- src_uyvy += 64;
760
- src_uyvy_next += 64;
761
- dst_u += 16;
762
- dst_v += 16;
763
- }
764
- }
765
-
766
- void UYVYToUV422Row_LASX(const uint8_t* src_uyvy,
767
- uint8_t* dst_u,
768
- uint8_t* dst_v,
769
- int width) {
770
- int x;
771
- int len = width / 32;
772
- __m256i src0, src1, tmp0, dst0, dst1;
773
-
774
- for (x = 0; x < len; x++) {
775
- DUP2_ARG2(__lasx_xvld, src_uyvy, 0, src_uyvy, 32, src0, src1);
776
- tmp0 = __lasx_xvpickev_b(src1, src0);
777
- tmp0 = __lasx_xvpermi_d(tmp0, 0xD8);
778
- dst0 = __lasx_xvpickev_b(tmp0, tmp0);
779
- dst1 = __lasx_xvpickod_b(tmp0, tmp0);
780
- __lasx_xvstelm_d(dst0, dst_u, 0, 0);
781
- __lasx_xvstelm_d(dst0, dst_u, 8, 2);
782
- __lasx_xvstelm_d(dst1, dst_v, 0, 0);
783
- __lasx_xvstelm_d(dst1, dst_v, 8, 2);
784
- src_uyvy += 64;
785
- dst_u += 16;
786
- dst_v += 16;
787
- }
788
- }
789
-
790
- void ARGBToUVRow_LASX(const uint8_t* src_argb0,
791
- int src_stride_argb,
792
- uint8_t* dst_u,
793
- uint8_t* dst_v,
794
- int width) {
795
- int x;
796
- int len = width / 32;
797
- const uint8_t* src_argb1 = src_argb0 + src_stride_argb;
798
-
799
- __m256i src0, src1, src2, src3, src4, src5, src6, src7;
800
- __m256i vec0, vec1, vec2, vec3;
801
- __m256i tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, dst0, dst1;
802
- __m256i const_0x70 = __lasx_xvldi(0x470);
803
- __m256i const_0x4A = __lasx_xvldi(0x44A);
804
- __m256i const_0x26 = __lasx_xvldi(0x426);
805
- __m256i const_0x5E = __lasx_xvldi(0x45E);
806
- __m256i const_0x12 = __lasx_xvldi(0x412);
807
-
808
- __m256i control = {0x0000000400000000, 0x0000000500000001, 0x0000000600000002,
809
- 0x0000000700000003};
810
- __m256i const_0x8000 = (__m256i)v4u64{0x8000800080008000, 0x8000800080008000,
811
- 0x8000800080008000, 0x8000800080008000};
812
-
813
- for (x = 0; x < len; x++) {
814
- DUP4_ARG2(__lasx_xvld, src_argb0, 0, src_argb0, 32, src_argb0, 64,
815
- src_argb0, 96, src0, src1, src2, src3);
816
- DUP4_ARG2(__lasx_xvld, src_argb1, 0, src_argb1, 32, src_argb1, 64,
817
- src_argb1, 96, src4, src5, src6, src7);
818
- vec0 = __lasx_xvaddwev_h_bu(src0, src4);
819
- vec1 = __lasx_xvaddwev_h_bu(src1, src5);
820
- vec2 = __lasx_xvaddwev_h_bu(src2, src6);
821
- vec3 = __lasx_xvaddwev_h_bu(src3, src7);
822
- tmp0 = __lasx_xvpickev_h(vec1, vec0);
823
- tmp1 = __lasx_xvpickev_h(vec3, vec2);
824
- tmp2 = __lasx_xvpickod_h(vec1, vec0);
825
- tmp3 = __lasx_xvpickod_h(vec3, vec2);
826
- vec0 = __lasx_xvaddwod_h_bu(src0, src4);
827
- vec1 = __lasx_xvaddwod_h_bu(src1, src5);
828
- vec2 = __lasx_xvaddwod_h_bu(src2, src6);
829
- vec3 = __lasx_xvaddwod_h_bu(src3, src7);
830
- tmp4 = __lasx_xvpickev_h(vec1, vec0);
831
- tmp5 = __lasx_xvpickev_h(vec3, vec2);
832
- vec0 = __lasx_xvpickev_h(tmp1, tmp0);
833
- vec1 = __lasx_xvpickod_h(tmp1, tmp0);
834
- src0 = __lasx_xvadd_h(vec0, vec1);
835
- src0 = __lasx_xvsrari_h(src0, 2);
836
- vec0 = __lasx_xvpickev_h(tmp3, tmp2);
837
- vec1 = __lasx_xvpickod_h(tmp3, tmp2);
838
- src1 = __lasx_xvadd_h(vec0, vec1);
839
- src1 = __lasx_xvsrari_h(src1, 2);
840
- vec0 = __lasx_xvpickev_h(tmp5, tmp4);
841
- vec1 = __lasx_xvpickod_h(tmp5, tmp4);
842
- src2 = __lasx_xvadd_h(vec0, vec1);
843
- src2 = __lasx_xvsrari_h(src2, 2);
844
- dst0 = __lasx_xvmadd_h(const_0x8000, src0, const_0x70);
845
- dst0 = __lasx_xvmsub_h(dst0, src2, const_0x4A);
846
- dst0 = __lasx_xvmsub_h(dst0, src1, const_0x26);
847
- dst1 = __lasx_xvmadd_h(const_0x8000, src1, const_0x70);
848
- dst1 = __lasx_xvmsub_h(dst1, src2, const_0x5E);
849
- dst1 = __lasx_xvmsub_h(dst1, src0, const_0x12);
850
- dst0 = __lasx_xvperm_w(dst0, control);
851
- dst1 = __lasx_xvperm_w(dst1, control);
852
- dst0 = __lasx_xvssrani_b_h(dst0, dst0, 8);
853
- dst1 = __lasx_xvssrani_b_h(dst1, dst1, 8);
854
- __lasx_xvstelm_d(dst0, dst_u, 0, 0);
855
- __lasx_xvstelm_d(dst0, dst_u, 8, 2);
856
- __lasx_xvstelm_d(dst1, dst_v, 0, 0);
857
- __lasx_xvstelm_d(dst1, dst_v, 8, 2);
858
- src_argb0 += 128;
859
- src_argb1 += 128;
860
- dst_u += 16;
861
- dst_v += 16;
862
- }
863
- }
864
-
865
- void ARGBToRGB24Row_LASX(const uint8_t* src_argb, uint8_t* dst_rgb, int width) {
866
- int x;
867
- int len = (width / 32) - 1;
868
- __m256i src0, src1, src2, src3;
869
- __m256i tmp0, tmp1, tmp2, tmp3;
870
- __m256i shuf = {0x0908060504020100, 0x000000000E0D0C0A, 0x0908060504020100,
871
- 0x000000000E0D0C0A};
872
- __m256i control = {0x0000000100000000, 0x0000000400000002, 0x0000000600000005,
873
- 0x0000000700000003};
874
- for (x = 0; x < len; x++) {
875
- DUP4_ARG2(__lasx_xvld, src_argb, 0, src_argb, 32, src_argb, 64, src_argb,
876
- 96, src0, src1, src2, src3);
877
- tmp0 = __lasx_xvshuf_b(src0, src0, shuf);
878
- tmp1 = __lasx_xvshuf_b(src1, src1, shuf);
879
- tmp2 = __lasx_xvshuf_b(src2, src2, shuf);
880
- tmp3 = __lasx_xvshuf_b(src3, src3, shuf);
881
- tmp0 = __lasx_xvperm_w(tmp0, control);
882
- tmp1 = __lasx_xvperm_w(tmp1, control);
883
- tmp2 = __lasx_xvperm_w(tmp2, control);
884
- tmp3 = __lasx_xvperm_w(tmp3, control);
885
- __lasx_xvst(tmp0, dst_rgb, 0);
886
- __lasx_xvst(tmp1, dst_rgb, 24);
887
- __lasx_xvst(tmp2, dst_rgb, 48);
888
- __lasx_xvst(tmp3, dst_rgb, 72);
889
- dst_rgb += 96;
890
- src_argb += 128;
891
- }
892
- DUP4_ARG2(__lasx_xvld, src_argb, 0, src_argb, 32, src_argb, 64, src_argb, 96,
893
- src0, src1, src2, src3);
894
- tmp0 = __lasx_xvshuf_b(src0, src0, shuf);
895
- tmp1 = __lasx_xvshuf_b(src1, src1, shuf);
896
- tmp2 = __lasx_xvshuf_b(src2, src2, shuf);
897
- tmp3 = __lasx_xvshuf_b(src3, src3, shuf);
898
- tmp0 = __lasx_xvperm_w(tmp0, control);
899
- tmp1 = __lasx_xvperm_w(tmp1, control);
900
- tmp2 = __lasx_xvperm_w(tmp2, control);
901
- tmp3 = __lasx_xvperm_w(tmp3, control);
902
- __lasx_xvst(tmp0, dst_rgb, 0);
903
- __lasx_xvst(tmp1, dst_rgb, 24);
904
- __lasx_xvst(tmp2, dst_rgb, 48);
905
- dst_rgb += 72;
906
- __lasx_xvstelm_d(tmp3, dst_rgb, 0, 0);
907
- __lasx_xvstelm_d(tmp3, dst_rgb, 8, 1);
908
- __lasx_xvstelm_d(tmp3, dst_rgb, 16, 2);
909
- }
910
-
911
- void ARGBToRAWRow_LASX(const uint8_t* src_argb, uint8_t* dst_rgb, int width) {
912
- int x;
913
- int len = (width / 32) - 1;
914
- __m256i src0, src1, src2, src3;
915
- __m256i tmp0, tmp1, tmp2, tmp3;
916
- __m256i shuf = {0x090A040506000102, 0x000000000C0D0E08, 0x090A040506000102,
917
- 0x000000000C0D0E08};
918
- __m256i control = {0x0000000100000000, 0x0000000400000002, 0x0000000600000005,
919
- 0x0000000700000003};
920
- for (x = 0; x < len; x++) {
921
- DUP4_ARG2(__lasx_xvld, src_argb, 0, src_argb, 32, src_argb, 64, src_argb,
922
- 96, src0, src1, src2, src3);
923
- tmp0 = __lasx_xvshuf_b(src0, src0, shuf);
924
- tmp1 = __lasx_xvshuf_b(src1, src1, shuf);
925
- tmp2 = __lasx_xvshuf_b(src2, src2, shuf);
926
- tmp3 = __lasx_xvshuf_b(src3, src3, shuf);
927
- tmp0 = __lasx_xvperm_w(tmp0, control);
928
- tmp1 = __lasx_xvperm_w(tmp1, control);
929
- tmp2 = __lasx_xvperm_w(tmp2, control);
930
- tmp3 = __lasx_xvperm_w(tmp3, control);
931
- __lasx_xvst(tmp0, dst_rgb, 0);
932
- __lasx_xvst(tmp1, dst_rgb, 24);
933
- __lasx_xvst(tmp2, dst_rgb, 48);
934
- __lasx_xvst(tmp3, dst_rgb, 72);
935
- dst_rgb += 96;
936
- src_argb += 128;
937
- }
938
- DUP4_ARG2(__lasx_xvld, src_argb, 0, src_argb, 32, src_argb, 64, src_argb, 96,
939
- src0, src1, src2, src3);
940
- tmp0 = __lasx_xvshuf_b(src0, src0, shuf);
941
- tmp1 = __lasx_xvshuf_b(src1, src1, shuf);
942
- tmp2 = __lasx_xvshuf_b(src2, src2, shuf);
943
- tmp3 = __lasx_xvshuf_b(src3, src3, shuf);
944
- tmp0 = __lasx_xvperm_w(tmp0, control);
945
- tmp1 = __lasx_xvperm_w(tmp1, control);
946
- tmp2 = __lasx_xvperm_w(tmp2, control);
947
- tmp3 = __lasx_xvperm_w(tmp3, control);
948
- __lasx_xvst(tmp0, dst_rgb, 0);
949
- __lasx_xvst(tmp1, dst_rgb, 24);
950
- __lasx_xvst(tmp2, dst_rgb, 48);
951
- dst_rgb += 72;
952
- __lasx_xvstelm_d(tmp3, dst_rgb, 0, 0);
953
- __lasx_xvstelm_d(tmp3, dst_rgb, 8, 1);
954
- __lasx_xvstelm_d(tmp3, dst_rgb, 16, 2);
955
- }
956
-
957
- void ARGBToRGB565Row_LASX(const uint8_t* src_argb,
958
- uint8_t* dst_rgb,
959
- int width) {
960
- int x;
961
- int len = width / 16;
962
- __m256i zero = __lasx_xvldi(0);
963
- __m256i src0, src1, tmp0, tmp1, dst0;
964
- __m256i shift = {0x0300030003000300, 0x0300030003000300, 0x0300030003000300,
965
- 0x0300030003000300};
966
-
967
- for (x = 0; x < len; x++) {
968
- DUP2_ARG2(__lasx_xvld, src_argb, 0, src_argb, 32, src0, src1);
969
- tmp0 = __lasx_xvpickev_b(src1, src0);
970
- tmp1 = __lasx_xvpickod_b(src1, src0);
971
- tmp0 = __lasx_xvsrli_b(tmp0, 3);
972
- tmp1 = __lasx_xvpackev_b(zero, tmp1);
973
- tmp1 = __lasx_xvsrli_h(tmp1, 2);
974
- tmp0 = __lasx_xvsll_b(tmp0, shift);
975
- tmp1 = __lasx_xvslli_h(tmp1, 5);
976
- dst0 = __lasx_xvor_v(tmp0, tmp1);
977
- dst0 = __lasx_xvpermi_d(dst0, 0xD8);
978
- __lasx_xvst(dst0, dst_rgb, 0);
979
- dst_rgb += 32;
980
- src_argb += 64;
981
- }
982
- }
983
-
984
- void ARGBToARGB1555Row_LASX(const uint8_t* src_argb,
985
- uint8_t* dst_rgb,
986
- int width) {
987
- int x;
988
- int len = width / 16;
989
- __m256i zero = __lasx_xvldi(0);
990
- __m256i src0, src1, tmp0, tmp1, tmp2, tmp3, dst0;
991
- __m256i shift1 = {0x0703070307030703, 0x0703070307030703, 0x0703070307030703,
992
- 0x0703070307030703};
993
- __m256i shift2 = {0x0200020002000200, 0x0200020002000200, 0x0200020002000200,
994
- 0x0200020002000200};
995
-
996
- for (x = 0; x < len; x++) {
997
- DUP2_ARG2(__lasx_xvld, src_argb, 0, src_argb, 32, src0, src1);
998
- tmp0 = __lasx_xvpickev_b(src1, src0);
999
- tmp1 = __lasx_xvpickod_b(src1, src0);
1000
- tmp0 = __lasx_xvsrli_b(tmp0, 3);
1001
- tmp1 = __lasx_xvsrl_b(tmp1, shift1);
1002
- tmp0 = __lasx_xvsll_b(tmp0, shift2);
1003
- tmp2 = __lasx_xvpackev_b(zero, tmp1);
1004
- tmp3 = __lasx_xvpackod_b(zero, tmp1);
1005
- tmp2 = __lasx_xvslli_h(tmp2, 5);
1006
- tmp3 = __lasx_xvslli_h(tmp3, 15);
1007
- dst0 = __lasx_xvor_v(tmp0, tmp2);
1008
- dst0 = __lasx_xvor_v(dst0, tmp3);
1009
- dst0 = __lasx_xvpermi_d(dst0, 0xD8);
1010
- __lasx_xvst(dst0, dst_rgb, 0);
1011
- dst_rgb += 32;
1012
- src_argb += 64;
1013
- }
1014
- }
1015
-
1016
- void ARGBToARGB4444Row_LASX(const uint8_t* src_argb,
1017
- uint8_t* dst_rgb,
1018
- int width) {
1019
- int x;
1020
- int len = width / 16;
1021
- __m256i src0, src1, tmp0, tmp1, dst0;
1022
-
1023
- for (x = 0; x < len; x++) {
1024
- DUP2_ARG2(__lasx_xvld, src_argb, 0, src_argb, 32, src0, src1);
1025
- tmp0 = __lasx_xvpickev_b(src1, src0);
1026
- tmp1 = __lasx_xvpickod_b(src1, src0);
1027
- tmp1 = __lasx_xvandi_b(tmp1, 0xF0);
1028
- tmp0 = __lasx_xvsrli_b(tmp0, 4);
1029
- dst0 = __lasx_xvor_v(tmp1, tmp0);
1030
- dst0 = __lasx_xvpermi_d(dst0, 0xD8);
1031
- __lasx_xvst(dst0, dst_rgb, 0);
1032
- dst_rgb += 32;
1033
- src_argb += 64;
1034
- }
1035
- }
1036
-
1037
- void ARGBToUV444Row_LASX(const uint8_t* src_argb,
1038
- uint8_t* dst_u,
1039
- uint8_t* dst_v,
1040
- int32_t width) {
1041
- int x;
1042
- int len = width / 32;
1043
- __m256i src0, src1, src2, src3;
1044
- __m256i tmp0, tmp1, tmp2, tmp3;
1045
- __m256i reg0, reg1, reg2, reg3, dst0, dst1;
1046
- __m256i const_112 = __lasx_xvldi(112);
1047
- __m256i const_74 = __lasx_xvldi(74);
1048
- __m256i const_38 = __lasx_xvldi(38);
1049
- __m256i const_94 = __lasx_xvldi(94);
1050
- __m256i const_18 = __lasx_xvldi(18);
1051
- __m256i const_0x8000 = (__m256i)v4u64{0x8000800080008000, 0x8000800080008000,
1052
- 0x8000800080008000, 0x8000800080008000};
1053
- __m256i control = {0x0000000400000000, 0x0000000500000001, 0x0000000600000002,
1054
- 0x0000000700000003};
1055
- for (x = 0; x < len; x++) {
1056
- DUP4_ARG2(__lasx_xvld, src_argb, 0, src_argb, 32, src_argb, 64, src_argb,
1057
- 96, src0, src1, src2, src3);
1058
- tmp0 = __lasx_xvpickev_h(src1, src0);
1059
- tmp1 = __lasx_xvpickod_h(src1, src0);
1060
- tmp2 = __lasx_xvpickev_h(src3, src2);
1061
- tmp3 = __lasx_xvpickod_h(src3, src2);
1062
- reg0 = __lasx_xvmaddwev_h_bu(const_0x8000, tmp0, const_112);
1063
- reg1 = __lasx_xvmaddwev_h_bu(const_0x8000, tmp2, const_112);
1064
- reg2 = __lasx_xvmulwod_h_bu(tmp0, const_74);
1065
- reg3 = __lasx_xvmulwod_h_bu(tmp2, const_74);
1066
- reg2 = __lasx_xvmaddwev_h_bu(reg2, tmp1, const_38);
1067
- reg3 = __lasx_xvmaddwev_h_bu(reg3, tmp3, const_38);
1068
- reg0 = __lasx_xvsub_h(reg0, reg2);
1069
- reg1 = __lasx_xvsub_h(reg1, reg3);
1070
- dst0 = __lasx_xvssrani_b_h(reg1, reg0, 8);
1071
- dst0 = __lasx_xvperm_w(dst0, control);
1072
- reg0 = __lasx_xvmaddwev_h_bu(const_0x8000, tmp1, const_112);
1073
- reg1 = __lasx_xvmaddwev_h_bu(const_0x8000, tmp3, const_112);
1074
- reg2 = __lasx_xvmulwev_h_bu(tmp0, const_18);
1075
- reg3 = __lasx_xvmulwev_h_bu(tmp2, const_18);
1076
- reg2 = __lasx_xvmaddwod_h_bu(reg2, tmp0, const_94);
1077
- reg3 = __lasx_xvmaddwod_h_bu(reg3, tmp2, const_94);
1078
- reg0 = __lasx_xvsub_h(reg0, reg2);
1079
- reg1 = __lasx_xvsub_h(reg1, reg3);
1080
- dst1 = __lasx_xvssrani_b_h(reg1, reg0, 8);
1081
- dst1 = __lasx_xvperm_w(dst1, control);
1082
- __lasx_xvst(dst0, dst_u, 0);
1083
- __lasx_xvst(dst1, dst_v, 0);
1084
- dst_u += 32;
1085
- dst_v += 32;
1086
- src_argb += 128;
1087
- }
1088
- }
1089
-
1090
- void ARGBMultiplyRow_LASX(const uint8_t* src_argb0,
1091
- const uint8_t* src_argb1,
1092
- uint8_t* dst_argb,
1093
- int width) {
1094
- int x;
1095
- int len = width / 8;
1096
- __m256i zero = __lasx_xvldi(0);
1097
- __m256i src0, src1, dst0, dst1;
1098
- __m256i tmp0, tmp1, tmp2, tmp3;
1099
-
1100
- for (x = 0; x < len; x++) {
1101
- DUP2_ARG2(__lasx_xvld, src_argb0, 0, src_argb1, 0, src0, src1);
1102
- tmp0 = __lasx_xvilvl_b(src0, src0);
1103
- tmp1 = __lasx_xvilvh_b(src0, src0);
1104
- tmp2 = __lasx_xvilvl_b(zero, src1);
1105
- tmp3 = __lasx_xvilvh_b(zero, src1);
1106
- dst0 = __lasx_xvmuh_hu(tmp0, tmp2);
1107
- dst1 = __lasx_xvmuh_hu(tmp1, tmp3);
1108
- dst0 = __lasx_xvpickev_b(dst1, dst0);
1109
- __lasx_xvst(dst0, dst_argb, 0);
1110
- src_argb0 += 32;
1111
- src_argb1 += 32;
1112
- dst_argb += 32;
1113
- }
1114
- }
1115
-
1116
- void ARGBAddRow_LASX(const uint8_t* src_argb0,
1117
- const uint8_t* src_argb1,
1118
- uint8_t* dst_argb,
1119
- int width) {
1120
- int x;
1121
- int len = width / 8;
1122
- __m256i src0, src1, dst0;
1123
-
1124
- for (x = 0; x < len; x++) {
1125
- DUP2_ARG2(__lasx_xvld, src_argb0, 0, src_argb1, 0, src0, src1);
1126
- dst0 = __lasx_xvsadd_bu(src0, src1);
1127
- __lasx_xvst(dst0, dst_argb, 0);
1128
- src_argb0 += 32;
1129
- src_argb1 += 32;
1130
- dst_argb += 32;
1131
- }
1132
- }
1133
-
1134
- void ARGBSubtractRow_LASX(const uint8_t* src_argb0,
1135
- const uint8_t* src_argb1,
1136
- uint8_t* dst_argb,
1137
- int width) {
1138
- int x;
1139
- int len = width / 8;
1140
- __m256i src0, src1, dst0;
1141
-
1142
- for (x = 0; x < len; x++) {
1143
- DUP2_ARG2(__lasx_xvld, src_argb0, 0, src_argb1, 0, src0, src1);
1144
- dst0 = __lasx_xvssub_bu(src0, src1);
1145
- __lasx_xvst(dst0, dst_argb, 0);
1146
- src_argb0 += 32;
1147
- src_argb1 += 32;
1148
- dst_argb += 32;
1149
- }
1150
- }
1151
-
1152
- void ARGBAttenuateRow_LASX(const uint8_t* src_argb,
1153
- uint8_t* dst_argb,
1154
- int width) {
1155
- int x;
1156
- int len = width / 16;
1157
- __m256i src0, src1, tmp0, tmp1;
1158
- __m256i reg0, reg1, reg2, reg3, reg4, reg5;
1159
- __m256i b, g, r, a, dst0, dst1;
1160
- __m256i control = {0x0005000100040000, 0x0007000300060002, 0x0005000100040000,
1161
- 0x0007000300060002};
1162
- __m256i zero = __lasx_xvldi(0);
1163
- __m256i const_add = __lasx_xvldi(0x8ff);
1164
-
1165
- for (x = 0; x < len; x++) {
1166
- DUP2_ARG2(__lasx_xvld, src_argb, 0, src_argb, 32, src0, src1);
1167
- tmp0 = __lasx_xvpickev_b(src1, src0);
1168
- tmp1 = __lasx_xvpickod_b(src1, src0);
1169
- b = __lasx_xvpackev_b(zero, tmp0);
1170
- r = __lasx_xvpackod_b(zero, tmp0);
1171
- g = __lasx_xvpackev_b(zero, tmp1);
1172
- a = __lasx_xvpackod_b(zero, tmp1);
1173
- reg0 = __lasx_xvmaddwev_w_hu(const_add, b, a);
1174
- reg1 = __lasx_xvmaddwod_w_hu(const_add, b, a);
1175
- reg2 = __lasx_xvmaddwev_w_hu(const_add, r, a);
1176
- reg3 = __lasx_xvmaddwod_w_hu(const_add, r, a);
1177
- reg4 = __lasx_xvmaddwev_w_hu(const_add, g, a);
1178
- reg5 = __lasx_xvmaddwod_w_hu(const_add, g, a);
1179
- reg0 = __lasx_xvssrani_h_w(reg1, reg0, 8);
1180
- reg2 = __lasx_xvssrani_h_w(reg3, reg2, 8);
1181
- reg4 = __lasx_xvssrani_h_w(reg5, reg4, 8);
1182
- reg0 = __lasx_xvshuf_h(control, reg0, reg0);
1183
- reg2 = __lasx_xvshuf_h(control, reg2, reg2);
1184
- reg4 = __lasx_xvshuf_h(control, reg4, reg4);
1185
- tmp0 = __lasx_xvpackev_b(reg4, reg0);
1186
- tmp1 = __lasx_xvpackev_b(a, reg2);
1187
- dst0 = __lasx_xvilvl_h(tmp1, tmp0);
1188
- dst1 = __lasx_xvilvh_h(tmp1, tmp0);
1189
- __lasx_xvst(dst0, dst_argb, 0);
1190
- __lasx_xvst(dst1, dst_argb, 32);
1191
- dst_argb += 64;
1192
- src_argb += 64;
1193
- }
1194
- }
1195
-
1196
- void ARGBToRGB565DitherRow_LASX(const uint8_t* src_argb,
1197
- uint8_t* dst_rgb,
1198
- uint32_t dither4,
1199
- int width) {
1200
- int x;
1201
- int len = width / 16;
1202
- __m256i src0, src1, tmp0, tmp1, dst0;
1203
- __m256i b, g, r;
1204
- __m256i zero = __lasx_xvldi(0);
1205
- __m256i vec_dither = __lasx_xvldrepl_w(&dither4, 0);
1206
-
1207
- vec_dither = __lasx_xvilvl_b(zero, vec_dither);
1208
- for (x = 0; x < len; x++) {
1209
- DUP2_ARG2(__lasx_xvld, src_argb, 0, src_argb, 32, src0, src1);
1210
- tmp0 = __lasx_xvpickev_b(src1, src0);
1211
- tmp1 = __lasx_xvpickod_b(src1, src0);
1212
- b = __lasx_xvpackev_b(zero, tmp0);
1213
- r = __lasx_xvpackod_b(zero, tmp0);
1214
- g = __lasx_xvpackev_b(zero, tmp1);
1215
- b = __lasx_xvadd_h(b, vec_dither);
1216
- g = __lasx_xvadd_h(g, vec_dither);
1217
- r = __lasx_xvadd_h(r, vec_dither);
1218
- DUP2_ARG1(__lasx_xvclip255_h, b, g, b, g);
1219
- r = __lasx_xvclip255_h(r);
1220
- b = __lasx_xvsrai_h(b, 3);
1221
- g = __lasx_xvsrai_h(g, 2);
1222
- r = __lasx_xvsrai_h(r, 3);
1223
- g = __lasx_xvslli_h(g, 5);
1224
- r = __lasx_xvslli_h(r, 11);
1225
- dst0 = __lasx_xvor_v(b, g);
1226
- dst0 = __lasx_xvor_v(dst0, r);
1227
- dst0 = __lasx_xvpermi_d(dst0, 0xD8);
1228
- __lasx_xvst(dst0, dst_rgb, 0);
1229
- src_argb += 64;
1230
- dst_rgb += 32;
1231
- }
1232
- }
1233
-
1234
- void ARGBShuffleRow_LASX(const uint8_t* src_argb,
1235
- uint8_t* dst_argb,
1236
- const uint8_t* shuffler,
1237
- int width) {
1238
- int x;
1239
- int len = width / 16;
1240
- __m256i src0, src1, dst0, dst1;
1241
- __m256i shuf = {0x0404040400000000, 0x0C0C0C0C08080808, 0x0404040400000000,
1242
- 0x0C0C0C0C08080808};
1243
- __m256i temp = __lasx_xvldrepl_w(shuffler, 0);
1244
-
1245
- shuf = __lasx_xvadd_b(shuf, temp);
1246
- for (x = 0; x < len; x++) {
1247
- DUP2_ARG2(__lasx_xvld, src_argb, 0, src_argb, 32, src0, src1);
1248
- dst0 = __lasx_xvshuf_b(src0, src0, shuf);
1249
- dst1 = __lasx_xvshuf_b(src1, src1, shuf);
1250
- __lasx_xvst(dst0, dst_argb, 0);
1251
- __lasx_xvst(dst1, dst_argb, 32);
1252
- src_argb += 64;
1253
- dst_argb += 64;
1254
- }
1255
- }
1256
-
1257
- void ARGBShadeRow_LASX(const uint8_t* src_argb,
1258
- uint8_t* dst_argb,
1259
- int width,
1260
- uint32_t value) {
1261
- int x;
1262
- int len = width / 8;
1263
- __m256i src0, dst0, tmp0, tmp1;
1264
- __m256i vec_value = __lasx_xvreplgr2vr_w(value);
1265
-
1266
- vec_value = __lasx_xvilvl_b(vec_value, vec_value);
1267
- for (x = 0; x < len; x++) {
1268
- src0 = __lasx_xvld(src_argb, 0);
1269
- tmp0 = __lasx_xvilvl_b(src0, src0);
1270
- tmp1 = __lasx_xvilvh_b(src0, src0);
1271
- tmp0 = __lasx_xvmuh_hu(tmp0, vec_value);
1272
- tmp1 = __lasx_xvmuh_hu(tmp1, vec_value);
1273
- dst0 = __lasx_xvpickod_b(tmp1, tmp0);
1274
- __lasx_xvst(dst0, dst_argb, 0);
1275
- src_argb += 32;
1276
- dst_argb += 32;
1277
- }
1278
- }
1279
-
1280
- void ARGBGrayRow_LASX(const uint8_t* src_argb, uint8_t* dst_argb, int width) {
1281
- int x;
1282
- int len = width / 16;
1283
- __m256i src0, src1, tmp0, tmp1;
1284
- __m256i reg0, reg1, reg2, dst0, dst1;
1285
- __m256i const_128 = __lasx_xvldi(0x480);
1286
- __m256i const_150 = __lasx_xvldi(0x96);
1287
- __m256i const_br = {0x4D1D4D1D4D1D4D1D, 0x4D1D4D1D4D1D4D1D,
1288
- 0x4D1D4D1D4D1D4D1D, 0x4D1D4D1D4D1D4D1D};
1289
-
1290
- for (x = 0; x < len; x++) {
1291
- DUP2_ARG2(__lasx_xvld, src_argb, 0, src_argb, 32, src0, src1);
1292
- tmp0 = __lasx_xvpickev_b(src1, src0);
1293
- tmp1 = __lasx_xvpickod_b(src1, src0);
1294
- reg0 = __lasx_xvdp2_h_bu(tmp0, const_br);
1295
- reg1 = __lasx_xvmaddwev_h_bu(const_128, tmp1, const_150);
1296
- reg2 = __lasx_xvadd_h(reg0, reg1);
1297
- tmp0 = __lasx_xvpackod_b(reg2, reg2);
1298
- tmp1 = __lasx_xvpackod_b(tmp1, reg2);
1299
- dst0 = __lasx_xvilvl_h(tmp1, tmp0);
1300
- dst1 = __lasx_xvilvh_h(tmp1, tmp0);
1301
- __lasx_xvst(dst0, dst_argb, 0);
1302
- __lasx_xvst(dst1, dst_argb, 32);
1303
- src_argb += 64;
1304
- dst_argb += 64;
1305
- }
1306
- }
1307
-
1308
- void ARGBSepiaRow_LASX(uint8_t* dst_argb, int width) {
1309
- int x;
1310
- int len = width / 16;
1311
- __m256i src0, src1, tmp0, tmp1;
1312
- __m256i reg0, reg1, spb, spg, spr;
1313
- __m256i dst0, dst1;
1314
- __m256i spb_g = __lasx_xvldi(68);
1315
- __m256i spg_g = __lasx_xvldi(88);
1316
- __m256i spr_g = __lasx_xvldi(98);
1317
- __m256i spb_br = {0x2311231123112311, 0x2311231123112311, 0x2311231123112311,
1318
- 0x2311231123112311};
1319
- __m256i spg_br = {0x2D162D162D162D16, 0x2D162D162D162D16, 0x2D162D162D162D16,
1320
- 0x2D162D162D162D16};
1321
- __m256i spr_br = {0x3218321832183218, 0x3218321832183218, 0x3218321832183218,
1322
- 0x3218321832183218};
1323
- __m256i shuff = {0x1706150413021100, 0x1F0E1D0C1B0A1908, 0x1706150413021100,
1324
- 0x1F0E1D0C1B0A1908};
1325
-
1326
- for (x = 0; x < len; x++) {
1327
- DUP2_ARG2(__lasx_xvld, dst_argb, 0, dst_argb, 32, src0, src1);
1328
- tmp0 = __lasx_xvpickev_b(src1, src0);
1329
- tmp1 = __lasx_xvpickod_b(src1, src0);
1330
- DUP2_ARG2(__lasx_xvdp2_h_bu, tmp0, spb_br, tmp0, spg_br, spb, spg);
1331
- spr = __lasx_xvdp2_h_bu(tmp0, spr_br);
1332
- spb = __lasx_xvmaddwev_h_bu(spb, tmp1, spb_g);
1333
- spg = __lasx_xvmaddwev_h_bu(spg, tmp1, spg_g);
1334
- spr = __lasx_xvmaddwev_h_bu(spr, tmp1, spr_g);
1335
- spb = __lasx_xvsrli_h(spb, 7);
1336
- spg = __lasx_xvsrli_h(spg, 7);
1337
- spr = __lasx_xvsrli_h(spr, 7);
1338
- spg = __lasx_xvsat_hu(spg, 7);
1339
- spr = __lasx_xvsat_hu(spr, 7);
1340
- reg0 = __lasx_xvpackev_b(spg, spb);
1341
- reg1 = __lasx_xvshuf_b(tmp1, spr, shuff);
1342
- dst0 = __lasx_xvilvl_h(reg1, reg0);
1343
- dst1 = __lasx_xvilvh_h(reg1, reg0);
1344
- __lasx_xvst(dst0, dst_argb, 0);
1345
- __lasx_xvst(dst1, dst_argb, 32);
1346
- dst_argb += 64;
1347
- }
1348
- }
1349
-
1350
- void ARGB4444ToARGBRow_LASX(const uint8_t* src_argb4444,
1351
- uint8_t* dst_argb,
1352
- int width) {
1353
- int x;
1354
- int len = width / 32;
1355
- __m256i src0, src1;
1356
- __m256i tmp0, tmp1, tmp2, tmp3;
1357
- __m256i reg0, reg1, reg2, reg3;
1358
- __m256i dst0, dst1, dst2, dst3;
1359
-
1360
- for (x = 0; x < len; x++) {
1361
- src0 = __lasx_xvld(src_argb4444, 0);
1362
- src1 = __lasx_xvld(src_argb4444, 32);
1363
- DUP4_ARG2(__lasx_xvandi_b, src0, 0x0F, src0, 0xF0, src1, 0x0F, src1, 0xF0,
1364
- tmp0, tmp1, tmp2, tmp3);
1365
- DUP2_ARG2(__lasx_xvslli_b, tmp0, 4, tmp2, 4, reg0, reg2);
1366
- DUP2_ARG2(__lasx_xvsrli_b, tmp1, 4, tmp3, 4, reg1, reg3);
1367
- DUP4_ARG2(__lasx_xvor_v, tmp0, reg0, tmp1, reg1, tmp2, reg2, tmp3, reg3,
1368
- tmp0, tmp1, tmp2, tmp3);
1369
- DUP2_ARG2(__lasx_xvilvl_b, tmp1, tmp0, tmp3, tmp2, reg0, reg2);
1370
- DUP2_ARG2(__lasx_xvilvh_b, tmp1, tmp0, tmp3, tmp2, reg1, reg3);
1371
- DUP4_ARG3(__lasx_xvpermi_q, reg1, reg0, 0x20, reg1, reg0, 0x31, reg3, reg2,
1372
- 0x20, reg3, reg2, 0x31, dst0, dst1, dst2, dst3);
1373
- __lasx_xvst(dst0, dst_argb, 0);
1374
- __lasx_xvst(dst1, dst_argb, 32);
1375
- __lasx_xvst(dst2, dst_argb, 64);
1376
- __lasx_xvst(dst3, dst_argb, 96);
1377
- src_argb4444 += 64;
1378
- dst_argb += 128;
1379
- }
1380
- }
1381
-
1382
- void ARGB1555ToARGBRow_LASX(const uint8_t* src_argb1555,
1383
- uint8_t* dst_argb,
1384
- int width) {
1385
- int x;
1386
- int len = width / 32;
1387
- __m256i src0, src1;
1388
- __m256i tmp0, tmp1, tmpb, tmpg, tmpr, tmpa;
1389
- __m256i reg0, reg1, reg2, reg3;
1390
- __m256i dst0, dst1, dst2, dst3;
1391
-
1392
- for (x = 0; x < len; x++) {
1393
- src0 = __lasx_xvld(src_argb1555, 0);
1394
- src1 = __lasx_xvld(src_argb1555, 32);
1395
- tmp0 = __lasx_xvpickev_b(src1, src0);
1396
- tmp1 = __lasx_xvpickod_b(src1, src0);
1397
- tmpb = __lasx_xvandi_b(tmp0, 0x1F);
1398
- tmpg = __lasx_xvsrli_b(tmp0, 5);
1399
- reg0 = __lasx_xvandi_b(tmp1, 0x03);
1400
- reg0 = __lasx_xvslli_b(reg0, 3);
1401
- tmpg = __lasx_xvor_v(tmpg, reg0);
1402
- reg1 = __lasx_xvandi_b(tmp1, 0x7C);
1403
- tmpr = __lasx_xvsrli_b(reg1, 2);
1404
- tmpa = __lasx_xvsrli_b(tmp1, 7);
1405
- tmpa = __lasx_xvneg_b(tmpa);
1406
- reg0 = __lasx_xvslli_b(tmpb, 3);
1407
- reg1 = __lasx_xvslli_b(tmpg, 3);
1408
- reg2 = __lasx_xvslli_b(tmpr, 3);
1409
- tmpb = __lasx_xvsrli_b(tmpb, 2);
1410
- tmpg = __lasx_xvsrli_b(tmpg, 2);
1411
- tmpr = __lasx_xvsrli_b(tmpr, 2);
1412
- tmpb = __lasx_xvor_v(reg0, tmpb);
1413
- tmpg = __lasx_xvor_v(reg1, tmpg);
1414
- tmpr = __lasx_xvor_v(reg2, tmpr);
1415
- DUP2_ARG2(__lasx_xvilvl_b, tmpg, tmpb, tmpa, tmpr, reg0, reg1);
1416
- DUP2_ARG2(__lasx_xvilvh_b, tmpg, tmpb, tmpa, tmpr, reg2, reg3);
1417
- dst0 = __lasx_xvilvl_h(reg1, reg0);
1418
- dst1 = __lasx_xvilvh_h(reg1, reg0);
1419
- dst2 = __lasx_xvilvl_h(reg3, reg2);
1420
- dst3 = __lasx_xvilvh_h(reg3, reg2);
1421
- DUP4_ARG3(__lasx_xvpermi_q, dst1, dst0, 0x20, dst1, dst0, 0x31, dst3, dst2,
1422
- 0x20, dst3, dst2, 0x31, reg0, reg1, reg2, reg3);
1423
- __lasx_xvst(reg0, dst_argb, 0);
1424
- __lasx_xvst(reg1, dst_argb, 32);
1425
- __lasx_xvst(reg2, dst_argb, 64);
1426
- __lasx_xvst(reg3, dst_argb, 96);
1427
- src_argb1555 += 64;
1428
- dst_argb += 128;
1429
- }
1430
- }
1431
-
1432
- void RGB565ToARGBRow_LASX(const uint8_t* src_rgb565,
1433
- uint8_t* dst_argb,
1434
- int width) {
1435
- int x;
1436
- int len = width / 32;
1437
- __m256i src0, src1;
1438
- __m256i tmp0, tmp1, tmpb, tmpg, tmpr;
1439
- __m256i reg0, reg1, reg2, reg3, dst0, dst1, dst2, dst3;
1440
- __m256i alpha = __lasx_xvldi(0xFF);
1441
-
1442
- for (x = 0; x < len; x++) {
1443
- src0 = __lasx_xvld(src_rgb565, 0);
1444
- src1 = __lasx_xvld(src_rgb565, 32);
1445
- tmp0 = __lasx_xvpickev_b(src1, src0);
1446
- tmp1 = __lasx_xvpickod_b(src1, src0);
1447
- tmpb = __lasx_xvandi_b(tmp0, 0x1F);
1448
- tmpr = __lasx_xvandi_b(tmp1, 0xF8);
1449
- reg1 = __lasx_xvandi_b(tmp1, 0x07);
1450
- reg0 = __lasx_xvsrli_b(tmp0, 5);
1451
- reg1 = __lasx_xvslli_b(reg1, 3);
1452
- tmpg = __lasx_xvor_v(reg1, reg0);
1453
- reg0 = __lasx_xvslli_b(tmpb, 3);
1454
- reg1 = __lasx_xvsrli_b(tmpb, 2);
1455
- tmpb = __lasx_xvor_v(reg1, reg0);
1456
- reg0 = __lasx_xvslli_b(tmpg, 2);
1457
- reg1 = __lasx_xvsrli_b(tmpg, 4);
1458
- tmpg = __lasx_xvor_v(reg1, reg0);
1459
- reg0 = __lasx_xvsrli_b(tmpr, 5);
1460
- tmpr = __lasx_xvor_v(tmpr, reg0);
1461
- DUP2_ARG2(__lasx_xvilvl_b, tmpg, tmpb, alpha, tmpr, reg0, reg1);
1462
- dst0 = __lasx_xvilvl_h(reg1, reg0);
1463
- dst1 = __lasx_xvilvh_h(reg1, reg0);
1464
- DUP2_ARG2(__lasx_xvilvh_b, tmpg, tmpb, alpha, tmpr, reg0, reg1);
1465
- dst2 = __lasx_xvilvl_h(reg1, reg0);
1466
- dst3 = __lasx_xvilvh_h(reg1, reg0);
1467
- DUP4_ARG3(__lasx_xvpermi_q, dst1, dst0, 0x20, dst1, dst0, 0x31, dst3, dst2,
1468
- 0x20, dst3, dst2, 0x31, reg0, reg1, reg2, reg3);
1469
- __lasx_xvst(reg0, dst_argb, 0);
1470
- __lasx_xvst(reg1, dst_argb, 32);
1471
- __lasx_xvst(reg2, dst_argb, 64);
1472
- __lasx_xvst(reg3, dst_argb, 96);
1473
- src_rgb565 += 64;
1474
- dst_argb += 128;
1475
- }
1476
- }
1477
-
1478
- void RGB24ToARGBRow_LASX(const uint8_t* src_rgb24,
1479
- uint8_t* dst_argb,
1480
- int width) {
1481
- int x;
1482
- int len = width / 32;
1483
- __m256i src0, src1, src2;
1484
- __m256i tmp0, tmp1, tmp2;
1485
- __m256i dst0, dst1, dst2, dst3;
1486
- __m256i reg0, reg1, reg2, reg3;
1487
- __m256i alpha = __lasx_xvldi(0xFF);
1488
- __m256i shuf0 = {0x131211100F0E0D0C, 0x1B1A191817161514, 0x131211100F0E0D0C,
1489
- 0x1B1A191817161514};
1490
- __m256i shuf1 = {0x1F1E1D1C1B1A1918, 0x0706050403020100, 0x1F1E1D1C1B1A1918,
1491
- 0x0706050403020100};
1492
- __m256i shuf2 = {0x0B0A090807060504, 0x131211100F0E0D0C, 0x0B0A090807060504,
1493
- 0x131211100F0E0D0C};
1494
- __m256i shuf3 = {0x1005040310020100, 0x100B0A0910080706, 0x1005040310020100,
1495
- 0x100B0A0910080706};
1496
-
1497
- for (x = 0; x < len; x++) {
1498
- reg0 = __lasx_xvld(src_rgb24, 0);
1499
- reg1 = __lasx_xvld(src_rgb24, 32);
1500
- reg2 = __lasx_xvld(src_rgb24, 64);
1501
- src0 = __lasx_xvpermi_q(reg1, reg0, 0x30);
1502
- src1 = __lasx_xvpermi_q(reg2, reg0, 0x21);
1503
- src2 = __lasx_xvpermi_q(reg2, reg1, 0x30);
1504
- DUP2_ARG3(__lasx_xvshuf_b, src1, src0, shuf0, src1, src2, shuf1, tmp0,
1505
- tmp1);
1506
- tmp2 = __lasx_xvshuf_b(src1, src2, shuf2);
1507
- DUP4_ARG3(__lasx_xvshuf_b, alpha, src0, shuf3, alpha, tmp0, shuf3, alpha,
1508
- tmp1, shuf3, alpha, tmp2, shuf3, reg0, reg1, reg2, reg3);
1509
- DUP4_ARG3(__lasx_xvpermi_q, reg1, reg0, 0x20, reg3, reg2, 0x20, reg1, reg0,
1510
- 0x31, reg3, reg2, 0x31, dst0, dst1, dst2, dst3);
1511
- __lasx_xvst(dst0, dst_argb, 0);
1512
- __lasx_xvst(dst1, dst_argb, 32);
1513
- __lasx_xvst(dst2, dst_argb, 64);
1514
- __lasx_xvst(dst3, dst_argb, 96);
1515
- src_rgb24 += 96;
1516
- dst_argb += 128;
1517
- }
1518
- }
1519
-
1520
- void RAWToARGBRow_LASX(const uint8_t* src_raw, uint8_t* dst_argb, int width) {
1521
- int x;
1522
- int len = width / 32;
1523
- __m256i src0, src1, src2;
1524
- __m256i tmp0, tmp1, tmp2, reg0, reg1, reg2, reg3;
1525
- __m256i dst0, dst1, dst2, dst3;
1526
- __m256i alpha = __lasx_xvldi(0xFF);
1527
- __m256i shuf0 = {0x131211100F0E0D0C, 0x1B1A191817161514, 0x131211100F0E0D0C,
1528
- 0x1B1A191817161514};
1529
- __m256i shuf1 = {0x1F1E1D1C1B1A1918, 0x0706050403020100, 0x1F1E1D1C1B1A1918,
1530
- 0x0706050403020100};
1531
- __m256i shuf2 = {0x0B0A090807060504, 0x131211100F0E0D0C, 0x0B0A090807060504,
1532
- 0x131211100F0E0D0C};
1533
- __m256i shuf3 = {0x1003040510000102, 0x10090A0B10060708, 0x1003040510000102,
1534
- 0x10090A0B10060708};
1535
-
1536
- for (x = 0; x < len; x++) {
1537
- reg0 = __lasx_xvld(src_raw, 0);
1538
- reg1 = __lasx_xvld(src_raw, 32);
1539
- reg2 = __lasx_xvld(src_raw, 64);
1540
- src0 = __lasx_xvpermi_q(reg1, reg0, 0x30);
1541
- src1 = __lasx_xvpermi_q(reg2, reg0, 0x21);
1542
- src2 = __lasx_xvpermi_q(reg2, reg1, 0x30);
1543
- DUP2_ARG3(__lasx_xvshuf_b, src1, src0, shuf0, src1, src2, shuf1, tmp0,
1544
- tmp1);
1545
- tmp2 = __lasx_xvshuf_b(src1, src2, shuf2);
1546
- DUP4_ARG3(__lasx_xvshuf_b, alpha, src0, shuf3, alpha, tmp0, shuf3, alpha,
1547
- tmp1, shuf3, alpha, tmp2, shuf3, reg0, reg1, reg2, reg3);
1548
- DUP4_ARG3(__lasx_xvpermi_q, reg1, reg0, 0x20, reg3, reg2, 0x20, reg1, reg0,
1549
- 0x31, reg3, reg2, 0x31, dst0, dst1, dst2, dst3);
1550
- __lasx_xvst(dst0, dst_argb, 0);
1551
- __lasx_xvst(dst1, dst_argb, 32);
1552
- __lasx_xvst(dst2, dst_argb, 64);
1553
- __lasx_xvst(dst3, dst_argb, 96);
1554
- src_raw += 96;
1555
- dst_argb += 128;
1556
- }
1557
- }
1558
-
1559
- void ARGB1555ToYRow_LASX(const uint8_t* src_argb1555,
1560
- uint8_t* dst_y,
1561
- int width) {
1562
- int x;
1563
- int len = width / 32;
1564
- __m256i src0, src1;
1565
- __m256i tmp0, tmp1, tmpb, tmpg, tmpr;
1566
- __m256i reg0, reg1, reg2, dst0;
1567
- __m256i const_66 = __lasx_xvldi(66);
1568
- __m256i const_129 = __lasx_xvldi(129);
1569
- __m256i const_25 = __lasx_xvldi(25);
1570
- __m256i const_1080 = {0x1080108010801080, 0x1080108010801080,
1571
- 0x1080108010801080, 0x1080108010801080};
1572
-
1573
- for (x = 0; x < len; x++) {
1574
- src0 = __lasx_xvld(src_argb1555, 0);
1575
- src1 = __lasx_xvld(src_argb1555, 32);
1576
- tmp0 = __lasx_xvpickev_b(src1, src0);
1577
- tmp1 = __lasx_xvpickod_b(src1, src0);
1578
- tmpb = __lasx_xvandi_b(tmp0, 0x1F);
1579
- tmpg = __lasx_xvsrli_b(tmp0, 5);
1580
- reg0 = __lasx_xvandi_b(tmp1, 0x03);
1581
- reg0 = __lasx_xvslli_b(reg0, 3);
1582
- tmpg = __lasx_xvor_v(tmpg, reg0);
1583
- reg1 = __lasx_xvandi_b(tmp1, 0x7C);
1584
- tmpr = __lasx_xvsrli_b(reg1, 2);
1585
- reg0 = __lasx_xvslli_b(tmpb, 3);
1586
- reg1 = __lasx_xvslli_b(tmpg, 3);
1587
- reg2 = __lasx_xvslli_b(tmpr, 3);
1588
- tmpb = __lasx_xvsrli_b(tmpb, 2);
1589
- tmpg = __lasx_xvsrli_b(tmpg, 2);
1590
- tmpr = __lasx_xvsrli_b(tmpr, 2);
1591
- tmpb = __lasx_xvor_v(reg0, tmpb);
1592
- tmpg = __lasx_xvor_v(reg1, tmpg);
1593
- tmpr = __lasx_xvor_v(reg2, tmpr);
1594
- reg0 = __lasx_xvmaddwev_h_bu(const_1080, tmpb, const_25);
1595
- reg1 = __lasx_xvmaddwod_h_bu(const_1080, tmpb, const_25);
1596
- reg0 = __lasx_xvmaddwev_h_bu(reg0, tmpg, const_129);
1597
- reg1 = __lasx_xvmaddwod_h_bu(reg1, tmpg, const_129);
1598
- reg0 = __lasx_xvmaddwev_h_bu(reg0, tmpr, const_66);
1599
- reg1 = __lasx_xvmaddwod_h_bu(reg1, tmpr, const_66);
1600
- dst0 = __lasx_xvpackod_b(reg1, reg0);
1601
- dst0 = __lasx_xvpermi_d(dst0, 0xD8);
1602
- __lasx_xvst(dst0, dst_y, 0);
1603
- src_argb1555 += 64;
1604
- dst_y += 32;
1605
- }
1606
- }
1607
-
1608
- void ARGB1555ToUVRow_LASX(const uint8_t* src_argb1555,
1609
- int src_stride_argb1555,
1610
- uint8_t* dst_u,
1611
- uint8_t* dst_v,
1612
- int width) {
1613
- int x;
1614
- int len = width / 32;
1615
- const uint8_t* next_argb1555 = src_argb1555 + src_stride_argb1555;
1616
- __m256i src0, src1, src2, src3;
1617
- __m256i tmp0, tmp1, tmp2, tmp3;
1618
- __m256i tmpb, tmpg, tmpr, nexb, nexg, nexr;
1619
- __m256i reg0, reg1, reg2, reg3, dst0;
1620
- __m256i const_112 = __lasx_xvldi(0x470);
1621
- __m256i const_74 = __lasx_xvldi(0x44A);
1622
- __m256i const_38 = __lasx_xvldi(0x426);
1623
- __m256i const_94 = __lasx_xvldi(0x45E);
1624
- __m256i const_18 = __lasx_xvldi(0x412);
1625
- __m256i const_8000 = (__m256i)v4u64{0x8000800080008000, 0x8000800080008000,
1626
- 0x8000800080008000, 0x8000800080008000};
1627
-
1628
- for (x = 0; x < len; x++) {
1629
- DUP4_ARG2(__lasx_xvld, src_argb1555, 0, src_argb1555, 32, next_argb1555, 0,
1630
- next_argb1555, 32, src0, src1, src2, src3);
1631
- DUP2_ARG2(__lasx_xvpickev_b, src1, src0, src3, src2, tmp0, tmp2);
1632
- DUP2_ARG2(__lasx_xvpickod_b, src1, src0, src3, src2, tmp1, tmp3);
1633
- tmpb = __lasx_xvandi_b(tmp0, 0x1F);
1634
- nexb = __lasx_xvandi_b(tmp2, 0x1F);
1635
- tmpg = __lasx_xvsrli_b(tmp0, 5);
1636
- nexg = __lasx_xvsrli_b(tmp2, 5);
1637
- reg0 = __lasx_xvandi_b(tmp1, 0x03);
1638
- reg2 = __lasx_xvandi_b(tmp3, 0x03);
1639
- reg0 = __lasx_xvslli_b(reg0, 3);
1640
- reg2 = __lasx_xvslli_b(reg2, 3);
1641
- tmpg = __lasx_xvor_v(tmpg, reg0);
1642
- nexg = __lasx_xvor_v(nexg, reg2);
1643
- reg1 = __lasx_xvandi_b(tmp1, 0x7C);
1644
- reg3 = __lasx_xvandi_b(tmp3, 0x7C);
1645
- tmpr = __lasx_xvsrli_b(reg1, 2);
1646
- nexr = __lasx_xvsrli_b(reg3, 2);
1647
- reg0 = __lasx_xvslli_b(tmpb, 3);
1648
- reg1 = __lasx_xvslli_b(tmpg, 3);
1649
- reg2 = __lasx_xvslli_b(tmpr, 3);
1650
- tmpb = __lasx_xvsrli_b(tmpb, 2);
1651
- tmpg = __lasx_xvsrli_b(tmpg, 2);
1652
- tmpr = __lasx_xvsrli_b(tmpr, 2);
1653
- tmpb = __lasx_xvor_v(reg0, tmpb);
1654
- tmpg = __lasx_xvor_v(reg1, tmpg);
1655
- tmpr = __lasx_xvor_v(reg2, tmpr);
1656
- reg0 = __lasx_xvslli_b(nexb, 3);
1657
- reg1 = __lasx_xvslli_b(nexg, 3);
1658
- reg2 = __lasx_xvslli_b(nexr, 3);
1659
- nexb = __lasx_xvsrli_b(nexb, 2);
1660
- nexg = __lasx_xvsrli_b(nexg, 2);
1661
- nexr = __lasx_xvsrli_b(nexr, 2);
1662
- nexb = __lasx_xvor_v(reg0, nexb);
1663
- nexg = __lasx_xvor_v(reg1, nexg);
1664
- nexr = __lasx_xvor_v(reg2, nexr);
1665
- RGBTOUV(tmpb, tmpg, tmpr, nexb, nexg, nexr, reg0, reg1);
1666
- reg0 = __lasx_xvpermi_d(reg0, 0xD8);
1667
- reg1 = __lasx_xvpermi_d(reg1, 0xD8);
1668
- dst0 = __lasx_xvpickod_b(reg1, reg0);
1669
- __lasx_xvstelm_d(dst0, dst_u, 0, 0);
1670
- __lasx_xvstelm_d(dst0, dst_v, 0, 1);
1671
- __lasx_xvstelm_d(dst0, dst_u, 8, 2);
1672
- __lasx_xvstelm_d(dst0, dst_v, 8, 3);
1673
- src_argb1555 += 64;
1674
- next_argb1555 += 64;
1675
- dst_u += 16;
1676
- dst_v += 16;
1677
- }
1678
- }
1679
-
1680
- void RGB565ToYRow_LASX(const uint8_t* src_rgb565, uint8_t* dst_y, int width) {
1681
- int x;
1682
- int len = width / 32;
1683
- __m256i src0, src1;
1684
- __m256i tmp0, tmp1, tmpb, tmpg, tmpr;
1685
- __m256i reg0, reg1, dst0;
1686
- __m256i const_66 = __lasx_xvldi(66);
1687
- __m256i const_129 = __lasx_xvldi(129);
1688
- __m256i const_25 = __lasx_xvldi(25);
1689
- __m256i const_1080 = {0x1080108010801080, 0x1080108010801080,
1690
- 0x1080108010801080, 0x1080108010801080};
1691
-
1692
- for (x = 0; x < len; x++) {
1693
- src0 = __lasx_xvld(src_rgb565, 0);
1694
- src1 = __lasx_xvld(src_rgb565, 32);
1695
- tmp0 = __lasx_xvpickev_b(src1, src0);
1696
- tmp1 = __lasx_xvpickod_b(src1, src0);
1697
- tmpb = __lasx_xvandi_b(tmp0, 0x1F);
1698
- tmpr = __lasx_xvandi_b(tmp1, 0xF8);
1699
- reg1 = __lasx_xvandi_b(tmp1, 0x07);
1700
- reg0 = __lasx_xvsrli_b(tmp0, 5);
1701
- reg1 = __lasx_xvslli_b(reg1, 3);
1702
- tmpg = __lasx_xvor_v(reg1, reg0);
1703
- reg0 = __lasx_xvslli_b(tmpb, 3);
1704
- reg1 = __lasx_xvsrli_b(tmpb, 2);
1705
- tmpb = __lasx_xvor_v(reg1, reg0);
1706
- reg0 = __lasx_xvslli_b(tmpg, 2);
1707
- reg1 = __lasx_xvsrli_b(tmpg, 4);
1708
- tmpg = __lasx_xvor_v(reg1, reg0);
1709
- reg0 = __lasx_xvsrli_b(tmpr, 5);
1710
- tmpr = __lasx_xvor_v(tmpr, reg0);
1711
- reg0 = __lasx_xvmaddwev_h_bu(const_1080, tmpb, const_25);
1712
- reg1 = __lasx_xvmaddwod_h_bu(const_1080, tmpb, const_25);
1713
- reg0 = __lasx_xvmaddwev_h_bu(reg0, tmpg, const_129);
1714
- reg1 = __lasx_xvmaddwod_h_bu(reg1, tmpg, const_129);
1715
- reg0 = __lasx_xvmaddwev_h_bu(reg0, tmpr, const_66);
1716
- reg1 = __lasx_xvmaddwod_h_bu(reg1, tmpr, const_66);
1717
- dst0 = __lasx_xvpackod_b(reg1, reg0);
1718
- dst0 = __lasx_xvpermi_d(dst0, 0xD8);
1719
- __lasx_xvst(dst0, dst_y, 0);
1720
- dst_y += 32;
1721
- src_rgb565 += 64;
1722
- }
1723
- }
1724
-
1725
- void RGB565ToUVRow_LASX(const uint8_t* src_rgb565,
1726
- int src_stride_rgb565,
1727
- uint8_t* dst_u,
1728
- uint8_t* dst_v,
1729
- int width) {
1730
- int x;
1731
- int len = width / 32;
1732
- const uint8_t* next_rgb565 = src_rgb565 + src_stride_rgb565;
1733
- __m256i src0, src1, src2, src3;
1734
- __m256i tmp0, tmp1, tmp2, tmp3;
1735
- __m256i tmpb, tmpg, tmpr, nexb, nexg, nexr;
1736
- __m256i reg0, reg1, reg2, reg3, dst0;
1737
- __m256i const_112 = __lasx_xvldi(0x470);
1738
- __m256i const_74 = __lasx_xvldi(0x44A);
1739
- __m256i const_38 = __lasx_xvldi(0x426);
1740
- __m256i const_94 = __lasx_xvldi(0x45E);
1741
- __m256i const_18 = __lasx_xvldi(0x412);
1742
- __m256i const_8000 = (__m256i)v4u64{0x8000800080008000, 0x8000800080008000,
1743
- 0x8000800080008000, 0x8000800080008000};
1744
-
1745
- for (x = 0; x < len; x++) {
1746
- DUP4_ARG2(__lasx_xvld, src_rgb565, 0, src_rgb565, 32, next_rgb565, 0,
1747
- next_rgb565, 32, src0, src1, src2, src3);
1748
- DUP2_ARG2(__lasx_xvpickev_b, src1, src0, src3, src2, tmp0, tmp2);
1749
- DUP2_ARG2(__lasx_xvpickod_b, src1, src0, src3, src2, tmp1, tmp3);
1750
- tmpb = __lasx_xvandi_b(tmp0, 0x1F);
1751
- tmpr = __lasx_xvandi_b(tmp1, 0xF8);
1752
- nexb = __lasx_xvandi_b(tmp2, 0x1F);
1753
- nexr = __lasx_xvandi_b(tmp3, 0xF8);
1754
- reg1 = __lasx_xvandi_b(tmp1, 0x07);
1755
- reg3 = __lasx_xvandi_b(tmp3, 0x07);
1756
- reg0 = __lasx_xvsrli_b(tmp0, 5);
1757
- reg1 = __lasx_xvslli_b(reg1, 3);
1758
- reg2 = __lasx_xvsrli_b(tmp2, 5);
1759
- reg3 = __lasx_xvslli_b(reg3, 3);
1760
- tmpg = __lasx_xvor_v(reg1, reg0);
1761
- nexg = __lasx_xvor_v(reg2, reg3);
1762
- reg0 = __lasx_xvslli_b(tmpb, 3);
1763
- reg1 = __lasx_xvsrli_b(tmpb, 2);
1764
- reg2 = __lasx_xvslli_b(nexb, 3);
1765
- reg3 = __lasx_xvsrli_b(nexb, 2);
1766
- tmpb = __lasx_xvor_v(reg1, reg0);
1767
- nexb = __lasx_xvor_v(reg2, reg3);
1768
- reg0 = __lasx_xvslli_b(tmpg, 2);
1769
- reg1 = __lasx_xvsrli_b(tmpg, 4);
1770
- reg2 = __lasx_xvslli_b(nexg, 2);
1771
- reg3 = __lasx_xvsrli_b(nexg, 4);
1772
- tmpg = __lasx_xvor_v(reg1, reg0);
1773
- nexg = __lasx_xvor_v(reg2, reg3);
1774
- reg0 = __lasx_xvsrli_b(tmpr, 5);
1775
- reg2 = __lasx_xvsrli_b(nexr, 5);
1776
- tmpr = __lasx_xvor_v(tmpr, reg0);
1777
- nexr = __lasx_xvor_v(nexr, reg2);
1778
- RGBTOUV(tmpb, tmpg, tmpr, nexb, nexg, nexr, reg0, reg1);
1779
- reg0 = __lasx_xvpermi_d(reg0, 0xD8);
1780
- reg1 = __lasx_xvpermi_d(reg1, 0xD8);
1781
- dst0 = __lasx_xvpickod_b(reg1, reg0);
1782
- __lasx_xvstelm_d(dst0, dst_u, 0, 0);
1783
- __lasx_xvstelm_d(dst0, dst_v, 0, 1);
1784
- __lasx_xvstelm_d(dst0, dst_u, 8, 2);
1785
- __lasx_xvstelm_d(dst0, dst_v, 8, 3);
1786
- dst_u += 16;
1787
- dst_v += 16;
1788
- src_rgb565 += 64;
1789
- next_rgb565 += 64;
1790
- }
1791
- }
1792
-
1793
- void RGB24ToUVRow_LASX(const uint8_t* src_rgb24,
1794
- int src_stride_rgb24,
1795
- uint8_t* dst_u,
1796
- uint8_t* dst_v,
1797
- int width) {
1798
- int x;
1799
- const uint8_t* next_rgb24 = src_rgb24 + src_stride_rgb24;
1800
- int len = width / 32;
1801
- __m256i src0, src1, src2, reg0, reg1, reg2;
1802
- __m256i nex0, nex1, nex2, dst0, tmp0, tmp1, tmp2;
1803
- __m256i tmpb, tmpg, tmpr, nexb, nexg, nexr;
1804
- __m256i const_112 = __lasx_xvldi(0x470);
1805
- __m256i const_74 = __lasx_xvldi(0x44A);
1806
- __m256i const_38 = __lasx_xvldi(0x426);
1807
- __m256i const_94 = __lasx_xvldi(0x45E);
1808
- __m256i const_18 = __lasx_xvldi(0x412);
1809
- __m256i const_8000 = (__m256i)v4u64{0x8000800080008000, 0x8000800080008000,
1810
- 0x8000800080008000, 0x8000800080008000};
1811
- __m256i shuff0_b = {0x15120F0C09060300, 0x00000000001E1B18,
1812
- 0x15120F0C09060300, 0x00000000001E1B18};
1813
- __m256i shuff1_b = {0x0706050403020100, 0x1D1A1714110A0908,
1814
- 0x0706050403020100, 0x1D1A1714110A0908};
1815
- __m256i shuff0_g = {0x1613100D0A070401, 0x00000000001F1C19,
1816
- 0x1613100D0A070401, 0x00000000001F1C19};
1817
- __m256i shuff1_g = {0x0706050403020100, 0x1E1B1815120A0908,
1818
- 0x0706050403020100, 0x1E1B1815120A0908};
1819
- __m256i shuff0_r = {0x1714110E0B080502, 0x0000000000001D1A,
1820
- 0x1714110E0B080502, 0x0000000000001D1A};
1821
- __m256i shuff1_r = {0x0706050403020100, 0x1F1C191613100908,
1822
- 0x0706050403020100, 0x1F1C191613100908};
1823
-
1824
- for (x = 0; x < len; x++) {
1825
- DUP4_ARG2(__lasx_xvld, src_rgb24, 0, src_rgb24, 32, src_rgb24, 64,
1826
- next_rgb24, 0, reg0, reg1, reg2, tmp0);
1827
- DUP2_ARG2(__lasx_xvld, next_rgb24, 32, next_rgb24, 64, tmp1, tmp2);
1828
- DUP4_ARG3(__lasx_xvpermi_q, reg1, reg0, 0x30, reg2, reg0, 0x21, reg2, reg1,
1829
- 0x30, tmp1, tmp0, 0x30, src0, src1, src2, nex0);
1830
- DUP2_ARG3(__lasx_xvpermi_q, tmp2, tmp0, 0x21, tmp2, tmp1, 0x30, nex1, nex2);
1831
- DUP2_ARG3(__lasx_xvshuf_b, src1, src0, shuff0_b, nex1, nex0, shuff0_b, tmpb,
1832
- nexb);
1833
- DUP2_ARG3(__lasx_xvshuf_b, src1, src0, shuff0_g, nex1, nex0, shuff0_g, tmpg,
1834
- nexg);
1835
- DUP2_ARG3(__lasx_xvshuf_b, src1, src0, shuff0_r, nex1, nex0, shuff0_r, tmpr,
1836
- nexr);
1837
- DUP2_ARG3(__lasx_xvshuf_b, src2, tmpb, shuff1_b, nex2, nexb, shuff1_b, tmpb,
1838
- nexb);
1839
- DUP2_ARG3(__lasx_xvshuf_b, src2, tmpg, shuff1_g, nex2, nexg, shuff1_g, tmpg,
1840
- nexg);
1841
- DUP2_ARG3(__lasx_xvshuf_b, src2, tmpr, shuff1_r, nex2, nexr, shuff1_r, tmpr,
1842
- nexr);
1843
- RGBTOUV(tmpb, tmpg, tmpr, nexb, nexg, nexr, reg0, reg1);
1844
- dst0 = __lasx_xvpickod_b(reg1, reg0);
1845
- __lasx_xvstelm_d(dst0, dst_u, 0, 0);
1846
- __lasx_xvstelm_d(dst0, dst_v, 0, 1);
1847
- __lasx_xvstelm_d(dst0, dst_u, 8, 2);
1848
- __lasx_xvstelm_d(dst0, dst_v, 8, 3);
1849
- src_rgb24 += 96;
1850
- next_rgb24 += 96;
1851
- dst_u += 16;
1852
- dst_v += 16;
1853
- }
1854
- }
1855
-
1856
- void RAWToUVRow_LASX(const uint8_t* src_raw,
1857
- int src_stride_raw,
1858
- uint8_t* dst_u,
1859
- uint8_t* dst_v,
1860
- int width) {
1861
- int x;
1862
- const uint8_t* next_raw = src_raw + src_stride_raw;
1863
- int len = width / 32;
1864
- __m256i src0, src1, src2, reg0, reg1, reg2;
1865
- __m256i nex0, nex1, nex2, dst0, tmp0, tmp1, tmp2;
1866
- __m256i tmpb, tmpg, tmpr, nexb, nexg, nexr;
1867
- __m256i const_112 = __lasx_xvldi(0x470);
1868
- __m256i const_74 = __lasx_xvldi(0x44A);
1869
- __m256i const_38 = __lasx_xvldi(0x426);
1870
- __m256i const_94 = __lasx_xvldi(0x45E);
1871
- __m256i const_18 = __lasx_xvldi(0x412);
1872
- __m256i const_8000 = (__m256i)v4u64{0x8000800080008000, 0x8000800080008000,
1873
- 0x8000800080008000, 0x8000800080008000};
1874
- __m256i shuff0_r = {0x15120F0C09060300, 0x00000000001E1B18,
1875
- 0x15120F0C09060300, 0x00000000001E1B18};
1876
- __m256i shuff1_r = {0x0706050403020100, 0x1D1A1714110A0908,
1877
- 0x0706050403020100, 0x1D1A1714110A0908};
1878
- __m256i shuff0_g = {0x1613100D0A070401, 0x00000000001F1C19,
1879
- 0x1613100D0A070401, 0x00000000001F1C19};
1880
- __m256i shuff1_g = {0x0706050403020100, 0x1E1B1815120A0908,
1881
- 0x0706050403020100, 0x1E1B1815120A0908};
1882
- __m256i shuff0_b = {0x1714110E0B080502, 0x0000000000001D1A,
1883
- 0x1714110E0B080502, 0x0000000000001D1A};
1884
- __m256i shuff1_b = {0x0706050403020100, 0x1F1C191613100908,
1885
- 0x0706050403020100, 0x1F1C191613100908};
1886
-
1887
- for (x = 0; x < len; x++) {
1888
- DUP4_ARG2(__lasx_xvld, src_raw, 0, src_raw, 32, src_raw, 64, next_raw, 0,
1889
- reg0, reg1, reg2, tmp0);
1890
- DUP2_ARG2(__lasx_xvld, next_raw, 32, next_raw, 64, tmp1, tmp2);
1891
- DUP4_ARG3(__lasx_xvpermi_q, reg1, reg0, 0x30, reg2, reg0, 0x21, reg2, reg1,
1892
- 0x30, tmp1, tmp0, 0x30, src0, src1, src2, nex0);
1893
- DUP2_ARG3(__lasx_xvpermi_q, tmp2, tmp0, 0x21, tmp2, tmp1, 0x30, nex1, nex2);
1894
- DUP2_ARG3(__lasx_xvshuf_b, src1, src0, shuff0_b, nex1, nex0, shuff0_b, tmpb,
1895
- nexb);
1896
- DUP2_ARG3(__lasx_xvshuf_b, src1, src0, shuff0_g, nex1, nex0, shuff0_g, tmpg,
1897
- nexg);
1898
- DUP2_ARG3(__lasx_xvshuf_b, src1, src0, shuff0_r, nex1, nex0, shuff0_r, tmpr,
1899
- nexr);
1900
- DUP2_ARG3(__lasx_xvshuf_b, src2, tmpb, shuff1_b, nex2, nexb, shuff1_b, tmpb,
1901
- nexb);
1902
- DUP2_ARG3(__lasx_xvshuf_b, src2, tmpg, shuff1_g, nex2, nexg, shuff1_g, tmpg,
1903
- nexg);
1904
- DUP2_ARG3(__lasx_xvshuf_b, src2, tmpr, shuff1_r, nex2, nexr, shuff1_r, tmpr,
1905
- nexr);
1906
- RGBTOUV(tmpb, tmpg, tmpr, nexb, nexg, nexr, reg0, reg1);
1907
- dst0 = __lasx_xvpickod_b(reg1, reg0);
1908
- __lasx_xvstelm_d(dst0, dst_u, 0, 0);
1909
- __lasx_xvstelm_d(dst0, dst_v, 0, 1);
1910
- __lasx_xvstelm_d(dst0, dst_u, 8, 2);
1911
- __lasx_xvstelm_d(dst0, dst_v, 8, 3);
1912
- src_raw += 96;
1913
- next_raw += 96;
1914
- dst_u += 16;
1915
- dst_v += 16;
1916
- }
1917
- }
1918
-
1919
- void NV12ToARGBRow_LASX(const uint8_t* src_y,
1920
- const uint8_t* src_uv,
1921
- uint8_t* dst_argb,
1922
- const struct YuvConstants* yuvconstants,
1923
- int width) {
1924
- int x;
1925
- int len = width / 16;
1926
- __m256i vec_yg, vec_yb, vec_ub, vec_vr, vec_ug, vec_vg;
1927
- __m256i vec_vrub, vec_vgug, vec_y, vec_vu;
1928
- __m256i out_b, out_g, out_r;
1929
- __m256i const_0x80 = __lasx_xvldi(0x80);
1930
- __m256i alpha = __lasx_xvldi(0xFF);
1931
-
1932
- YUVTORGB_SETUP(yuvconstants, vec_ub, vec_vr, vec_ug, vec_vg, vec_yg, vec_yb);
1933
- vec_vrub = __lasx_xvilvl_h(vec_vr, vec_ub);
1934
- vec_vgug = __lasx_xvilvl_h(vec_vg, vec_ug);
1935
-
1936
- for (x = 0; x < len; x++) {
1937
- vec_y = __lasx_xvld(src_y, 0);
1938
- vec_vu = __lasx_xvld(src_uv, 0);
1939
- vec_vu = __lasx_xvsub_b(vec_vu, const_0x80);
1940
- vec_vu = __lasx_vext2xv_h_b(vec_vu);
1941
- YUVTORGB(vec_y, vec_vu, vec_vrub, vec_vgug, vec_yg, vec_yb, out_r, out_g,
1942
- out_b);
1943
- STOREARGB(alpha, out_r, out_g, out_b, dst_argb);
1944
- src_y += 16;
1945
- src_uv += 16;
1946
- }
1947
- }
1948
-
1949
- void NV12ToRGB565Row_LASX(const uint8_t* src_y,
1950
- const uint8_t* src_uv,
1951
- uint8_t* dst_rgb565,
1952
- const struct YuvConstants* yuvconstants,
1953
- int width) {
1954
- int x;
1955
- int len = width / 16;
1956
- __m256i vec_yg, vec_yb, vec_ub, vec_vr, vec_ug, vec_vg;
1957
- __m256i vec_vrub, vec_vgug, vec_y, vec_vu;
1958
- __m256i out_b, out_g, out_r;
1959
- __m256i const_0x80 = __lasx_xvldi(0x80);
1960
-
1961
- YUVTORGB_SETUP(yuvconstants, vec_ub, vec_vr, vec_ug, vec_vg, vec_yg, vec_yb);
1962
- vec_vrub = __lasx_xvilvl_h(vec_vr, vec_ub);
1963
- vec_vgug = __lasx_xvilvl_h(vec_vg, vec_ug);
1964
-
1965
- for (x = 0; x < len; x++) {
1966
- vec_y = __lasx_xvld(src_y, 0);
1967
- vec_vu = __lasx_xvld(src_uv, 0);
1968
- vec_vu = __lasx_xvsub_b(vec_vu, const_0x80);
1969
- vec_vu = __lasx_vext2xv_h_b(vec_vu);
1970
- YUVTORGB(vec_y, vec_vu, vec_vrub, vec_vgug, vec_yg, vec_yb, out_r, out_g,
1971
- out_b);
1972
- out_b = __lasx_xvsrli_h(out_b, 3);
1973
- out_g = __lasx_xvsrli_h(out_g, 2);
1974
- out_r = __lasx_xvsrli_h(out_r, 3);
1975
- out_g = __lasx_xvslli_h(out_g, 5);
1976
- out_r = __lasx_xvslli_h(out_r, 11);
1977
- out_r = __lasx_xvor_v(out_r, out_g);
1978
- out_r = __lasx_xvor_v(out_r, out_b);
1979
- __lasx_xvst(out_r, dst_rgb565, 0);
1980
- src_y += 16;
1981
- src_uv += 16;
1982
- dst_rgb565 += 32;
1983
- }
1984
- }
1985
-
1986
- void NV21ToARGBRow_LASX(const uint8_t* src_y,
1987
- const uint8_t* src_uv,
1988
- uint8_t* dst_argb,
1989
- const struct YuvConstants* yuvconstants,
1990
- int width) {
1991
- int x;
1992
- int len = width / 16;
1993
- __m256i vec_yg, vec_yb, vec_ub, vec_vr, vec_ug, vec_vg;
1994
- __m256i vec_ubvr, vec_ugvg, vec_y, vec_uv;
1995
- __m256i out_b, out_g, out_r;
1996
- __m256i const_0x80 = __lasx_xvldi(0x80);
1997
- __m256i alpha = __lasx_xvldi(0xFF);
1998
-
1999
- YUVTORGB_SETUP(yuvconstants, vec_ub, vec_vr, vec_ug, vec_vg, vec_yg, vec_yb);
2000
- vec_ubvr = __lasx_xvilvl_h(vec_ub, vec_vr);
2001
- vec_ugvg = __lasx_xvilvl_h(vec_ug, vec_vg);
2002
-
2003
- for (x = 0; x < len; x++) {
2004
- vec_y = __lasx_xvld(src_y, 0);
2005
- vec_uv = __lasx_xvld(src_uv, 0);
2006
- vec_uv = __lasx_xvsub_b(vec_uv, const_0x80);
2007
- vec_uv = __lasx_vext2xv_h_b(vec_uv);
2008
- YUVTORGB(vec_y, vec_uv, vec_ubvr, vec_ugvg, vec_yg, vec_yb, out_b, out_g,
2009
- out_r);
2010
- STOREARGB(alpha, out_r, out_g, out_b, dst_argb);
2011
- src_y += 16;
2012
- src_uv += 16;
2013
- }
2014
- }
2015
-
2016
- #ifndef RgbConstants
2017
- struct RgbConstants {
2018
- uint8_t kRGBToY[4];
2019
- uint16_t kAddY;
2020
- uint16_t pad;
2021
- };
2022
- #define RgbConstants RgbConstants
2023
-
2024
- // RGB to JPeg coefficients
2025
- // B * 0.1140 coefficient = 29
2026
- // G * 0.5870 coefficient = 150
2027
- // R * 0.2990 coefficient = 77
2028
- // Add 0.5 = 0x80
2029
- static const struct RgbConstants kRgb24JPEGConstants = {{29, 150, 77, 0},
2030
- 128,
2031
- 0};
2032
-
2033
- static const struct RgbConstants kRawJPEGConstants = {{77, 150, 29, 0}, 128, 0};
2034
-
2035
- // RGB to BT.601 coefficients
2036
- // B * 0.1016 coefficient = 25
2037
- // G * 0.5078 coefficient = 129
2038
- // R * 0.2578 coefficient = 66
2039
- // Add 16.5 = 0x1080
2040
-
2041
- static const struct RgbConstants kRgb24I601Constants = {{25, 129, 66, 0},
2042
- 0x1080,
2043
- 0};
2044
-
2045
- static const struct RgbConstants kRawI601Constants = {{66, 129, 25, 0},
2046
- 0x1080,
2047
- 0};
2048
- #endif // RgbConstants
2049
-
2050
- // ARGB expects first 3 values to contain RGB and 4th value is ignored.
2051
- static void ARGBToYMatrixRow_LASX(const uint8_t* src_argb,
2052
- uint8_t* dst_y,
2053
- int width,
2054
- const struct RgbConstants* rgbconstants) {
2055
- int32_t shuff[8] = {0, 4, 1, 5, 2, 6, 3, 7};
2056
- asm volatile(
2057
- "xvldrepl.b $xr0, %3, 0 \n\t" // load rgbconstants
2058
- "xvldrepl.b $xr1, %3, 1 \n\t" // load rgbconstants
2059
- "xvldrepl.b $xr2, %3, 2 \n\t" // load rgbconstants
2060
- "xvldrepl.h $xr3, %3, 4 \n\t" // load rgbconstants
2061
- "xvld $xr20, %4, 0 \n\t" // load shuff
2062
- "1: \n\t"
2063
- "xvld $xr4, %0, 0 \n\t"
2064
- "xvld $xr5, %0, 32 \n\t"
2065
- "xvld $xr6, %0, 64 \n\t"
2066
- "xvld $xr7, %0, 96 \n\t" // load 32 pixels of
2067
- // ARGB
2068
- "xvor.v $xr12, $xr3, $xr3 \n\t"
2069
- "xvor.v $xr13, $xr3, $xr3 \n\t"
2070
- "addi.d %2, %2, -32 \n\t" // 32 processed per
2071
- // loop.
2072
- "xvpickev.b $xr8, $xr5, $xr4 \n\t" // BR
2073
- "xvpickev.b $xr10, $xr7, $xr6 \n\t"
2074
- "xvpickod.b $xr9, $xr5, $xr4 \n\t" // GA
2075
- "xvpickod.b $xr11, $xr7, $xr6 \n\t"
2076
- "xvmaddwev.h.bu $xr12, $xr8, $xr0 \n\t" // B
2077
- "xvmaddwev.h.bu $xr13, $xr10, $xr0 \n\t"
2078
- "xvmaddwev.h.bu $xr12, $xr9, $xr1 \n\t" // G
2079
- "xvmaddwev.h.bu $xr13, $xr11, $xr1 \n\t"
2080
- "xvmaddwod.h.bu $xr12, $xr8, $xr2 \n\t" // R
2081
- "xvmaddwod.h.bu $xr13, $xr10, $xr2 \n\t"
2082
- "addi.d %0, %0, 128 \n\t"
2083
- "xvpickod.b $xr10, $xr13, $xr12 \n\t"
2084
- "xvperm.w $xr11, $xr10, $xr20 \n\t"
2085
- "xvst $xr11, %1, 0 \n\t"
2086
- "addi.d %1, %1, 32 \n\t"
2087
- "bnez %2, 1b \n\t"
2088
- : "+&r"(src_argb), // %0
2089
- "+&r"(dst_y), // %1
2090
- "+&r"(width) // %2
2091
- : "r"(rgbconstants), "r"(shuff)
2092
- : "memory");
2093
- }
2094
-
2095
- void ARGBToYRow_LASX(const uint8_t* src_argb, uint8_t* dst_y, int width) {
2096
- ARGBToYMatrixRow_LASX(src_argb, dst_y, width, &kRgb24I601Constants);
2097
- }
2098
-
2099
- void ARGBToYJRow_LASX(const uint8_t* src_argb, uint8_t* dst_yj, int width) {
2100
- ARGBToYMatrixRow_LASX(src_argb, dst_yj, width, &kRgb24JPEGConstants);
2101
- }
2102
-
2103
- void ABGRToYRow_LASX(const uint8_t* src_abgr, uint8_t* dst_y, int width) {
2104
- ARGBToYMatrixRow_LASX(src_abgr, dst_y, width, &kRawI601Constants);
2105
- }
2106
-
2107
- void ABGRToYJRow_LASX(const uint8_t* src_abgr, uint8_t* dst_yj, int width) {
2108
- ARGBToYMatrixRow_LASX(src_abgr, dst_yj, width, &kRawJPEGConstants);
2109
- }
2110
-
2111
- // RGBA expects first value to be A and ignored, then 3 values to contain RGB.
2112
- // Same code as ARGB, except the LD4
2113
- static void RGBAToYMatrixRow_LASX(const uint8_t* src_rgba,
2114
- uint8_t* dst_y,
2115
- int width,
2116
- const struct RgbConstants* rgbconstants) {
2117
- int32_t shuff[8] = {0, 4, 1, 5, 2, 6, 3, 7};
2118
- asm volatile(
2119
- "xvldrepl.b $xr0, %3, 0 \n\t" // load rgbconstants
2120
- "xvldrepl.b $xr1, %3, 1 \n\t" // load rgbconstants
2121
- "xvldrepl.b $xr2, %3, 2 \n\t" // load rgbconstants
2122
- "xvldrepl.h $xr3, %3, 4 \n\t" // load rgbconstants
2123
- "xvld $xr20, %4, 0 \n\t" // load shuff
2124
- "1: \n\t"
2125
- "xvld $xr4, %0, 0 \n\t"
2126
- "xvld $xr5, %0, 32 \n\t"
2127
- "xvld $xr6, %0, 64 \n\t"
2128
- "xvld $xr7, %0, 96 \n\t" // load 32 pixels of
2129
- // RGBA
2130
- "xvor.v $xr12, $xr3, $xr3 \n\t"
2131
- "xvor.v $xr13, $xr3, $xr3 \n\t"
2132
- "addi.d %2, %2, -32 \n\t" // 32 processed per
2133
- // loop.
2134
- "xvpickev.b $xr8, $xr5, $xr4 \n\t" // AG
2135
- "xvpickev.b $xr10, $xr7, $xr6 \n\t"
2136
- "xvpickod.b $xr9, $xr5, $xr4 \n\t" // BR
2137
- "xvpickod.b $xr11, $xr7, $xr6 \n\t"
2138
- "xvmaddwev.h.bu $xr12, $xr9, $xr0 \n\t" // B
2139
- "xvmaddwev.h.bu $xr13, $xr11, $xr0 \n\t"
2140
- "xvmaddwod.h.bu $xr12, $xr8, $xr1 \n\t" // G
2141
- "xvmaddwod.h.bu $xr13, $xr10, $xr1 \n\t"
2142
- "xvmaddwod.h.bu $xr12, $xr9, $xr2 \n\t" // R
2143
- "xvmaddwod.h.bu $xr13, $xr11, $xr2 \n\t"
2144
- "addi.d %0, %0, 128 \n\t"
2145
- "xvpickod.b $xr10, $xr13, $xr12 \n\t"
2146
- "xvperm.w $xr11, $xr10, $xr20 \n\t"
2147
- "xvst $xr11, %1, 0 \n\t"
2148
- "addi.d %1, %1, 32 \n\t"
2149
- "bnez %2, 1b \n\t"
2150
- : "+&r"(src_rgba), // %0
2151
- "+&r"(dst_y), // %1
2152
- "+&r"(width) // %2
2153
- : "r"(rgbconstants), "r"(shuff)
2154
- : "memory");
2155
- }
2156
-
2157
- void RGBAToYRow_LASX(const uint8_t* src_rgba, uint8_t* dst_y, int width) {
2158
- RGBAToYMatrixRow_LASX(src_rgba, dst_y, width, &kRgb24I601Constants);
2159
- }
2160
-
2161
- void RGBAToYJRow_LASX(const uint8_t* src_rgba, uint8_t* dst_yj, int width) {
2162
- RGBAToYMatrixRow_LASX(src_rgba, dst_yj, width, &kRgb24JPEGConstants);
2163
- }
2164
-
2165
- void BGRAToYRow_LASX(const uint8_t* src_bgra, uint8_t* dst_y, int width) {
2166
- RGBAToYMatrixRow_LASX(src_bgra, dst_y, width, &kRawI601Constants);
2167
- }
2168
-
2169
- static void RGBToYMatrixRow_LASX(const uint8_t* src_rgba,
2170
- uint8_t* dst_y,
2171
- int width,
2172
- const struct RgbConstants* rgbconstants) {
2173
- int8_t shuff[128] = {
2174
- 0, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15, 17, 18, 20, 21, 23,
2175
- 0, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15, 17, 18, 20, 21, 23,
2176
- 24, 26, 27, 29, 30, 0, 1, 3, 4, 6, 7, 9, 10, 12, 13, 15,
2177
- 24, 26, 27, 29, 30, 0, 1, 3, 4, 6, 7, 9, 10, 12, 13, 15,
2178
- 1, 0, 4, 0, 7, 0, 10, 0, 13, 0, 16, 0, 19, 0, 22, 0,
2179
- 1, 0, 4, 0, 7, 0, 10, 0, 13, 0, 16, 0, 19, 0, 22, 0,
2180
- 25, 0, 28, 0, 31, 0, 2, 0, 5, 0, 8, 0, 11, 0, 14, 0,
2181
- 25, 0, 28, 0, 31, 0, 2, 0, 5, 0, 8, 0, 11, 0, 14, 0};
2182
- asm volatile(
2183
- "xvldrepl.b $xr0, %3, 0 \n\t" // load rgbconstants
2184
- "xvldrepl.b $xr1, %3, 1 \n\t" // load rgbconstants
2185
- "xvldrepl.b $xr2, %3, 2 \n\t" // load rgbconstants
2186
- "xvldrepl.h $xr3, %3, 4 \n\t" // load rgbconstants
2187
- "xvld $xr4, %4, 0 \n\t" // load shuff
2188
- "xvld $xr5, %4, 32 \n\t"
2189
- "xvld $xr6, %4, 64 \n\t"
2190
- "xvld $xr7, %4, 96 \n\t"
2191
- "1: \n\t"
2192
- "xvld $xr8, %0, 0 \n\t"
2193
- "xvld $xr9, %0, 32 \n\t"
2194
- "xvld $xr10, %0, 64 \n\t" // load 32 pixels of
2195
- // RGB
2196
- "xvor.v $xr12, $xr3, $xr3 \n\t"
2197
- "xvor.v $xr13, $xr3, $xr3 \n\t"
2198
- "xvor.v $xr11, $xr9, $xr9 \n\t"
2199
- "addi.d %2, %2, -32 \n\t" // 32 processed per
2200
- // loop.
2201
- "xvpermi.q $xr9, $xr8, 0x30 \n\t" // src0
2202
- "xvpermi.q $xr8, $xr10, 0x03 \n\t" // src1
2203
- "xvpermi.q $xr10, $xr11, 0x30 \n\t" // src2
2204
- "xvshuf.b $xr14, $xr8, $xr9, $xr4 \n\t"
2205
- "xvshuf.b $xr15, $xr8, $xr10, $xr5 \n\t"
2206
- "xvshuf.b $xr16, $xr8, $xr9, $xr6 \n\t"
2207
- "xvshuf.b $xr17, $xr8, $xr10, $xr7 \n\t"
2208
- "xvmaddwev.h.bu $xr12, $xr16, $xr1 \n\t" // G
2209
- "xvmaddwev.h.bu $xr13, $xr17, $xr1 \n\t"
2210
- "xvmaddwev.h.bu $xr12, $xr14, $xr0 \n\t" // B
2211
- "xvmaddwev.h.bu $xr13, $xr15, $xr0 \n\t"
2212
- "xvmaddwod.h.bu $xr12, $xr14, $xr2 \n\t" // R
2213
- "xvmaddwod.h.bu $xr13, $xr15, $xr2 \n\t"
2214
- "addi.d %0, %0, 96 \n\t"
2215
- "xvpickod.b $xr10, $xr13, $xr12 \n\t"
2216
- "xvst $xr10, %1, 0 \n\t"
2217
- "addi.d %1, %1, 32 \n\t"
2218
- "bnez %2, 1b \n\t"
2219
- : "+&r"(src_rgba), // %0
2220
- "+&r"(dst_y), // %1
2221
- "+&r"(width) // %2
2222
- : "r"(rgbconstants), // %3
2223
- "r"(shuff) // %4
2224
- : "memory");
2225
- }
2226
-
2227
- void RGB24ToYJRow_LASX(const uint8_t* src_rgb24, uint8_t* dst_yj, int width) {
2228
- RGBToYMatrixRow_LASX(src_rgb24, dst_yj, width, &kRgb24JPEGConstants);
2229
- }
2230
-
2231
- void RAWToYJRow_LASX(const uint8_t* src_raw, uint8_t* dst_yj, int width) {
2232
- RGBToYMatrixRow_LASX(src_raw, dst_yj, width, &kRawJPEGConstants);
2233
- }
2234
-
2235
- void RGB24ToYRow_LASX(const uint8_t* src_rgb24, uint8_t* dst_y, int width) {
2236
- RGBToYMatrixRow_LASX(src_rgb24, dst_y, width, &kRgb24I601Constants);
2237
- }
2238
-
2239
- void RAWToYRow_LASX(const uint8_t* src_raw, uint8_t* dst_y, int width) {
2240
- RGBToYMatrixRow_LASX(src_raw, dst_y, width, &kRawI601Constants);
2241
- }
2242
-
2243
- void ARGBToUVJRow_LASX(const uint8_t* src_argb,
2244
- int src_stride_argb,
2245
- uint8_t* dst_u,
2246
- uint8_t* dst_v,
2247
- int width) {
2248
- int x;
2249
- const uint8_t* next_argb = src_argb + src_stride_argb;
2250
- int len = width / 32;
2251
- __m256i src0, src1, src2, src3;
2252
- __m256i nex0, nex1, nex2, nex3;
2253
- __m256i tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
2254
- __m256i reg0, reg1, dst0;
2255
- __m256i tmpb, tmpg, tmpr, nexb, nexg, nexr;
2256
- __m256i const_128 = __lasx_xvldi(0x480);
2257
- __m256i const_85 = __lasx_xvldi(0x455);
2258
- __m256i const_43 = __lasx_xvldi(0x42B);
2259
- __m256i const_107 = __lasx_xvldi(0x46B);
2260
- __m256i const_21 = __lasx_xvldi(0x415);
2261
- __m256i const_8000 = (__m256i)v4u64{0x8000800080008000, 0x8000800080008000,
2262
- 0x8000800080008000, 0x8000800080008000};
2263
- __m256i shuff = {0x1614060412100200, 0x1E1C0E0C1A180A08, 0x1715070513110301,
2264
- 0x1F1D0F0D1B190B09};
2265
-
2266
- for (x = 0; x < len; x++) {
2267
- DUP4_ARG2(__lasx_xvld, src_argb, 0, src_argb, 32, src_argb, 64, src_argb,
2268
- 96, src0, src1, src2, src3);
2269
- DUP4_ARG2(__lasx_xvld, next_argb, 0, next_argb, 32, next_argb, 64,
2270
- next_argb, 96, nex0, nex1, nex2, nex3);
2271
- tmp0 = __lasx_xvpickev_b(src1, src0);
2272
- tmp1 = __lasx_xvpickod_b(src1, src0);
2273
- tmp2 = __lasx_xvpickev_b(src3, src2);
2274
- tmp3 = __lasx_xvpickod_b(src3, src2);
2275
- tmpr = __lasx_xvpickod_b(tmp2, tmp0);
2276
- tmpb = __lasx_xvpickev_b(tmp2, tmp0);
2277
- tmpg = __lasx_xvpickev_b(tmp3, tmp1);
2278
- tmp0 = __lasx_xvpickev_b(nex1, nex0);
2279
- tmp1 = __lasx_xvpickod_b(nex1, nex0);
2280
- tmp2 = __lasx_xvpickev_b(nex3, nex2);
2281
- tmp3 = __lasx_xvpickod_b(nex3, nex2);
2282
- nexr = __lasx_xvpickod_b(tmp2, tmp0);
2283
- nexb = __lasx_xvpickev_b(tmp2, tmp0);
2284
- nexg = __lasx_xvpickev_b(tmp3, tmp1);
2285
- tmp0 = __lasx_xvaddwev_h_bu(tmpb, nexb);
2286
- tmp1 = __lasx_xvaddwod_h_bu(tmpb, nexb);
2287
- tmp2 = __lasx_xvaddwev_h_bu(tmpg, nexg);
2288
- tmp3 = __lasx_xvaddwod_h_bu(tmpg, nexg);
2289
- reg0 = __lasx_xvaddwev_h_bu(tmpr, nexr);
2290
- reg1 = __lasx_xvaddwod_h_bu(tmpr, nexr);
2291
- tmp4 = __lasx_xvaddwev_w_hu(tmp0, tmp1);
2292
- tmp5 = __lasx_xvaddwod_w_hu(tmp0, tmp1);
2293
- tmp0 = __lasx_xvilvl_w(tmp5, tmp4);
2294
- tmp1 = __lasx_xvilvh_w(tmp5, tmp4);
2295
- tmpb = __lasx_xvssrarni_hu_w(tmp1, tmp0, 2);
2296
- tmp4 = __lasx_xvaddwev_w_hu(tmp2, tmp3);
2297
- tmp5 = __lasx_xvaddwod_w_hu(tmp2, tmp3);
2298
- tmp2 = __lasx_xvilvl_w(tmp5, tmp4);
2299
- tmp3 = __lasx_xvilvh_w(tmp5, tmp4);
2300
- tmpg = __lasx_xvssrarni_hu_w(tmp3, tmp2, 2);
2301
- tmp4 = __lasx_xvaddwev_w_hu(reg0, reg1);
2302
- tmp5 = __lasx_xvaddwod_w_hu(reg0, reg1);
2303
- tmp0 = __lasx_xvilvl_w(tmp5, tmp4);
2304
- tmp1 = __lasx_xvilvh_w(tmp5, tmp4);
2305
- tmpr = __lasx_xvssrarni_hu_w(tmp1, tmp0, 2);
2306
- reg0 = __lasx_xvmadd_h(const_8000, const_128, tmpb);
2307
- reg1 = __lasx_xvmadd_h(const_8000, const_128, tmpr);
2308
- reg0 = __lasx_xvmsub_h(reg0, const_85, tmpg);
2309
- reg1 = __lasx_xvmsub_h(reg1, const_107, tmpg);
2310
- reg0 = __lasx_xvmsub_h(reg0, const_43, tmpr);
2311
- reg1 = __lasx_xvmsub_h(reg1, const_21, tmpb);
2312
- dst0 = __lasx_xvpackod_b(reg1, reg0);
2313
- tmp0 = __lasx_xvpermi_d(dst0, 0x44);
2314
- tmp1 = __lasx_xvpermi_d(dst0, 0xEE);
2315
- dst0 = __lasx_xvshuf_b(tmp1, tmp0, shuff);
2316
- __lasx_xvstelm_d(dst0, dst_u, 0, 0);
2317
- __lasx_xvstelm_d(dst0, dst_v, 0, 2);
2318
- __lasx_xvstelm_d(dst0, dst_u, 8, 1);
2319
- __lasx_xvstelm_d(dst0, dst_v, 8, 3);
2320
- dst_u += 16;
2321
- dst_v += 16;
2322
- src_argb += 128;
2323
- next_argb += 128;
2324
- }
2325
- }
2326
-
2327
- // undef for unified sources build
2328
- #undef ALPHA_VAL
2329
- #undef YUVTORGB_SETUP
2330
- #undef READYUV422_D
2331
- #undef READYUV422
2332
- #undef YUVTORGB_D
2333
- #undef YUVTORGB
2334
- #undef STOREARGB_D
2335
- #undef STOREARGB
2336
- #undef RGBTOUV
2337
-
2338
- #ifdef __cplusplus
2339
- } // extern "C"
2340
- } // namespace libyuv
2341
- #endif
2342
-
2343
- #endif // !defined(LIBYUV_DISABLE_LASX) && defined(__loongarch_asx)