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,391 +0,0 @@
1
- /*
2
- * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3
- *
4
- * Use of this source code is governed by a BSD-style license
5
- * that can be found in the LICENSE file in the root of the source
6
- * tree. An additional intellectual property rights grant can be found
7
- * in the file PATENTS. All contributing project authors may
8
- * be found in the AUTHORS file in the root of the source tree.
9
- */
10
-
11
- #include "libyuv/convert_argb.h"
12
-
13
- #include <limits.h>
14
- #include <stdint.h>
15
- #include <stdlib.h>
16
-
17
- #include "libyuv/cpu_id.h"
18
- #ifdef HAVE_JPEG
19
- #include "libyuv/mjpeg_decoder.h"
20
- #endif
21
- #include "libyuv/rotate_argb.h"
22
- #include "libyuv/row.h"
23
- #include "libyuv/video_common.h"
24
-
25
- #ifdef __cplusplus
26
- namespace libyuv {
27
- extern "C" {
28
- #endif
29
-
30
- // Convert camera sample to ARGB with cropping, rotation and vertical flip.
31
- // src_width is used for source stride computation
32
- // src_height is used to compute location of planes, and indicate inversion
33
- // sample_size is measured in bytes and is the size of the frame.
34
- // With MJPEG it is the compressed size of the frame.
35
-
36
- // TODO(fbarchard): Add the following:
37
- // H010ToARGB
38
- // I010ToARGB
39
-
40
- LIBYUV_API
41
- int ConvertToARGB(const uint8_t* sample,
42
- size_t sample_size,
43
- uint8_t* dst_argb,
44
- int dst_stride_argb,
45
- int crop_x,
46
- int crop_y,
47
- int src_width,
48
- int src_height,
49
- int crop_width,
50
- int crop_height,
51
- enum RotationMode rotation,
52
- uint32_t fourcc) {
53
- uint32_t format = CanonicalFourCC(fourcc);
54
- int aligned_src_width = (src_width + 1) & ~1;
55
- const uint8_t* src;
56
- const uint8_t* src_uv;
57
- int abs_src_height = (src_height < 0) ? -src_height : src_height;
58
- int inv_crop_height = (crop_height < 0) ? -crop_height : crop_height;
59
- int r = 0;
60
-
61
- // One pass rotation is available for some formats. For the rest, convert
62
- // to ARGB (with optional vertical flipping) into a temporary ARGB buffer,
63
- // and then rotate the ARGB to the final destination buffer.
64
- // For in-place conversion, if destination dst_argb is same as source sample,
65
- // also enable temporary buffer.
66
- LIBYUV_BOOL need_buf =
67
- (rotation && format != FOURCC_ARGB) || dst_argb == sample;
68
- uint8_t* dest_argb = dst_argb;
69
- int dest_dst_stride_argb = dst_stride_argb;
70
- uint8_t* rotate_buffer = NULL;
71
- int abs_crop_height = (crop_height < 0) ? -crop_height : crop_height;
72
-
73
- if (dst_argb == NULL || sample == NULL || src_width <= 0 ||
74
- src_width > INT_MAX / 4 || crop_width <= 0 || crop_width > INT_MAX / 4 ||
75
- src_height == 0 || crop_height == 0) {
76
- return -1;
77
- }
78
- if (src_height < 0) {
79
- inv_crop_height = -inv_crop_height;
80
- }
81
-
82
- if (need_buf) {
83
- const uint64_t rotate_buffer_size =
84
- (uint64_t)crop_width * 4 * abs_crop_height;
85
- if (rotate_buffer_size > SIZE_MAX) {
86
- return -1; // Invalid size.
87
- }
88
- rotate_buffer = (uint8_t*)malloc((size_t)rotate_buffer_size);
89
- if (!rotate_buffer) {
90
- return 1; // Out of memory runtime error.
91
- }
92
- dst_argb = rotate_buffer;
93
- dst_stride_argb = crop_width * 4;
94
- }
95
-
96
- switch (format) {
97
- // Single plane formats
98
- case FOURCC_YUY2:
99
- src = sample + (aligned_src_width * crop_y + crop_x) * 2;
100
- r = YUY2ToARGB(src, aligned_src_width * 2, dst_argb, dst_stride_argb,
101
- crop_width, inv_crop_height);
102
- break;
103
- case FOURCC_UYVY:
104
- src = sample + (aligned_src_width * crop_y + crop_x) * 2;
105
- r = UYVYToARGB(src, aligned_src_width * 2, dst_argb, dst_stride_argb,
106
- crop_width, inv_crop_height);
107
- break;
108
- case FOURCC_24BG:
109
- src = sample + (src_width * crop_y + crop_x) * 3;
110
- r = RGB24ToARGB(src, src_width * 3, dst_argb, dst_stride_argb, crop_width,
111
- inv_crop_height);
112
- break;
113
- case FOURCC_RAW:
114
- src = sample + (src_width * crop_y + crop_x) * 3;
115
- r = RAWToARGB(src, src_width * 3, dst_argb, dst_stride_argb, crop_width,
116
- inv_crop_height);
117
- break;
118
- case FOURCC_ARGB:
119
- if (!need_buf && !rotation) {
120
- src = sample + (src_width * crop_y + crop_x) * 4;
121
- r = ARGBToARGB(src, src_width * 4, dst_argb, dst_stride_argb,
122
- crop_width, inv_crop_height);
123
- }
124
- break;
125
- case FOURCC_BGRA:
126
- src = sample + (src_width * crop_y + crop_x) * 4;
127
- r = BGRAToARGB(src, src_width * 4, dst_argb, dst_stride_argb, crop_width,
128
- inv_crop_height);
129
- break;
130
- case FOURCC_ABGR:
131
- src = sample + (src_width * crop_y + crop_x) * 4;
132
- r = ABGRToARGB(src, src_width * 4, dst_argb, dst_stride_argb, crop_width,
133
- inv_crop_height);
134
- break;
135
- case FOURCC_RGBA:
136
- src = sample + (src_width * crop_y + crop_x) * 4;
137
- r = RGBAToARGB(src, src_width * 4, dst_argb, dst_stride_argb, crop_width,
138
- inv_crop_height);
139
- break;
140
- case FOURCC_AR30:
141
- src = sample + (src_width * crop_y + crop_x) * 4;
142
- r = AR30ToARGB(src, src_width * 4, dst_argb, dst_stride_argb, crop_width,
143
- inv_crop_height);
144
- break;
145
- case FOURCC_AB30:
146
- src = sample + (src_width * crop_y + crop_x) * 4;
147
- r = AB30ToARGB(src, src_width * 4, dst_argb, dst_stride_argb, crop_width,
148
- inv_crop_height);
149
- break;
150
- case FOURCC_RGBP:
151
- src = sample + (src_width * crop_y + crop_x) * 2;
152
- r = RGB565ToARGB(src, src_width * 2, dst_argb, dst_stride_argb,
153
- crop_width, inv_crop_height);
154
- break;
155
- case FOURCC_RGBO:
156
- src = sample + (src_width * crop_y + crop_x) * 2;
157
- r = ARGB1555ToARGB(src, src_width * 2, dst_argb, dst_stride_argb,
158
- crop_width, inv_crop_height);
159
- break;
160
- case FOURCC_R444:
161
- src = sample + (src_width * crop_y + crop_x) * 2;
162
- r = ARGB4444ToARGB(src, src_width * 2, dst_argb, dst_stride_argb,
163
- crop_width, inv_crop_height);
164
- break;
165
- case FOURCC_I400:
166
- src = sample + src_width * crop_y + crop_x;
167
- r = I400ToARGB(src, src_width, dst_argb, dst_stride_argb, crop_width,
168
- inv_crop_height);
169
- break;
170
- case FOURCC_J400:
171
- src = sample + src_width * crop_y + crop_x;
172
- r = J400ToARGB(src, src_width, dst_argb, dst_stride_argb, crop_width,
173
- inv_crop_height);
174
- break;
175
-
176
- // Biplanar formats
177
- case FOURCC_NV12:
178
- src = sample + (src_width * crop_y + crop_x);
179
- src_uv =
180
- sample + aligned_src_width * (abs_src_height + crop_y / 2) + crop_x;
181
- r = NV12ToARGB(src, src_width, src_uv, aligned_src_width, dst_argb,
182
- dst_stride_argb, crop_width, inv_crop_height);
183
- break;
184
- case FOURCC_NV21:
185
- src = sample + (src_width * crop_y + crop_x);
186
- src_uv =
187
- sample + aligned_src_width * (abs_src_height + crop_y / 2) + crop_x;
188
- // Call NV12 but with u and v parameters swapped.
189
- r = NV21ToARGB(src, src_width, src_uv, aligned_src_width, dst_argb,
190
- dst_stride_argb, crop_width, inv_crop_height);
191
- break;
192
- // Triplanar formats
193
- case FOURCC_I420:
194
- case FOURCC_YV12: {
195
- const uint8_t* src_y = sample + (src_width * crop_y + crop_x);
196
- const uint8_t* src_u;
197
- const uint8_t* src_v;
198
- int halfwidth = (src_width + 1) / 2;
199
- int halfheight = (abs_src_height + 1) / 2;
200
- if (format == FOURCC_YV12) {
201
- src_v = sample + src_width * abs_src_height +
202
- (halfwidth * crop_y + crop_x) / 2;
203
- src_u = sample + src_width * abs_src_height +
204
- halfwidth * (halfheight + crop_y / 2) + crop_x / 2;
205
- } else {
206
- src_u = sample + src_width * abs_src_height +
207
- (halfwidth * crop_y + crop_x) / 2;
208
- src_v = sample + src_width * abs_src_height +
209
- halfwidth * (halfheight + crop_y / 2) + crop_x / 2;
210
- }
211
- r = I420ToARGB(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
212
- dst_argb, dst_stride_argb, crop_width, inv_crop_height);
213
- break;
214
- }
215
-
216
- case FOURCC_J420: {
217
- int halfwidth = (src_width + 1) / 2;
218
- int halfheight = (abs_src_height + 1) / 2;
219
- const uint8_t* src_y = sample + (src_width * crop_y + crop_x);
220
- const uint8_t* src_u = sample + src_width * abs_src_height +
221
- (halfwidth * crop_y + crop_x) / 2;
222
- const uint8_t* src_v = sample + src_width * abs_src_height +
223
- halfwidth * (halfheight + crop_y / 2) + crop_x / 2;
224
- r = J420ToARGB(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
225
- dst_argb, dst_stride_argb, crop_width, inv_crop_height);
226
- break;
227
- }
228
-
229
- case FOURCC_H420: {
230
- int halfwidth = (src_width + 1) / 2;
231
- int halfheight = (abs_src_height + 1) / 2;
232
- const uint8_t* src_y = sample + (src_width * crop_y + crop_x);
233
- const uint8_t* src_u = sample + src_width * abs_src_height +
234
- (halfwidth * crop_y + crop_x) / 2;
235
- const uint8_t* src_v = sample + src_width * abs_src_height +
236
- halfwidth * (halfheight + crop_y / 2) + crop_x / 2;
237
- r = H420ToARGB(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
238
- dst_argb, dst_stride_argb, crop_width, inv_crop_height);
239
- break;
240
- }
241
-
242
- case FOURCC_U420: {
243
- int halfwidth = (src_width + 1) / 2;
244
- int halfheight = (abs_src_height + 1) / 2;
245
- const uint8_t* src_y = sample + (src_width * crop_y + crop_x);
246
- const uint8_t* src_u = sample + src_width * abs_src_height +
247
- (halfwidth * crop_y + crop_x) / 2;
248
- const uint8_t* src_v = sample + src_width * abs_src_height +
249
- halfwidth * (halfheight + crop_y / 2) + crop_x / 2;
250
- r = U420ToARGB(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
251
- dst_argb, dst_stride_argb, crop_width, inv_crop_height);
252
- break;
253
- }
254
-
255
- case FOURCC_I422:
256
- case FOURCC_YV16: {
257
- int halfwidth = (src_width + 1) / 2;
258
- const uint8_t* src_y = sample + src_width * crop_y + crop_x;
259
- const uint8_t* src_u;
260
- const uint8_t* src_v;
261
- if (format == FOURCC_YV16) {
262
- src_v = sample + src_width * abs_src_height + halfwidth * crop_y +
263
- crop_x / 2;
264
- src_u = sample + src_width * abs_src_height +
265
- halfwidth * (abs_src_height + crop_y) + crop_x / 2;
266
- } else {
267
- src_u = sample + src_width * abs_src_height + halfwidth * crop_y +
268
- crop_x / 2;
269
- src_v = sample + src_width * abs_src_height +
270
- halfwidth * (abs_src_height + crop_y) + crop_x / 2;
271
- }
272
- r = I422ToARGB(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
273
- dst_argb, dst_stride_argb, crop_width, inv_crop_height);
274
- break;
275
- }
276
-
277
- case FOURCC_J422: {
278
- int halfwidth = (src_width + 1) / 2;
279
- const uint8_t* src_y = sample + src_width * crop_y + crop_x;
280
- const uint8_t* src_u =
281
- sample + src_width * abs_src_height + halfwidth * crop_y + crop_x / 2;
282
- const uint8_t* src_v = sample + src_width * abs_src_height +
283
- halfwidth * (abs_src_height + crop_y) + crop_x / 2;
284
- r = J422ToARGB(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
285
- dst_argb, dst_stride_argb, crop_width, inv_crop_height);
286
- break;
287
- }
288
-
289
- case FOURCC_H422: {
290
- int halfwidth = (src_width + 1) / 2;
291
- const uint8_t* src_y = sample + src_width * crop_y + crop_x;
292
- const uint8_t* src_u =
293
- sample + src_width * abs_src_height + halfwidth * crop_y + crop_x / 2;
294
- const uint8_t* src_v = sample + src_width * abs_src_height +
295
- halfwidth * (abs_src_height + crop_y) + crop_x / 2;
296
- r = H422ToARGB(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
297
- dst_argb, dst_stride_argb, crop_width, inv_crop_height);
298
- break;
299
- }
300
-
301
- case FOURCC_U422: {
302
- int halfwidth = (src_width + 1) / 2;
303
- const uint8_t* src_y = sample + src_width * crop_y + crop_x;
304
- const uint8_t* src_u =
305
- sample + src_width * abs_src_height + halfwidth * crop_y + crop_x / 2;
306
- const uint8_t* src_v = sample + src_width * abs_src_height +
307
- halfwidth * (abs_src_height + crop_y) + crop_x / 2;
308
- r = H422ToARGB(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
309
- dst_argb, dst_stride_argb, crop_width, inv_crop_height);
310
- break;
311
- }
312
-
313
- case FOURCC_I444:
314
- case FOURCC_YV24: {
315
- const uint8_t* src_y = sample + src_width * crop_y + crop_x;
316
- const uint8_t* src_u;
317
- const uint8_t* src_v;
318
- if (format == FOURCC_YV24) {
319
- src_v = sample + src_width * (abs_src_height + crop_y) + crop_x;
320
- src_u = sample + src_width * (abs_src_height * 2 + crop_y) + crop_x;
321
- } else {
322
- src_u = sample + src_width * (abs_src_height + crop_y) + crop_x;
323
- src_v = sample + src_width * (abs_src_height * 2 + crop_y) + crop_x;
324
- }
325
- r = I444ToARGB(src_y, src_width, src_u, src_width, src_v, src_width,
326
- dst_argb, dst_stride_argb, crop_width, inv_crop_height);
327
- break;
328
- }
329
-
330
- case FOURCC_J444: {
331
- const uint8_t* src_y = sample + src_width * crop_y + crop_x;
332
- const uint8_t* src_u;
333
- const uint8_t* src_v;
334
- src_u = sample + src_width * (abs_src_height + crop_y) + crop_x;
335
- src_v = sample + src_width * (abs_src_height * 2 + crop_y) + crop_x;
336
- r = J444ToARGB(src_y, src_width, src_u, src_width, src_v, src_width,
337
- dst_argb, dst_stride_argb, crop_width, inv_crop_height);
338
- break;
339
- }
340
-
341
- case FOURCC_H444: {
342
- const uint8_t* src_y = sample + src_width * crop_y + crop_x;
343
- const uint8_t* src_u;
344
- const uint8_t* src_v;
345
- src_u = sample + src_width * (abs_src_height + crop_y) + crop_x;
346
- src_v = sample + src_width * (abs_src_height * 2 + crop_y) + crop_x;
347
- r = H444ToARGB(src_y, src_width, src_u, src_width, src_v, src_width,
348
- dst_argb, dst_stride_argb, crop_width, inv_crop_height);
349
- break;
350
- }
351
-
352
- case FOURCC_U444: {
353
- const uint8_t* src_y = sample + src_width * crop_y + crop_x;
354
- const uint8_t* src_u;
355
- const uint8_t* src_v;
356
- src_u = sample + src_width * (abs_src_height + crop_y) + crop_x;
357
- src_v = sample + src_width * (abs_src_height * 2 + crop_y) + crop_x;
358
- r = U444ToARGB(src_y, src_width, src_u, src_width, src_v, src_width,
359
- dst_argb, dst_stride_argb, crop_width, inv_crop_height);
360
- break;
361
- }
362
-
363
- #ifdef HAVE_JPEG
364
- case FOURCC_MJPG:
365
- r = MJPGToARGB(sample, sample_size, dst_argb, dst_stride_argb, src_width,
366
- abs_src_height, crop_width, inv_crop_height);
367
- break;
368
- #endif
369
- default:
370
- r = -1; // unknown fourcc - return failure code.
371
- }
372
-
373
- if (need_buf) {
374
- if (!r) {
375
- r = ARGBRotate(dst_argb, dst_stride_argb, dest_argb, dest_dst_stride_argb,
376
- crop_width, abs_crop_height, rotation);
377
- }
378
- free(rotate_buffer);
379
- } else if (rotation) {
380
- src = sample + (src_width * crop_y + crop_x) * 4;
381
- r = ARGBRotate(src, src_width * 4, dst_argb, dst_stride_argb, crop_width,
382
- inv_crop_height, rotation);
383
- }
384
-
385
- return r;
386
- }
387
-
388
- #ifdef __cplusplus
389
- } // extern "C"
390
- } // namespace libyuv
391
- #endif
@@ -1,288 +0,0 @@
1
- /*
2
- * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3
- *
4
- * Use of this source code is governed by a BSD-style license
5
- * that can be found in the LICENSE file in the root of the source
6
- * tree. An additional intellectual property rights grant can be found
7
- * in the file PATENTS. All contributing project authors may
8
- * be found in the AUTHORS file in the root of the source tree.
9
- */
10
-
11
- #include "libyuv/convert.h"
12
-
13
- #include <limits.h>
14
- #include <stddef.h>
15
- #include <stdint.h>
16
- #include <stdlib.h>
17
-
18
- #include "libyuv/video_common.h"
19
-
20
- #ifdef __cplusplus
21
- namespace libyuv {
22
- extern "C" {
23
- #endif
24
-
25
- // Convert camera sample to I420 with cropping, rotation and vertical flip.
26
- // src_width is used for source stride computation
27
- // src_height is used to compute location of planes, and indicate inversion
28
- // sample_size is measured in bytes and is the size of the frame.
29
- // With MJPEG it is the compressed size of the frame.
30
- LIBYUV_API
31
- int ConvertToI420(const uint8_t* sample,
32
- size_t sample_size,
33
- uint8_t* dst_y,
34
- int dst_stride_y,
35
- uint8_t* dst_u,
36
- int dst_stride_u,
37
- uint8_t* dst_v,
38
- int dst_stride_v,
39
- int crop_x,
40
- int crop_y,
41
- int src_width,
42
- int src_height,
43
- int crop_width,
44
- int crop_height,
45
- enum RotationMode rotation,
46
- uint32_t fourcc) {
47
- uint32_t format = CanonicalFourCC(fourcc);
48
- int aligned_src_width = (src_width + 1) & ~1;
49
- const uint8_t* src;
50
- const uint8_t* src_uv;
51
- const int abs_src_height = (src_height < 0) ? -src_height : src_height;
52
- const int abs_crop_height = (crop_height < 0) ? -crop_height : crop_height;
53
- int r = 0;
54
- LIBYUV_BOOL need_buf =
55
- (rotation && format != FOURCC_I420 && format != FOURCC_NV12 &&
56
- format != FOURCC_NV21 && format != FOURCC_YV12) ||
57
- dst_y == sample;
58
- uint8_t* tmp_y = dst_y;
59
- uint8_t* tmp_u = dst_u;
60
- uint8_t* tmp_v = dst_v;
61
- int tmp_y_stride = dst_stride_y;
62
- int tmp_u_stride = dst_stride_u;
63
- int tmp_v_stride = dst_stride_v;
64
- uint8_t* rotate_buffer = NULL;
65
- const int inv_crop_height =
66
- (src_height < 0) ? -abs_crop_height : abs_crop_height;
67
-
68
- if (!dst_y || !dst_u || !dst_v || !sample || src_width <= 0 ||
69
- src_width > INT_MAX / 4 || crop_width <= 0 || src_height == 0 ||
70
- crop_height == 0) {
71
- return -1;
72
- }
73
-
74
- // One pass rotation is available for some formats. For the rest, convert
75
- // to I420 (with optional vertical flipping) into a temporary I420 buffer,
76
- // and then rotate the I420 to the final destination buffer.
77
- // For in-place conversion, if destination dst_y is same as source sample,
78
- // also enable temporary buffer.
79
- if (need_buf) {
80
- int y_size = crop_width * abs_crop_height;
81
- int uv_size = ((crop_width + 1) / 2) * ((abs_crop_height + 1) / 2);
82
- const uint64_t rotate_buffer_size =
83
- (uint64_t)y_size + (uint64_t)uv_size * 2;
84
- if (rotate_buffer_size > SIZE_MAX) {
85
- return -1; // Invalid size.
86
- }
87
- rotate_buffer = (uint8_t*)malloc((size_t)rotate_buffer_size);
88
- if (!rotate_buffer) {
89
- return 1; // Out of memory runtime error.
90
- }
91
- dst_y = rotate_buffer;
92
- dst_u = dst_y + y_size;
93
- dst_v = dst_u + uv_size;
94
- dst_stride_y = crop_width;
95
- dst_stride_u = dst_stride_v = ((crop_width + 1) / 2);
96
- }
97
-
98
- switch (format) {
99
- // Single plane formats
100
- case FOURCC_YUY2: { // TODO(fbarchard): Find better odd crop fix.
101
- uint8_t* u = (crop_x & 1) ? dst_v : dst_u;
102
- uint8_t* v = (crop_x & 1) ? dst_u : dst_v;
103
- int stride_u = (crop_x & 1) ? dst_stride_v : dst_stride_u;
104
- int stride_v = (crop_x & 1) ? dst_stride_u : dst_stride_v;
105
- src = sample + (aligned_src_width * crop_y + crop_x) * 2;
106
- r = YUY2ToI420(src, aligned_src_width * 2, dst_y, dst_stride_y, u,
107
- stride_u, v, stride_v, crop_width, inv_crop_height);
108
- break;
109
- }
110
- case FOURCC_UYVY: {
111
- uint8_t* u = (crop_x & 1) ? dst_v : dst_u;
112
- uint8_t* v = (crop_x & 1) ? dst_u : dst_v;
113
- int stride_u = (crop_x & 1) ? dst_stride_v : dst_stride_u;
114
- int stride_v = (crop_x & 1) ? dst_stride_u : dst_stride_v;
115
- src = sample + (aligned_src_width * crop_y + crop_x) * 2;
116
- r = UYVYToI420(src, aligned_src_width * 2, dst_y, dst_stride_y, u,
117
- stride_u, v, stride_v, crop_width, inv_crop_height);
118
- break;
119
- }
120
- case FOURCC_RGBP:
121
- src = sample + (src_width * crop_y + crop_x) * 2;
122
- r = RGB565ToI420(src, src_width * 2, dst_y, dst_stride_y, dst_u,
123
- dst_stride_u, dst_v, dst_stride_v, crop_width,
124
- inv_crop_height);
125
- break;
126
- case FOURCC_RGBO:
127
- src = sample + (src_width * crop_y + crop_x) * 2;
128
- r = ARGB1555ToI420(src, src_width * 2, dst_y, dst_stride_y, dst_u,
129
- dst_stride_u, dst_v, dst_stride_v, crop_width,
130
- inv_crop_height);
131
- break;
132
- case FOURCC_R444:
133
- src = sample + (src_width * crop_y + crop_x) * 2;
134
- r = ARGB4444ToI420(src, src_width * 2, dst_y, dst_stride_y, dst_u,
135
- dst_stride_u, dst_v, dst_stride_v, crop_width,
136
- inv_crop_height);
137
- break;
138
- case FOURCC_24BG:
139
- src = sample + (src_width * crop_y + crop_x) * 3;
140
- r = RGB24ToI420(src, src_width * 3, dst_y, dst_stride_y, dst_u,
141
- dst_stride_u, dst_v, dst_stride_v, crop_width,
142
- inv_crop_height);
143
- break;
144
- case FOURCC_RAW:
145
- src = sample + (src_width * crop_y + crop_x) * 3;
146
- r = RAWToI420(src, src_width * 3, dst_y, dst_stride_y, dst_u,
147
- dst_stride_u, dst_v, dst_stride_v, crop_width,
148
- inv_crop_height);
149
- break;
150
- case FOURCC_ARGB:
151
- src = sample + (src_width * crop_y + crop_x) * 4;
152
- r = ARGBToI420(src, src_width * 4, dst_y, dst_stride_y, dst_u,
153
- dst_stride_u, dst_v, dst_stride_v, crop_width,
154
- inv_crop_height);
155
- break;
156
- case FOURCC_BGRA:
157
- src = sample + (src_width * crop_y + crop_x) * 4;
158
- r = BGRAToI420(src, src_width * 4, dst_y, dst_stride_y, dst_u,
159
- dst_stride_u, dst_v, dst_stride_v, crop_width,
160
- inv_crop_height);
161
- break;
162
- case FOURCC_ABGR:
163
- src = sample + (src_width * crop_y + crop_x) * 4;
164
- r = ABGRToI420(src, src_width * 4, dst_y, dst_stride_y, dst_u,
165
- dst_stride_u, dst_v, dst_stride_v, crop_width,
166
- inv_crop_height);
167
- break;
168
- case FOURCC_RGBA:
169
- src = sample + (src_width * crop_y + crop_x) * 4;
170
- r = RGBAToI420(src, src_width * 4, dst_y, dst_stride_y, dst_u,
171
- dst_stride_u, dst_v, dst_stride_v, crop_width,
172
- inv_crop_height);
173
- break;
174
- // TODO(fbarchard): Add AR30 and AB30
175
- case FOURCC_I400:
176
- src = sample + src_width * crop_y + crop_x;
177
- r = I400ToI420(src, src_width, dst_y, dst_stride_y, dst_u, dst_stride_u,
178
- dst_v, dst_stride_v, crop_width, inv_crop_height);
179
- break;
180
- // Biplanar formats
181
- case FOURCC_NV12:
182
- src = sample + (src_width * crop_y + crop_x);
183
- src_uv = sample + (src_width * abs_src_height) +
184
- ((crop_y / 2) * aligned_src_width) + ((crop_x / 2) * 2);
185
- r = NV12ToI420Rotate(src, src_width, src_uv, aligned_src_width, dst_y,
186
- dst_stride_y, dst_u, dst_stride_u, dst_v,
187
- dst_stride_v, crop_width, inv_crop_height, rotation);
188
- break;
189
- case FOURCC_NV21:
190
- src = sample + (src_width * crop_y + crop_x);
191
- src_uv = sample + (src_width * abs_src_height) +
192
- ((crop_y / 2) * aligned_src_width) + ((crop_x / 2) * 2);
193
- // Call NV12 but with dst_u and dst_v parameters swapped.
194
- r = NV12ToI420Rotate(src, src_width, src_uv, aligned_src_width, dst_y,
195
- dst_stride_y, dst_v, dst_stride_v, dst_u,
196
- dst_stride_u, crop_width, inv_crop_height, rotation);
197
- break;
198
- // Triplanar formats
199
- case FOURCC_I420:
200
- case FOURCC_YV12: {
201
- const uint8_t* src_y = sample + (src_width * crop_y + crop_x);
202
- const uint8_t* src_u;
203
- const uint8_t* src_v;
204
- int halfwidth = (src_width + 1) / 2;
205
- int halfheight = (abs_src_height + 1) / 2;
206
- if (format == FOURCC_YV12) {
207
- src_v = sample + src_width * abs_src_height + halfwidth * (crop_y / 2) +
208
- (crop_x / 2);
209
- src_u = sample + src_width * abs_src_height +
210
- halfwidth * (halfheight + (crop_y / 2)) + (crop_x / 2);
211
- } else {
212
- src_u = sample + src_width * abs_src_height + halfwidth * (crop_y / 2) +
213
- (crop_x / 2);
214
- src_v = sample + src_width * abs_src_height +
215
- halfwidth * (halfheight + (crop_y / 2)) + (crop_x / 2);
216
- }
217
- r = I420Rotate(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
218
- dst_y, dst_stride_y, dst_u, dst_stride_u, dst_v,
219
- dst_stride_v, crop_width, inv_crop_height, rotation);
220
- break;
221
- }
222
- case FOURCC_I422:
223
- case FOURCC_YV16: {
224
- const uint8_t* src_y = sample + src_width * crop_y + crop_x;
225
- const uint8_t* src_u;
226
- const uint8_t* src_v;
227
- int halfwidth = (src_width + 1) / 2;
228
- if (format == FOURCC_YV16) {
229
- src_v = sample + src_width * abs_src_height + halfwidth * crop_y +
230
- (crop_x / 2);
231
- src_u = sample + src_width * abs_src_height +
232
- halfwidth * (abs_src_height + crop_y) + (crop_x / 2);
233
- } else {
234
- src_u = sample + src_width * abs_src_height + halfwidth * crop_y +
235
- (crop_x / 2);
236
- src_v = sample + src_width * abs_src_height +
237
- halfwidth * (abs_src_height + crop_y) + (crop_x / 2);
238
- }
239
- r = I422ToI420(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
240
- dst_y, dst_stride_y, dst_u, dst_stride_u, dst_v,
241
- dst_stride_v, crop_width, inv_crop_height);
242
- break;
243
- }
244
- case FOURCC_I444:
245
- case FOURCC_YV24: {
246
- const uint8_t* src_y = sample + src_width * crop_y + crop_x;
247
- const uint8_t* src_u;
248
- const uint8_t* src_v;
249
- if (format == FOURCC_YV24) {
250
- src_v = sample + src_width * (abs_src_height + crop_y) + crop_x;
251
- src_u = sample + src_width * (abs_src_height * 2 + crop_y) + crop_x;
252
- } else {
253
- src_u = sample + src_width * (abs_src_height + crop_y) + crop_x;
254
- src_v = sample + src_width * (abs_src_height * 2 + crop_y) + crop_x;
255
- }
256
- r = I444ToI420(src_y, src_width, src_u, src_width, src_v, src_width,
257
- dst_y, dst_stride_y, dst_u, dst_stride_u, dst_v,
258
- dst_stride_v, crop_width, inv_crop_height);
259
- break;
260
- }
261
- #ifdef HAVE_JPEG
262
- case FOURCC_MJPG:
263
- r = MJPGToI420(sample, sample_size, dst_y, dst_stride_y, dst_u,
264
- dst_stride_u, dst_v, dst_stride_v, src_width,
265
- abs_src_height, crop_width, inv_crop_height);
266
- break;
267
- #endif
268
- default:
269
- r = -1; // unknown fourcc - return failure code.
270
- }
271
-
272
- if (need_buf) {
273
- if (!r) {
274
- r = I420Rotate(dst_y, dst_stride_y, dst_u, dst_stride_u, dst_v,
275
- dst_stride_v, tmp_y, tmp_y_stride, tmp_u, tmp_u_stride,
276
- tmp_v, tmp_v_stride, crop_width, abs_crop_height,
277
- rotation);
278
- }
279
- free(rotate_buffer);
280
- }
281
-
282
- return r;
283
- }
284
-
285
- #ifdef __cplusplus
286
- } // extern "C"
287
- } // namespace libyuv
288
- #endif