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,866 +0,0 @@
1
- /*
2
- * Copyright 2012 The LibYuv Project Authors. All rights reserved.
3
- *
4
- * Use of this source code is governed by a BSD-style license
5
- * that can be found in the LICENSE file in the root of the source
6
- * tree. An additional intellectual property rights grant can be found
7
- * in the file PATENTS. All contributing project authors may
8
- * be found in the AUTHORS file in the root of the source tree.
9
- */
10
-
11
- #include "libyuv/convert_from.h"
12
-
13
- #include "libyuv/basic_types.h"
14
- #include "libyuv/convert.h" // For I420Copy
15
- #include "libyuv/cpu_id.h"
16
- #include "libyuv/planar_functions.h"
17
- #include "libyuv/rotate.h"
18
- #include "libyuv/row.h"
19
- #include "libyuv/scale.h" // For ScalePlane()
20
- #include "libyuv/video_common.h"
21
-
22
- #ifdef __cplusplus
23
- namespace libyuv {
24
- extern "C" {
25
- #endif
26
-
27
- #define SUBSAMPLE(v, a, s) (v < 0) ? (-((-v + a) >> s)) : ((v + a) >> s)
28
- static __inline int Abs(int v) {
29
- return v >= 0 ? v : -v;
30
- }
31
-
32
- // I420 To any I4xx YUV format with mirroring.
33
- static int I420ToI4xx(const uint8_t* src_y,
34
- int src_stride_y,
35
- const uint8_t* src_u,
36
- int src_stride_u,
37
- const uint8_t* src_v,
38
- int src_stride_v,
39
- uint8_t* dst_y,
40
- int dst_stride_y,
41
- uint8_t* dst_u,
42
- int dst_stride_u,
43
- uint8_t* dst_v,
44
- int dst_stride_v,
45
- int src_y_width,
46
- int src_y_height,
47
- int dst_uv_width,
48
- int dst_uv_height) {
49
- const int src_uv_width = SUBSAMPLE(src_y_width, 1, 1);
50
- const int src_uv_height = SUBSAMPLE(src_y_height, 1, 1);
51
- int r;
52
- if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v ||
53
- src_y_width <= 0 || src_y_height == 0 || dst_uv_width <= 0 ||
54
- dst_uv_height <= 0) {
55
- return -1;
56
- }
57
- if (dst_y) {
58
- CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, src_y_width,
59
- src_y_height);
60
- }
61
- r = ScalePlane(src_u, src_stride_u, src_uv_width, src_uv_height, dst_u,
62
- dst_stride_u, dst_uv_width, dst_uv_height, kFilterBilinear);
63
- if (r != 0) {
64
- return r;
65
- }
66
- r = ScalePlane(src_v, src_stride_v, src_uv_width, src_uv_height, dst_v,
67
- dst_stride_v, dst_uv_width, dst_uv_height, kFilterBilinear);
68
- return r;
69
- }
70
-
71
- // Convert 8 bit YUV to 10 bit.
72
- LIBYUV_API
73
- int I420ToI010(const uint8_t* src_y,
74
- int src_stride_y,
75
- const uint8_t* src_u,
76
- int src_stride_u,
77
- const uint8_t* src_v,
78
- int src_stride_v,
79
- uint16_t* dst_y,
80
- int dst_stride_y,
81
- uint16_t* dst_u,
82
- int dst_stride_u,
83
- uint16_t* dst_v,
84
- int dst_stride_v,
85
- int width,
86
- int height) {
87
- int halfwidth = (width + 1) >> 1;
88
- int halfheight = (height + 1) >> 1;
89
- if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
90
- height == 0) {
91
- return -1;
92
- }
93
- // Negative height means invert the image.
94
- if (height < 0) {
95
- height = -height;
96
- halfheight = (height + 1) >> 1;
97
- src_y = src_y + (height - 1) * src_stride_y;
98
- src_u = src_u + (halfheight - 1) * src_stride_u;
99
- src_v = src_v + (halfheight - 1) * src_stride_v;
100
- src_stride_y = -src_stride_y;
101
- src_stride_u = -src_stride_u;
102
- src_stride_v = -src_stride_v;
103
- }
104
-
105
- // Convert Y plane.
106
- Convert8To16Plane(src_y, src_stride_y, dst_y, dst_stride_y, 1024, width,
107
- height);
108
- // Convert UV planes.
109
- Convert8To16Plane(src_u, src_stride_u, dst_u, dst_stride_u, 1024, halfwidth,
110
- halfheight);
111
- Convert8To16Plane(src_v, src_stride_v, dst_v, dst_stride_v, 1024, halfwidth,
112
- halfheight);
113
- return 0;
114
- }
115
-
116
- // Convert 8 bit YUV to 12 bit.
117
- LIBYUV_API
118
- int I420ToI012(const uint8_t* src_y,
119
- int src_stride_y,
120
- const uint8_t* src_u,
121
- int src_stride_u,
122
- const uint8_t* src_v,
123
- int src_stride_v,
124
- uint16_t* dst_y,
125
- int dst_stride_y,
126
- uint16_t* dst_u,
127
- int dst_stride_u,
128
- uint16_t* dst_v,
129
- int dst_stride_v,
130
- int width,
131
- int height) {
132
- int halfwidth = (width + 1) >> 1;
133
- int halfheight = (height + 1) >> 1;
134
- if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
135
- height == 0) {
136
- return -1;
137
- }
138
- // Negative height means invert the image.
139
- if (height < 0) {
140
- height = -height;
141
- halfheight = (height + 1) >> 1;
142
- src_y = src_y + (height - 1) * src_stride_y;
143
- src_u = src_u + (halfheight - 1) * src_stride_u;
144
- src_v = src_v + (halfheight - 1) * src_stride_v;
145
- src_stride_y = -src_stride_y;
146
- src_stride_u = -src_stride_u;
147
- src_stride_v = -src_stride_v;
148
- }
149
-
150
- // Convert Y plane.
151
- Convert8To16Plane(src_y, src_stride_y, dst_y, dst_stride_y, 4096, width,
152
- height);
153
- // Convert UV planes.
154
- Convert8To16Plane(src_u, src_stride_u, dst_u, dst_stride_u, 4096, halfwidth,
155
- halfheight);
156
- Convert8To16Plane(src_v, src_stride_v, dst_v, dst_stride_v, 4096, halfwidth,
157
- halfheight);
158
- return 0;
159
- }
160
-
161
- // 420 chroma is 1/2 width, 1/2 height
162
- // 422 chroma is 1/2 width, 1x height
163
- LIBYUV_API
164
- int I420ToI422(const uint8_t* src_y,
165
- int src_stride_y,
166
- const uint8_t* src_u,
167
- int src_stride_u,
168
- const uint8_t* src_v,
169
- int src_stride_v,
170
- uint8_t* dst_y,
171
- int dst_stride_y,
172
- uint8_t* dst_u,
173
- int dst_stride_u,
174
- uint8_t* dst_v,
175
- int dst_stride_v,
176
- int width,
177
- int height) {
178
- const int dst_uv_width = (Abs(width) + 1) >> 1;
179
- const int dst_uv_height = Abs(height);
180
- return I420ToI4xx(src_y, src_stride_y, src_u, src_stride_u, src_v,
181
- src_stride_v, dst_y, dst_stride_y, dst_u, dst_stride_u,
182
- dst_v, dst_stride_v, width, height, dst_uv_width,
183
- dst_uv_height);
184
- }
185
-
186
- // 420 chroma is 1/2 width, 1/2 height
187
- // 444 chroma is 1x width, 1x height
188
- LIBYUV_API
189
- int I420ToI444(const uint8_t* src_y,
190
- int src_stride_y,
191
- const uint8_t* src_u,
192
- int src_stride_u,
193
- const uint8_t* src_v,
194
- int src_stride_v,
195
- uint8_t* dst_y,
196
- int dst_stride_y,
197
- uint8_t* dst_u,
198
- int dst_stride_u,
199
- uint8_t* dst_v,
200
- int dst_stride_v,
201
- int width,
202
- int height) {
203
- const int dst_uv_width = Abs(width);
204
- const int dst_uv_height = Abs(height);
205
- return I420ToI4xx(src_y, src_stride_y, src_u, src_stride_u, src_v,
206
- src_stride_v, dst_y, dst_stride_y, dst_u, dst_stride_u,
207
- dst_v, dst_stride_v, width, height, dst_uv_width,
208
- dst_uv_height);
209
- }
210
-
211
- // 420 chroma to 444 chroma, 10/12 bit version
212
- LIBYUV_API
213
- int I010ToI410(const uint16_t* src_y,
214
- int src_stride_y,
215
- const uint16_t* src_u,
216
- int src_stride_u,
217
- const uint16_t* src_v,
218
- int src_stride_v,
219
- uint16_t* dst_y,
220
- int dst_stride_y,
221
- uint16_t* dst_u,
222
- int dst_stride_u,
223
- uint16_t* dst_v,
224
- int dst_stride_v,
225
- int width,
226
- int height) {
227
- int r;
228
- if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
229
- height == 0) {
230
- return -1;
231
- }
232
-
233
- if (dst_y) {
234
- CopyPlane_16(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
235
- }
236
- r = ScalePlane_12(src_u, src_stride_u, SUBSAMPLE(width, 1, 1),
237
- SUBSAMPLE(height, 1, 1), dst_u, dst_stride_u, width,
238
- Abs(height), kFilterBilinear);
239
- if (r != 0) {
240
- return r;
241
- }
242
- r = ScalePlane_12(src_v, src_stride_v, SUBSAMPLE(width, 1, 1),
243
- SUBSAMPLE(height, 1, 1), dst_v, dst_stride_v, width,
244
- Abs(height), kFilterBilinear);
245
- return r;
246
- }
247
-
248
- // 422 chroma to 444 chroma, 10/12 bit version
249
- LIBYUV_API
250
- int I210ToI410(const uint16_t* src_y,
251
- int src_stride_y,
252
- const uint16_t* src_u,
253
- int src_stride_u,
254
- const uint16_t* src_v,
255
- int src_stride_v,
256
- uint16_t* dst_y,
257
- int dst_stride_y,
258
- uint16_t* dst_u,
259
- int dst_stride_u,
260
- uint16_t* dst_v,
261
- int dst_stride_v,
262
- int width,
263
- int height) {
264
- int r;
265
- if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
266
- height == 0) {
267
- return -1;
268
- }
269
-
270
- if (dst_y) {
271
- CopyPlane_16(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
272
- }
273
- r = ScalePlane_12(src_u, src_stride_u, SUBSAMPLE(width, 1, 1), height, dst_u,
274
- dst_stride_u, width, Abs(height), kFilterBilinear);
275
- if (r != 0) {
276
- return r;
277
- }
278
- r = ScalePlane_12(src_v, src_stride_v, SUBSAMPLE(width, 1, 1), height, dst_v,
279
- dst_stride_v, width, Abs(height), kFilterBilinear);
280
- return r;
281
- }
282
-
283
- // 422 chroma is 1/2 width, 1x height
284
- // 444 chroma is 1x width, 1x height
285
- LIBYUV_API
286
- int I422ToI444(const uint8_t* src_y,
287
- int src_stride_y,
288
- const uint8_t* src_u,
289
- int src_stride_u,
290
- const uint8_t* src_v,
291
- int src_stride_v,
292
- uint8_t* dst_y,
293
- int dst_stride_y,
294
- uint8_t* dst_u,
295
- int dst_stride_u,
296
- uint8_t* dst_v,
297
- int dst_stride_v,
298
- int width,
299
- int height) {
300
- int r;
301
- if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
302
- height == 0) {
303
- return -1;
304
- }
305
-
306
- if (dst_y) {
307
- CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
308
- }
309
- r = ScalePlane(src_u, src_stride_u, SUBSAMPLE(width, 1, 1), height, dst_u,
310
- dst_stride_u, width, Abs(height), kFilterBilinear);
311
- if (r != 0) {
312
- return r;
313
- }
314
- r = ScalePlane(src_v, src_stride_v, SUBSAMPLE(width, 1, 1), height, dst_v,
315
- dst_stride_v, width, Abs(height), kFilterBilinear);
316
- return r;
317
- }
318
-
319
- // Copy to I400. Source can be I420,422,444,400,NV12,NV21
320
- LIBYUV_API
321
- int I400Copy(const uint8_t* src_y,
322
- int src_stride_y,
323
- uint8_t* dst_y,
324
- int dst_stride_y,
325
- int width,
326
- int height) {
327
- if (!src_y || !dst_y || width <= 0 || height == 0) {
328
- return -1;
329
- }
330
- CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
331
- return 0;
332
- }
333
-
334
- LIBYUV_API
335
- int I422ToYUY2(const uint8_t* src_y,
336
- int src_stride_y,
337
- const uint8_t* src_u,
338
- int src_stride_u,
339
- const uint8_t* src_v,
340
- int src_stride_v,
341
- uint8_t* dst_yuy2,
342
- int dst_stride_yuy2,
343
- int width,
344
- int height) {
345
- int y;
346
- void (*I422ToYUY2Row)(const uint8_t* src_y, const uint8_t* src_u,
347
- const uint8_t* src_v, uint8_t* dst_yuy2, int width) =
348
- I422ToYUY2Row_C;
349
- if (!src_y || !src_u || !src_v || !dst_yuy2 || width <= 0 || height == 0) {
350
- return -1;
351
- }
352
- // Negative height means invert the image.
353
- if (height < 0) {
354
- height = -height;
355
- dst_yuy2 = dst_yuy2 + (height - 1) * dst_stride_yuy2;
356
- dst_stride_yuy2 = -dst_stride_yuy2;
357
- }
358
- // Coalesce rows.
359
- if (src_stride_y == width && src_stride_u * 2 == width &&
360
- src_stride_v * 2 == width && dst_stride_yuy2 == width * 2) {
361
- width *= height;
362
- height = 1;
363
- src_stride_y = src_stride_u = src_stride_v = dst_stride_yuy2 = 0;
364
- }
365
- #if defined(HAS_I422TOYUY2ROW_SSE2)
366
- if (TestCpuFlag(kCpuHasSSE2)) {
367
- I422ToYUY2Row = I422ToYUY2Row_Any_SSE2;
368
- if (IS_ALIGNED(width, 16)) {
369
- I422ToYUY2Row = I422ToYUY2Row_SSE2;
370
- }
371
- }
372
- #endif
373
- #if defined(HAS_I422TOYUY2ROW_AVX2)
374
- if (TestCpuFlag(kCpuHasAVX2)) {
375
- I422ToYUY2Row = I422ToYUY2Row_Any_AVX2;
376
- if (IS_ALIGNED(width, 32)) {
377
- I422ToYUY2Row = I422ToYUY2Row_AVX2;
378
- }
379
- }
380
- #endif
381
- #if defined(HAS_I422TOYUY2ROW_NEON)
382
- if (TestCpuFlag(kCpuHasNEON)) {
383
- I422ToYUY2Row = I422ToYUY2Row_Any_NEON;
384
- if (IS_ALIGNED(width, 16)) {
385
- I422ToYUY2Row = I422ToYUY2Row_NEON;
386
- }
387
- }
388
- #endif
389
-
390
- for (y = 0; y < height; ++y) {
391
- I422ToYUY2Row(src_y, src_u, src_v, dst_yuy2, width);
392
- src_y += src_stride_y;
393
- src_u += src_stride_u;
394
- src_v += src_stride_v;
395
- dst_yuy2 += dst_stride_yuy2;
396
- }
397
- return 0;
398
- }
399
-
400
- LIBYUV_API
401
- int I420ToYUY2(const uint8_t* src_y,
402
- int src_stride_y,
403
- const uint8_t* src_u,
404
- int src_stride_u,
405
- const uint8_t* src_v,
406
- int src_stride_v,
407
- uint8_t* dst_yuy2,
408
- int dst_stride_yuy2,
409
- int width,
410
- int height) {
411
- int y;
412
- void (*I422ToYUY2Row)(const uint8_t* src_y, const uint8_t* src_u,
413
- const uint8_t* src_v, uint8_t* dst_yuy2, int width) =
414
- I422ToYUY2Row_C;
415
- if (!src_y || !src_u || !src_v || !dst_yuy2 || width <= 0 || height == 0) {
416
- return -1;
417
- }
418
- // Negative height means invert the image.
419
- if (height < 0) {
420
- height = -height;
421
- dst_yuy2 = dst_yuy2 + (height - 1) * dst_stride_yuy2;
422
- dst_stride_yuy2 = -dst_stride_yuy2;
423
- }
424
- #if defined(HAS_I422TOYUY2ROW_SSE2)
425
- if (TestCpuFlag(kCpuHasSSE2)) {
426
- I422ToYUY2Row = I422ToYUY2Row_Any_SSE2;
427
- if (IS_ALIGNED(width, 16)) {
428
- I422ToYUY2Row = I422ToYUY2Row_SSE2;
429
- }
430
- }
431
- #endif
432
- #if defined(HAS_I422TOYUY2ROW_AVX2)
433
- if (TestCpuFlag(kCpuHasAVX2)) {
434
- I422ToYUY2Row = I422ToYUY2Row_Any_AVX2;
435
- if (IS_ALIGNED(width, 32)) {
436
- I422ToYUY2Row = I422ToYUY2Row_AVX2;
437
- }
438
- }
439
- #endif
440
- #if defined(HAS_I422TOYUY2ROW_NEON)
441
- if (TestCpuFlag(kCpuHasNEON)) {
442
- I422ToYUY2Row = I422ToYUY2Row_Any_NEON;
443
- if (IS_ALIGNED(width, 16)) {
444
- I422ToYUY2Row = I422ToYUY2Row_NEON;
445
- }
446
- }
447
- #endif
448
- #if defined(HAS_I422TOYUY2ROW_LSX)
449
- if (TestCpuFlag(kCpuHasLSX)) {
450
- I422ToYUY2Row = I422ToYUY2Row_Any_LSX;
451
- if (IS_ALIGNED(width, 16)) {
452
- I422ToYUY2Row = I422ToYUY2Row_LSX;
453
- }
454
- }
455
- #endif
456
- #if defined(HAS_I422TOYUY2ROW_LASX)
457
- if (TestCpuFlag(kCpuHasLASX)) {
458
- I422ToYUY2Row = I422ToYUY2Row_Any_LASX;
459
- if (IS_ALIGNED(width, 32)) {
460
- I422ToYUY2Row = I422ToYUY2Row_LASX;
461
- }
462
- }
463
- #endif
464
-
465
- for (y = 0; y < height - 1; y += 2) {
466
- I422ToYUY2Row(src_y, src_u, src_v, dst_yuy2, width);
467
- I422ToYUY2Row(src_y + src_stride_y, src_u, src_v,
468
- dst_yuy2 + dst_stride_yuy2, width);
469
- src_y += src_stride_y * 2;
470
- src_u += src_stride_u;
471
- src_v += src_stride_v;
472
- dst_yuy2 += dst_stride_yuy2 * 2;
473
- }
474
- if (height & 1) {
475
- I422ToYUY2Row(src_y, src_u, src_v, dst_yuy2, width);
476
- }
477
- return 0;
478
- }
479
-
480
- LIBYUV_API
481
- int I422ToUYVY(const uint8_t* src_y,
482
- int src_stride_y,
483
- const uint8_t* src_u,
484
- int src_stride_u,
485
- const uint8_t* src_v,
486
- int src_stride_v,
487
- uint8_t* dst_uyvy,
488
- int dst_stride_uyvy,
489
- int width,
490
- int height) {
491
- int y;
492
- void (*I422ToUYVYRow)(const uint8_t* src_y, const uint8_t* src_u,
493
- const uint8_t* src_v, uint8_t* dst_uyvy, int width) =
494
- I422ToUYVYRow_C;
495
- if (!src_y || !src_u || !src_v || !dst_uyvy || width <= 0 || height == 0) {
496
- return -1;
497
- }
498
- // Negative height means invert the image.
499
- if (height < 0) {
500
- height = -height;
501
- dst_uyvy = dst_uyvy + (height - 1) * dst_stride_uyvy;
502
- dst_stride_uyvy = -dst_stride_uyvy;
503
- }
504
- // Coalesce rows.
505
- if (src_stride_y == width && src_stride_u * 2 == width &&
506
- src_stride_v * 2 == width && dst_stride_uyvy == width * 2) {
507
- width *= height;
508
- height = 1;
509
- src_stride_y = src_stride_u = src_stride_v = dst_stride_uyvy = 0;
510
- }
511
- #if defined(HAS_I422TOUYVYROW_SSE2)
512
- if (TestCpuFlag(kCpuHasSSE2)) {
513
- I422ToUYVYRow = I422ToUYVYRow_Any_SSE2;
514
- if (IS_ALIGNED(width, 16)) {
515
- I422ToUYVYRow = I422ToUYVYRow_SSE2;
516
- }
517
- }
518
- #endif
519
- #if defined(HAS_I422TOUYVYROW_AVX2)
520
- if (TestCpuFlag(kCpuHasAVX2)) {
521
- I422ToUYVYRow = I422ToUYVYRow_Any_AVX2;
522
- if (IS_ALIGNED(width, 32)) {
523
- I422ToUYVYRow = I422ToUYVYRow_AVX2;
524
- }
525
- }
526
- #endif
527
- #if defined(HAS_I422TOUYVYROW_NEON)
528
- if (TestCpuFlag(kCpuHasNEON)) {
529
- I422ToUYVYRow = I422ToUYVYRow_Any_NEON;
530
- if (IS_ALIGNED(width, 16)) {
531
- I422ToUYVYRow = I422ToUYVYRow_NEON;
532
- }
533
- }
534
- #endif
535
- #if defined(HAS_I422TOUYVYROW_LSX)
536
- if (TestCpuFlag(kCpuHasLSX)) {
537
- I422ToUYVYRow = I422ToUYVYRow_Any_LSX;
538
- if (IS_ALIGNED(width, 16)) {
539
- I422ToUYVYRow = I422ToUYVYRow_LSX;
540
- }
541
- }
542
- #endif
543
- #if defined(HAS_I422TOUYVYROW_LASX)
544
- if (TestCpuFlag(kCpuHasLASX)) {
545
- I422ToUYVYRow = I422ToUYVYRow_Any_LASX;
546
- if (IS_ALIGNED(width, 32)) {
547
- I422ToUYVYRow = I422ToUYVYRow_LASX;
548
- }
549
- }
550
- #endif
551
-
552
- for (y = 0; y < height; ++y) {
553
- I422ToUYVYRow(src_y, src_u, src_v, dst_uyvy, width);
554
- src_y += src_stride_y;
555
- src_u += src_stride_u;
556
- src_v += src_stride_v;
557
- dst_uyvy += dst_stride_uyvy;
558
- }
559
- return 0;
560
- }
561
-
562
- LIBYUV_API
563
- int I420ToUYVY(const uint8_t* src_y,
564
- int src_stride_y,
565
- const uint8_t* src_u,
566
- int src_stride_u,
567
- const uint8_t* src_v,
568
- int src_stride_v,
569
- uint8_t* dst_uyvy,
570
- int dst_stride_uyvy,
571
- int width,
572
- int height) {
573
- int y;
574
- void (*I422ToUYVYRow)(const uint8_t* src_y, const uint8_t* src_u,
575
- const uint8_t* src_v, uint8_t* dst_uyvy, int width) =
576
- I422ToUYVYRow_C;
577
- if (!src_y || !src_u || !src_v || !dst_uyvy || width <= 0 || height == 0) {
578
- return -1;
579
- }
580
- // Negative height means invert the image.
581
- if (height < 0) {
582
- height = -height;
583
- dst_uyvy = dst_uyvy + (height - 1) * dst_stride_uyvy;
584
- dst_stride_uyvy = -dst_stride_uyvy;
585
- }
586
- #if defined(HAS_I422TOUYVYROW_SSE2)
587
- if (TestCpuFlag(kCpuHasSSE2)) {
588
- I422ToUYVYRow = I422ToUYVYRow_Any_SSE2;
589
- if (IS_ALIGNED(width, 16)) {
590
- I422ToUYVYRow = I422ToUYVYRow_SSE2;
591
- }
592
- }
593
- #endif
594
- #if defined(HAS_I422TOUYVYROW_AVX2)
595
- if (TestCpuFlag(kCpuHasAVX2)) {
596
- I422ToUYVYRow = I422ToUYVYRow_Any_AVX2;
597
- if (IS_ALIGNED(width, 32)) {
598
- I422ToUYVYRow = I422ToUYVYRow_AVX2;
599
- }
600
- }
601
- #endif
602
- #if defined(HAS_I422TOUYVYROW_NEON)
603
- if (TestCpuFlag(kCpuHasNEON)) {
604
- I422ToUYVYRow = I422ToUYVYRow_Any_NEON;
605
- if (IS_ALIGNED(width, 16)) {
606
- I422ToUYVYRow = I422ToUYVYRow_NEON;
607
- }
608
- }
609
- #endif
610
- #if defined(HAS_I422TOUYVYROW_LSX)
611
- if (TestCpuFlag(kCpuHasLSX)) {
612
- I422ToUYVYRow = I422ToUYVYRow_Any_LSX;
613
- if (IS_ALIGNED(width, 16)) {
614
- I422ToUYVYRow = I422ToUYVYRow_LSX;
615
- }
616
- }
617
- #endif
618
- #if defined(HAS_I422TOUYVYROW_LASX)
619
- if (TestCpuFlag(kCpuHasLASX)) {
620
- I422ToUYVYRow = I422ToUYVYRow_Any_LASX;
621
- if (IS_ALIGNED(width, 32)) {
622
- I422ToUYVYRow = I422ToUYVYRow_LASX;
623
- }
624
- }
625
- #endif
626
-
627
- for (y = 0; y < height - 1; y += 2) {
628
- I422ToUYVYRow(src_y, src_u, src_v, dst_uyvy, width);
629
- I422ToUYVYRow(src_y + src_stride_y, src_u, src_v,
630
- dst_uyvy + dst_stride_uyvy, width);
631
- src_y += src_stride_y * 2;
632
- src_u += src_stride_u;
633
- src_v += src_stride_v;
634
- dst_uyvy += dst_stride_uyvy * 2;
635
- }
636
- if (height & 1) {
637
- I422ToUYVYRow(src_y, src_u, src_v, dst_uyvy, width);
638
- }
639
- return 0;
640
- }
641
-
642
- LIBYUV_API
643
- int I420ToNV12(const uint8_t* src_y,
644
- int src_stride_y,
645
- const uint8_t* src_u,
646
- int src_stride_u,
647
- const uint8_t* src_v,
648
- int src_stride_v,
649
- uint8_t* dst_y,
650
- int dst_stride_y,
651
- uint8_t* dst_uv,
652
- int dst_stride_uv,
653
- int width,
654
- int height) {
655
- int halfwidth = (width + 1) / 2;
656
- int halfheight = (height + 1) / 2;
657
- if ((!src_y && dst_y) || !src_u || !src_v || !dst_uv || width <= 0 ||
658
- height == 0) {
659
- return -1;
660
- }
661
- // Negative height means invert the image.
662
- if (height < 0) {
663
- height = -height;
664
- halfheight = (height + 1) >> 1;
665
- src_y = src_y + (height - 1) * src_stride_y;
666
- src_u = src_u + (halfheight - 1) * src_stride_u;
667
- src_v = src_v + (halfheight - 1) * src_stride_v;
668
- src_stride_y = -src_stride_y;
669
- src_stride_u = -src_stride_u;
670
- src_stride_v = -src_stride_v;
671
- }
672
- if (dst_y) {
673
- CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
674
- }
675
- MergeUVPlane(src_u, src_stride_u, src_v, src_stride_v, dst_uv, dst_stride_uv,
676
- halfwidth, halfheight);
677
- return 0;
678
- }
679
-
680
- LIBYUV_API
681
- int I420ToNV21(const uint8_t* src_y,
682
- int src_stride_y,
683
- const uint8_t* src_u,
684
- int src_stride_u,
685
- const uint8_t* src_v,
686
- int src_stride_v,
687
- uint8_t* dst_y,
688
- int dst_stride_y,
689
- uint8_t* dst_vu,
690
- int dst_stride_vu,
691
- int width,
692
- int height) {
693
- return I420ToNV12(src_y, src_stride_y, src_v, src_stride_v, src_u,
694
- src_stride_u, dst_y, dst_stride_y, dst_vu, dst_stride_vu,
695
- width, height);
696
- }
697
-
698
- // Convert I420 to specified format
699
- LIBYUV_API
700
- int ConvertFromI420(const uint8_t* y,
701
- int y_stride,
702
- const uint8_t* u,
703
- int u_stride,
704
- const uint8_t* v,
705
- int v_stride,
706
- uint8_t* dst_sample,
707
- int dst_sample_stride,
708
- int width,
709
- int height,
710
- uint32_t fourcc) {
711
- uint32_t format = CanonicalFourCC(fourcc);
712
- int r = 0;
713
- if (!y || !u || !v || !dst_sample || width <= 0 || height == 0) {
714
- return -1;
715
- }
716
- switch (format) {
717
- // Single plane formats
718
- case FOURCC_YUY2:
719
- r = I420ToYUY2(y, y_stride, u, u_stride, v, v_stride, dst_sample,
720
- dst_sample_stride ? dst_sample_stride : width * 2, width,
721
- height);
722
- break;
723
- case FOURCC_UYVY:
724
- r = I420ToUYVY(y, y_stride, u, u_stride, v, v_stride, dst_sample,
725
- dst_sample_stride ? dst_sample_stride : width * 2, width,
726
- height);
727
- break;
728
- case FOURCC_RGBP:
729
- r = I420ToRGB565(y, y_stride, u, u_stride, v, v_stride, dst_sample,
730
- dst_sample_stride ? dst_sample_stride : width * 2, width,
731
- height);
732
- break;
733
- case FOURCC_RGBO:
734
- r = I420ToARGB1555(y, y_stride, u, u_stride, v, v_stride, dst_sample,
735
- dst_sample_stride ? dst_sample_stride : width * 2,
736
- width, height);
737
- break;
738
- case FOURCC_R444:
739
- r = I420ToARGB4444(y, y_stride, u, u_stride, v, v_stride, dst_sample,
740
- dst_sample_stride ? dst_sample_stride : width * 2,
741
- width, height);
742
- break;
743
- case FOURCC_24BG:
744
- r = I420ToRGB24(y, y_stride, u, u_stride, v, v_stride, dst_sample,
745
- dst_sample_stride ? dst_sample_stride : width * 3, width,
746
- height);
747
- break;
748
- case FOURCC_RAW:
749
- r = I420ToRAW(y, y_stride, u, u_stride, v, v_stride, dst_sample,
750
- dst_sample_stride ? dst_sample_stride : width * 3, width,
751
- height);
752
- break;
753
- case FOURCC_ARGB:
754
- r = I420ToARGB(y, y_stride, u, u_stride, v, v_stride, dst_sample,
755
- dst_sample_stride ? dst_sample_stride : width * 4, width,
756
- height);
757
- break;
758
- case FOURCC_BGRA:
759
- r = I420ToBGRA(y, y_stride, u, u_stride, v, v_stride, dst_sample,
760
- dst_sample_stride ? dst_sample_stride : width * 4, width,
761
- height);
762
- break;
763
- case FOURCC_ABGR:
764
- r = I420ToABGR(y, y_stride, u, u_stride, v, v_stride, dst_sample,
765
- dst_sample_stride ? dst_sample_stride : width * 4, width,
766
- height);
767
- break;
768
- case FOURCC_RGBA:
769
- r = I420ToRGBA(y, y_stride, u, u_stride, v, v_stride, dst_sample,
770
- dst_sample_stride ? dst_sample_stride : width * 4, width,
771
- height);
772
- break;
773
- case FOURCC_AR30:
774
- r = I420ToAR30(y, y_stride, u, u_stride, v, v_stride, dst_sample,
775
- dst_sample_stride ? dst_sample_stride : width * 4, width,
776
- height);
777
- break;
778
- case FOURCC_I400:
779
- r = I400Copy(y, y_stride, dst_sample,
780
- dst_sample_stride ? dst_sample_stride : width, width,
781
- height);
782
- break;
783
- case FOURCC_NV12: {
784
- int dst_y_stride = dst_sample_stride ? dst_sample_stride : width;
785
- uint8_t* dst_uv = dst_sample + dst_y_stride * height;
786
- r = I420ToNV12(y, y_stride, u, u_stride, v, v_stride, dst_sample,
787
- dst_sample_stride ? dst_sample_stride : width, dst_uv,
788
- dst_sample_stride ? dst_sample_stride : width, width,
789
- height);
790
- break;
791
- }
792
- case FOURCC_NV21: {
793
- int dst_y_stride = dst_sample_stride ? dst_sample_stride : width;
794
- uint8_t* dst_vu = dst_sample + dst_y_stride * height;
795
- r = I420ToNV21(y, y_stride, u, u_stride, v, v_stride, dst_sample,
796
- dst_sample_stride ? dst_sample_stride : width, dst_vu,
797
- dst_sample_stride ? dst_sample_stride : width, width,
798
- height);
799
- break;
800
- }
801
- // Triplanar formats
802
- case FOURCC_I420:
803
- case FOURCC_YV12: {
804
- dst_sample_stride = dst_sample_stride ? dst_sample_stride : width;
805
- int halfstride = (dst_sample_stride + 1) / 2;
806
- int halfheight = (height + 1) / 2;
807
- uint8_t* dst_u;
808
- uint8_t* dst_v;
809
- if (format == FOURCC_YV12) {
810
- dst_v = dst_sample + dst_sample_stride * height;
811
- dst_u = dst_v + halfstride * halfheight;
812
- } else {
813
- dst_u = dst_sample + dst_sample_stride * height;
814
- dst_v = dst_u + halfstride * halfheight;
815
- }
816
- r = I420Copy(y, y_stride, u, u_stride, v, v_stride, dst_sample,
817
- dst_sample_stride, dst_u, halfstride, dst_v, halfstride,
818
- width, height);
819
- break;
820
- }
821
- case FOURCC_I422:
822
- case FOURCC_YV16: {
823
- dst_sample_stride = dst_sample_stride ? dst_sample_stride : width;
824
- int halfstride = (dst_sample_stride + 1) / 2;
825
- uint8_t* dst_u;
826
- uint8_t* dst_v;
827
- if (format == FOURCC_YV16) {
828
- dst_v = dst_sample + dst_sample_stride * height;
829
- dst_u = dst_v + halfstride * height;
830
- } else {
831
- dst_u = dst_sample + dst_sample_stride * height;
832
- dst_v = dst_u + halfstride * height;
833
- }
834
- r = I420ToI422(y, y_stride, u, u_stride, v, v_stride, dst_sample,
835
- dst_sample_stride, dst_u, halfstride, dst_v, halfstride,
836
- width, height);
837
- break;
838
- }
839
- case FOURCC_I444:
840
- case FOURCC_YV24: {
841
- dst_sample_stride = dst_sample_stride ? dst_sample_stride : width;
842
- uint8_t* dst_u;
843
- uint8_t* dst_v;
844
- if (format == FOURCC_YV24) {
845
- dst_v = dst_sample + dst_sample_stride * height;
846
- dst_u = dst_v + dst_sample_stride * height;
847
- } else {
848
- dst_u = dst_sample + dst_sample_stride * height;
849
- dst_v = dst_u + dst_sample_stride * height;
850
- }
851
- r = I420ToI444(y, y_stride, u, u_stride, v, v_stride, dst_sample,
852
- dst_sample_stride, dst_u, dst_sample_stride, dst_v,
853
- dst_sample_stride, width, height);
854
- break;
855
- }
856
- // Formats not supported - MJPG, biplanar, some rgb formats.
857
- default:
858
- return -1; // unknown fourcc - return failure code.
859
- }
860
- return r;
861
- }
862
-
863
- #ifdef __cplusplus
864
- } // extern "C"
865
- } // namespace libyuv
866
- #endif