react-native-vision-camera-spoof-detector 1.0.21 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/.gitattributes +2 -0
  2. package/.gitignore +27 -0
  3. package/CHANGELOG.md +2 -2
  4. package/CONTRIBUTING.md +2 -2
  5. package/README.md +442 -443
  6. package/android/build.gradle +12 -4
  7. package/android/src/main/cpp/CMakeLists.txt +101 -94
  8. package/android/src/main/cpp/libyuv/.clang-format +6 -6
  9. package/android/src/main/cpp/libyuv/.gn +40 -40
  10. package/android/src/main/cpp/libyuv/.vpython3 +410 -410
  11. package/android/src/main/cpp/libyuv/AUTHORS +7 -7
  12. package/android/src/main/cpp/libyuv/Android.bp +202 -202
  13. package/android/src/main/cpp/libyuv/Android.mk +106 -106
  14. package/android/src/main/cpp/libyuv/BUILD.gn +490 -490
  15. package/android/src/main/cpp/libyuv/CM_linux_packages.cmake +70 -70
  16. package/android/src/main/cpp/libyuv/CMakeLists.txt +259 -252
  17. package/android/src/main/cpp/libyuv/DEPS +935 -935
  18. package/android/src/main/cpp/libyuv/DIR_METADATA +3 -3
  19. package/android/src/main/cpp/libyuv/LICENSE +29 -29
  20. package/android/src/main/cpp/libyuv/OWNERS +11 -11
  21. package/android/src/main/cpp/libyuv/PATENTS +23 -23
  22. package/android/src/main/cpp/libyuv/PRESUBMIT.py +65 -65
  23. package/android/src/main/cpp/libyuv/README.chromium +11 -11
  24. package/android/src/main/cpp/libyuv/README.md +19 -19
  25. package/android/src/main/cpp/libyuv/build_overrides/build.gni +60 -60
  26. package/android/src/main/cpp/libyuv/build_overrides/gtest.gni +19 -19
  27. package/android/src/main/cpp/libyuv/build_overrides/partition_alloc.gni +17 -17
  28. package/android/src/main/cpp/libyuv/codereview.settings +5 -5
  29. package/android/src/main/cpp/libyuv/docs/deprecated_builds.md +409 -409
  30. package/android/src/main/cpp/libyuv/docs/environment_variables.md +64 -64
  31. package/android/src/main/cpp/libyuv/docs/feature_detection.md +108 -108
  32. package/android/src/main/cpp/libyuv/docs/filtering.md +196 -196
  33. package/android/src/main/cpp/libyuv/docs/formats.md +208 -208
  34. package/android/src/main/cpp/libyuv/docs/getting_started.md +296 -296
  35. package/android/src/main/cpp/libyuv/docs/rotation.md +107 -107
  36. package/android/src/main/cpp/libyuv/download_vs_toolchain.py +29 -29
  37. package/android/src/main/cpp/libyuv/include/libyuv/basic_types.h +68 -68
  38. package/android/src/main/cpp/libyuv/include/libyuv/compare.h +111 -111
  39. package/android/src/main/cpp/libyuv/include/libyuv/compare_row.h +112 -112
  40. package/android/src/main/cpp/libyuv/include/libyuv/convert.h +1117 -1117
  41. package/android/src/main/cpp/libyuv/include/libyuv/convert_argb.h +2335 -2335
  42. package/android/src/main/cpp/libyuv/include/libyuv/convert_from.h +203 -203
  43. package/android/src/main/cpp/libyuv/include/libyuv/convert_from_argb.h +394 -394
  44. package/android/src/main/cpp/libyuv/include/libyuv/cpu_id.h +147 -147
  45. package/android/src/main/cpp/libyuv/include/libyuv/cpu_support.h +99 -99
  46. package/android/src/main/cpp/libyuv/include/libyuv/loongson_intrinsics.h +1949 -1949
  47. package/android/src/main/cpp/libyuv/include/libyuv/mjpeg_decoder.h +195 -195
  48. package/android/src/main/cpp/libyuv/include/libyuv/planar_functions.h +1131 -1131
  49. package/android/src/main/cpp/libyuv/include/libyuv/rotate.h +296 -296
  50. package/android/src/main/cpp/libyuv/include/libyuv/rotate_argb.h +37 -37
  51. package/android/src/main/cpp/libyuv/include/libyuv/rotate_row.h +265 -265
  52. package/android/src/main/cpp/libyuv/include/libyuv/row.h +6738 -6738
  53. package/android/src/main/cpp/libyuv/include/libyuv/row_sve.h +2154 -2154
  54. package/android/src/main/cpp/libyuv/include/libyuv/scale.h +336 -336
  55. package/android/src/main/cpp/libyuv/include/libyuv/scale_argb.h +76 -76
  56. package/android/src/main/cpp/libyuv/include/libyuv/scale_rgb.h +42 -42
  57. package/android/src/main/cpp/libyuv/include/libyuv/scale_row.h +1726 -1726
  58. package/android/src/main/cpp/libyuv/include/libyuv/scale_uv.h +51 -51
  59. package/android/src/main/cpp/libyuv/include/libyuv/version.h +16 -16
  60. package/android/src/main/cpp/libyuv/include/libyuv/video_common.h +222 -222
  61. package/android/src/main/cpp/libyuv/include/libyuv.h +33 -33
  62. package/android/src/main/cpp/libyuv/infra/config/OWNERS +3 -3
  63. package/android/src/main/cpp/libyuv/infra/config/PRESUBMIT.py +17 -17
  64. package/android/src/main/cpp/libyuv/infra/config/README.md +2 -2
  65. package/android/src/main/cpp/libyuv/infra/config/codereview.settings +6 -6
  66. package/android/src/main/cpp/libyuv/infra/config/commit-queue.cfg +144 -144
  67. package/android/src/main/cpp/libyuv/infra/config/cr-buildbucket.cfg +1185 -1185
  68. package/android/src/main/cpp/libyuv/infra/config/luci-logdog.cfg +9 -9
  69. package/android/src/main/cpp/libyuv/infra/config/luci-milo.cfg +246 -246
  70. package/android/src/main/cpp/libyuv/infra/config/luci-scheduler.cfg +385 -385
  71. package/android/src/main/cpp/libyuv/infra/config/main.star +402 -402
  72. package/android/src/main/cpp/libyuv/infra/config/project.cfg +16 -16
  73. package/android/src/main/cpp/libyuv/infra/config/realms.cfg +111 -111
  74. package/android/src/main/cpp/libyuv/libyuv.gni +34 -34
  75. package/android/src/main/cpp/libyuv/libyuv.gyp +149 -149
  76. package/android/src/main/cpp/libyuv/libyuv.gypi +87 -87
  77. package/android/src/main/cpp/libyuv/linux.mk +96 -96
  78. package/android/src/main/cpp/libyuv/public.mk +13 -13
  79. package/android/src/main/cpp/libyuv/pylintrc +49 -49
  80. package/android/src/main/cpp/libyuv/riscv_script/prepare_toolchain_qemu.sh +74 -74
  81. package/android/src/main/cpp/libyuv/riscv_script/riscv-clang.cmake +56 -56
  82. package/android/src/main/cpp/libyuv/riscv_script/run_qemu.sh +15 -15
  83. package/android/src/main/cpp/libyuv/source/compare.cc +435 -435
  84. package/android/src/main/cpp/libyuv/source/compare_common.cc +74 -74
  85. package/android/src/main/cpp/libyuv/source/compare_gcc.cc +362 -362
  86. package/android/src/main/cpp/libyuv/source/compare_neon.cc +96 -96
  87. package/android/src/main/cpp/libyuv/source/compare_neon64.cc +223 -223
  88. package/android/src/main/cpp/libyuv/source/compare_win.cc +241 -241
  89. package/android/src/main/cpp/libyuv/source/convert.cc +4746 -4746
  90. package/android/src/main/cpp/libyuv/source/convert_argb.cc +9179 -9179
  91. package/android/src/main/cpp/libyuv/source/convert_from.cc +866 -866
  92. package/android/src/main/cpp/libyuv/source/convert_from_argb.cc +3671 -3671
  93. package/android/src/main/cpp/libyuv/source/convert_jpeg.cc +602 -602
  94. package/android/src/main/cpp/libyuv/source/convert_to_argb.cc +391 -391
  95. package/android/src/main/cpp/libyuv/source/convert_to_i420.cc +288 -288
  96. package/android/src/main/cpp/libyuv/source/cpu_id.cc +496 -496
  97. package/android/src/main/cpp/libyuv/source/mjpeg_decoder.cc +580 -580
  98. package/android/src/main/cpp/libyuv/source/mjpeg_validate.cc +71 -71
  99. package/android/src/main/cpp/libyuv/source/planar_functions.cc +5663 -5663
  100. package/android/src/main/cpp/libyuv/source/rotate.cc +1241 -1241
  101. package/android/src/main/cpp/libyuv/source/rotate_any.cc +76 -76
  102. package/android/src/main/cpp/libyuv/source/rotate_argb.cc +259 -259
  103. package/android/src/main/cpp/libyuv/source/rotate_common.cc +208 -208
  104. package/android/src/main/cpp/libyuv/source/rotate_gcc.cc +505 -505
  105. package/android/src/main/cpp/libyuv/source/rotate_lsx.cc +233 -233
  106. package/android/src/main/cpp/libyuv/source/rotate_neon.cc +219 -219
  107. package/android/src/main/cpp/libyuv/source/rotate_neon64.cc +273 -273
  108. package/android/src/main/cpp/libyuv/source/rotate_sme.cc +174 -174
  109. package/android/src/main/cpp/libyuv/source/rotate_win.cc +253 -253
  110. package/android/src/main/cpp/libyuv/source/row_any.cc +2519 -2519
  111. package/android/src/main/cpp/libyuv/source/row_common.cc +4461 -4461
  112. package/android/src/main/cpp/libyuv/source/row_gcc.cc +9570 -9570
  113. package/android/src/main/cpp/libyuv/source/row_lasx.cc +2343 -2343
  114. package/android/src/main/cpp/libyuv/source/row_lsx.cc +3030 -3030
  115. package/android/src/main/cpp/libyuv/source/row_neon.cc +4026 -4026
  116. package/android/src/main/cpp/libyuv/source/row_neon64.cc +5617 -5617
  117. package/android/src/main/cpp/libyuv/source/row_rvv.cc +2599 -2599
  118. package/android/src/main/cpp/libyuv/source/row_sme.cc +1183 -1183
  119. package/android/src/main/cpp/libyuv/source/row_sve.cc +1088 -1088
  120. package/android/src/main/cpp/libyuv/source/row_win.cc +6453 -6453
  121. package/android/src/main/cpp/libyuv/source/scale.cc +2710 -2710
  122. package/android/src/main/cpp/libyuv/source/scale_any.cc +991 -991
  123. package/android/src/main/cpp/libyuv/source/scale_argb.cc +1158 -1158
  124. package/android/src/main/cpp/libyuv/source/scale_common.cc +1977 -1977
  125. package/android/src/main/cpp/libyuv/source/scale_gcc.cc +2947 -2947
  126. package/android/src/main/cpp/libyuv/source/scale_lsx.cc +739 -739
  127. package/android/src/main/cpp/libyuv/source/scale_neon.cc +1449 -1449
  128. package/android/src/main/cpp/libyuv/source/scale_neon64.cc +1552 -1552
  129. package/android/src/main/cpp/libyuv/source/scale_rgb.cc +82 -82
  130. package/android/src/main/cpp/libyuv/source/scale_rvv.cc +1971 -1971
  131. package/android/src/main/cpp/libyuv/source/scale_sme.cc +555 -555
  132. package/android/src/main/cpp/libyuv/source/scale_uv.cc +1159 -1159
  133. package/android/src/main/cpp/libyuv/source/scale_win.cc +1392 -1392
  134. package/android/src/main/cpp/libyuv/source/test.sh +35 -35
  135. package/android/src/main/cpp/libyuv/source/video_common.cc +62 -62
  136. package/android/src/main/cpp/libyuv/tools_libyuv/OWNERS +4 -4
  137. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/roll_deps.py +931 -931
  138. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/roll_deps_test.py +164 -164
  139. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS +21 -21
  140. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.new +13 -13
  141. package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.old +13 -13
  142. package/android/src/main/cpp/libyuv/tools_libyuv/get_landmines.py +38 -38
  143. package/android/src/main/cpp/libyuv/tools_libyuv/msan/OWNERS +3 -3
  144. package/android/src/main/cpp/libyuv/tools_libyuv/msan/blacklist.txt +9 -9
  145. package/android/src/main/cpp/libyuv/tools_libyuv/ubsan/OWNERS +3 -3
  146. package/android/src/main/cpp/libyuv/tools_libyuv/ubsan/blacklist.txt +15 -15
  147. package/android/src/main/cpp/libyuv/tools_libyuv/ubsan/vptr_blacklist.txt +25 -25
  148. package/android/src/main/cpp/libyuv/unit_test/basictypes_test.cc +43 -43
  149. package/android/src/main/cpp/libyuv/unit_test/color_test.cc +848 -848
  150. package/android/src/main/cpp/libyuv/unit_test/compare_test.cc +739 -739
  151. package/android/src/main/cpp/libyuv/unit_test/convert_argb_test.cc +2867 -2867
  152. package/android/src/main/cpp/libyuv/unit_test/convert_test.cc +2133 -2133
  153. package/android/src/main/cpp/libyuv/unit_test/cpu_test.cc +427 -427
  154. package/android/src/main/cpp/libyuv/unit_test/cpu_thread_test.cc +63 -63
  155. package/android/src/main/cpp/libyuv/unit_test/math_test.cc +160 -160
  156. package/android/src/main/cpp/libyuv/unit_test/planar_test.cc +4731 -4731
  157. package/android/src/main/cpp/libyuv/unit_test/rotate_argb_test.cc +334 -334
  158. package/android/src/main/cpp/libyuv/unit_test/rotate_test.cc +962 -962
  159. package/android/src/main/cpp/libyuv/unit_test/scale_argb_test.cc +590 -590
  160. package/android/src/main/cpp/libyuv/unit_test/scale_plane_test.cc +465 -465
  161. package/android/src/main/cpp/libyuv/unit_test/scale_rgb_test.cc +280 -280
  162. package/android/src/main/cpp/libyuv/unit_test/scale_test.cc +1135 -1135
  163. package/android/src/main/cpp/libyuv/unit_test/scale_uv_test.cc +249 -249
  164. package/android/src/main/cpp/libyuv/unit_test/testdata/arm_v7.txt +12 -12
  165. package/android/src/main/cpp/libyuv/unit_test/testdata/mips.txt +7 -7
  166. package/android/src/main/cpp/libyuv/unit_test/testdata/mips_loongson2k.txt +5 -5
  167. package/android/src/main/cpp/libyuv/unit_test/testdata/mips_loongson3.txt +10 -10
  168. package/android/src/main/cpp/libyuv/unit_test/testdata/mips_loongson_mmi.txt +7 -7
  169. package/android/src/main/cpp/libyuv/unit_test/testdata/riscv64.txt +3 -3
  170. package/android/src/main/cpp/libyuv/unit_test/testdata/riscv64_rvv.txt +3 -3
  171. package/android/src/main/cpp/libyuv/unit_test/testdata/riscv64_rvv_zvfh.txt +3 -3
  172. package/android/src/main/cpp/libyuv/unit_test/testdata/tegra3.txt +23 -23
  173. package/android/src/main/cpp/libyuv/unit_test/unit_test.cc +581 -581
  174. package/android/src/main/cpp/libyuv/unit_test/unit_test.h +232 -232
  175. package/android/src/main/cpp/libyuv/unit_test/video_common_test.cc +112 -112
  176. package/android/src/main/cpp/libyuv/util/Makefile +9 -9
  177. package/android/src/main/cpp/libyuv/util/color.cc +120 -120
  178. package/android/src/main/cpp/libyuv/util/compare.cc +67 -67
  179. package/android/src/main/cpp/libyuv/util/cpuid.c +211 -211
  180. package/android/src/main/cpp/libyuv/util/i444tonv12_eg.cc +27 -27
  181. package/android/src/main/cpp/libyuv/util/psnr.cc +291 -291
  182. package/android/src/main/cpp/libyuv/util/psnr.h +47 -47
  183. package/android/src/main/cpp/libyuv/util/psnr_main.cc +620 -620
  184. package/android/src/main/cpp/libyuv/util/ssim.cc +364 -364
  185. package/android/src/main/cpp/libyuv/util/ssim.h +38 -38
  186. package/android/src/main/cpp/libyuv/util/yuvconstants.c +114 -114
  187. package/android/src/main/cpp/libyuv/util/yuvconvert.cc +367 -367
  188. package/android/src/main/cpp/libyuv/winarm.mk +47 -47
  189. package/package.json +86 -84
  190. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  191. package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
  192. package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
  193. package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  194. package/android/.gradle/8.9/gc.properties +0 -0
  195. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  196. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  197. package/android/.gradle/vcs-1/gc.properties +0 -0
@@ -1,962 +1,962 @@
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 <stdlib.h>
12
-
13
- #include "../unit_test/unit_test.h"
14
- #include "libyuv/cpu_id.h"
15
- #include "libyuv/rotate.h"
16
-
17
- #ifdef ENABLE_ROW_TESTS
18
- #include "libyuv/rotate_row.h"
19
- #endif
20
-
21
- namespace libyuv {
22
-
23
- #define SUBSAMPLE(v, a) ((((v) + (a)-1)) / (a))
24
-
25
- static void I420TestRotate(int src_width,
26
- int src_height,
27
- int dst_width,
28
- int dst_height,
29
- libyuv::RotationMode mode,
30
- int benchmark_iterations,
31
- int disable_cpu_flags,
32
- int benchmark_cpu_info) {
33
- if (src_width < 1) {
34
- src_width = 1;
35
- }
36
- if (src_height == 0) {
37
- src_height = 1;
38
- }
39
- if (dst_width < 1) {
40
- dst_width = 1;
41
- }
42
- if (dst_height < 1) {
43
- dst_height = 1;
44
- }
45
- int src_i420_y_size = src_width * Abs(src_height);
46
- int src_i420_uv_size = ((src_width + 1) / 2) * ((Abs(src_height) + 1) / 2);
47
- int src_i420_size = src_i420_y_size + src_i420_uv_size * 2;
48
- align_buffer_page_end(src_i420, src_i420_size);
49
- for (int i = 0; i < src_i420_size; ++i) {
50
- src_i420[i] = fastrand() & 0xff;
51
- }
52
-
53
- int dst_i420_y_size = dst_width * dst_height;
54
- int dst_i420_uv_size = ((dst_width + 1) / 2) * ((dst_height + 1) / 2);
55
- int dst_i420_size = dst_i420_y_size + dst_i420_uv_size * 2;
56
- align_buffer_page_end(dst_i420_c, dst_i420_size);
57
- align_buffer_page_end(dst_i420_opt, dst_i420_size);
58
- memset(dst_i420_c, 2, dst_i420_size);
59
- memset(dst_i420_opt, 3, dst_i420_size);
60
-
61
- MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
62
- I420Rotate(src_i420, src_width, src_i420 + src_i420_y_size,
63
- (src_width + 1) / 2, src_i420 + src_i420_y_size + src_i420_uv_size,
64
- (src_width + 1) / 2, dst_i420_c, dst_width,
65
- dst_i420_c + dst_i420_y_size, (dst_width + 1) / 2,
66
- dst_i420_c + dst_i420_y_size + dst_i420_uv_size,
67
- (dst_width + 1) / 2, src_width, src_height, mode);
68
-
69
- MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
70
- for (int i = 0; i < benchmark_iterations; ++i) {
71
- I420Rotate(
72
- src_i420, src_width, src_i420 + src_i420_y_size, (src_width + 1) / 2,
73
- src_i420 + src_i420_y_size + src_i420_uv_size, (src_width + 1) / 2,
74
- dst_i420_opt, dst_width, dst_i420_opt + dst_i420_y_size,
75
- (dst_width + 1) / 2, dst_i420_opt + dst_i420_y_size + dst_i420_uv_size,
76
- (dst_width + 1) / 2, src_width, src_height, mode);
77
- }
78
-
79
- // Rotation should be exact.
80
- for (int i = 0; i < dst_i420_size; ++i) {
81
- EXPECT_EQ(dst_i420_c[i], dst_i420_opt[i]);
82
- }
83
-
84
- free_aligned_buffer_page_end(dst_i420_c);
85
- free_aligned_buffer_page_end(dst_i420_opt);
86
- free_aligned_buffer_page_end(src_i420);
87
- }
88
-
89
- TEST_F(LibYUVRotateTest, I420Rotate0_Opt) {
90
- I420TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
91
- benchmark_height_, kRotate0, benchmark_iterations_,
92
- disable_cpu_flags_, benchmark_cpu_info_);
93
- }
94
-
95
- TEST_F(LibYUVRotateTest, I420Rotate90_Opt) {
96
- I420TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
97
- benchmark_width_, kRotate90, benchmark_iterations_,
98
- disable_cpu_flags_, benchmark_cpu_info_);
99
- }
100
-
101
- TEST_F(LibYUVRotateTest, I420Rotate180_Opt) {
102
- I420TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
103
- benchmark_height_, kRotate180, benchmark_iterations_,
104
- disable_cpu_flags_, benchmark_cpu_info_);
105
- }
106
-
107
- TEST_F(LibYUVRotateTest, I420Rotate270_Opt) {
108
- I420TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
109
- benchmark_width_, kRotate270, benchmark_iterations_,
110
- disable_cpu_flags_, benchmark_cpu_info_);
111
- }
112
-
113
- // TODO(fbarchard): Remove odd width tests.
114
- // Odd width tests work but disabled because they use C code and can be
115
- // tested by passing an odd width command line or environment variable.
116
- TEST_F(LibYUVRotateTest, DISABLED_I420Rotate0_Odd) {
117
- I420TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
118
- benchmark_width_ + 1, benchmark_height_ + 1, kRotate0,
119
- benchmark_iterations_, disable_cpu_flags_,
120
- benchmark_cpu_info_);
121
- }
122
-
123
- TEST_F(LibYUVRotateTest, DISABLED_I420Rotate90_Odd) {
124
- I420TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
125
- benchmark_height_ + 1, benchmark_width_ + 1, kRotate90,
126
- benchmark_iterations_, disable_cpu_flags_,
127
- benchmark_cpu_info_);
128
- }
129
-
130
- TEST_F(LibYUVRotateTest, DISABLED_I420Rotate180_Odd) {
131
- I420TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
132
- benchmark_width_ + 1, benchmark_height_ + 1, kRotate180,
133
- benchmark_iterations_, disable_cpu_flags_,
134
- benchmark_cpu_info_);
135
- }
136
-
137
- TEST_F(LibYUVRotateTest, DISABLED_I420Rotate270_Odd) {
138
- I420TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
139
- benchmark_height_ + 1, benchmark_width_ + 1, kRotate270,
140
- benchmark_iterations_, disable_cpu_flags_,
141
- benchmark_cpu_info_);
142
- }
143
-
144
- static void I422TestRotate(int src_width,
145
- int src_height,
146
- int dst_width,
147
- int dst_height,
148
- libyuv::RotationMode mode,
149
- int benchmark_iterations,
150
- int disable_cpu_flags,
151
- int benchmark_cpu_info) {
152
- if (src_width < 1) {
153
- src_width = 1;
154
- }
155
- if (src_height == 0) {
156
- src_height = 1;
157
- }
158
- if (dst_width < 1) {
159
- dst_width = 1;
160
- }
161
- if (dst_height < 1) {
162
- dst_height = 1;
163
- }
164
- int src_i422_y_size = src_width * Abs(src_height);
165
- int src_i422_uv_size = ((src_width + 1) / 2) * Abs(src_height);
166
- int src_i422_size = src_i422_y_size + src_i422_uv_size * 2;
167
- align_buffer_page_end(src_i422, src_i422_size);
168
- for (int i = 0; i < src_i422_size; ++i) {
169
- src_i422[i] = fastrand() & 0xff;
170
- }
171
-
172
- int dst_i422_y_size = dst_width * dst_height;
173
- int dst_i422_uv_size = ((dst_width + 1) / 2) * dst_height;
174
- int dst_i422_size = dst_i422_y_size + dst_i422_uv_size * 2;
175
- align_buffer_page_end(dst_i422_c, dst_i422_size);
176
- align_buffer_page_end(dst_i422_opt, dst_i422_size);
177
- memset(dst_i422_c, 2, dst_i422_size);
178
- memset(dst_i422_opt, 3, dst_i422_size);
179
-
180
- MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
181
- I422Rotate(src_i422, src_width, src_i422 + src_i422_y_size,
182
- (src_width + 1) / 2, src_i422 + src_i422_y_size + src_i422_uv_size,
183
- (src_width + 1) / 2, dst_i422_c, dst_width,
184
- dst_i422_c + dst_i422_y_size, (dst_width + 1) / 2,
185
- dst_i422_c + dst_i422_y_size + dst_i422_uv_size,
186
- (dst_width + 1) / 2, src_width, src_height, mode);
187
-
188
- MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
189
- for (int i = 0; i < benchmark_iterations; ++i) {
190
- I422Rotate(
191
- src_i422, src_width, src_i422 + src_i422_y_size, (src_width + 1) / 2,
192
- src_i422 + src_i422_y_size + src_i422_uv_size, (src_width + 1) / 2,
193
- dst_i422_opt, dst_width, dst_i422_opt + dst_i422_y_size,
194
- (dst_width + 1) / 2, dst_i422_opt + dst_i422_y_size + dst_i422_uv_size,
195
- (dst_width + 1) / 2, src_width, src_height, mode);
196
- }
197
-
198
- // Rotation should be exact.
199
- for (int i = 0; i < dst_i422_size; ++i) {
200
- EXPECT_EQ(dst_i422_c[i], dst_i422_opt[i]);
201
- }
202
-
203
- free_aligned_buffer_page_end(dst_i422_c);
204
- free_aligned_buffer_page_end(dst_i422_opt);
205
- free_aligned_buffer_page_end(src_i422);
206
- }
207
-
208
- TEST_F(LibYUVRotateTest, I422Rotate0_Opt) {
209
- I422TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
210
- benchmark_height_, kRotate0, benchmark_iterations_,
211
- disable_cpu_flags_, benchmark_cpu_info_);
212
- }
213
-
214
- TEST_F(LibYUVRotateTest, I422Rotate90_Opt) {
215
- I422TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
216
- benchmark_width_, kRotate90, benchmark_iterations_,
217
- disable_cpu_flags_, benchmark_cpu_info_);
218
- }
219
-
220
- TEST_F(LibYUVRotateTest, I422Rotate180_Opt) {
221
- I422TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
222
- benchmark_height_, kRotate180, benchmark_iterations_,
223
- disable_cpu_flags_, benchmark_cpu_info_);
224
- }
225
-
226
- TEST_F(LibYUVRotateTest, I422Rotate270_Opt) {
227
- I422TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
228
- benchmark_width_, kRotate270, benchmark_iterations_,
229
- disable_cpu_flags_, benchmark_cpu_info_);
230
- }
231
-
232
- static void I444TestRotate(int src_width,
233
- int src_height,
234
- int dst_width,
235
- int dst_height,
236
- libyuv::RotationMode mode,
237
- int benchmark_iterations,
238
- int disable_cpu_flags,
239
- int benchmark_cpu_info) {
240
- if (src_width < 1) {
241
- src_width = 1;
242
- }
243
- if (src_height == 0) {
244
- src_height = 1;
245
- }
246
- if (dst_width < 1) {
247
- dst_width = 1;
248
- }
249
- if (dst_height < 1) {
250
- dst_height = 1;
251
- }
252
- int src_i444_y_size = src_width * Abs(src_height);
253
- int src_i444_uv_size = src_width * Abs(src_height);
254
- int src_i444_size = src_i444_y_size + src_i444_uv_size * 2;
255
- align_buffer_page_end(src_i444, src_i444_size);
256
- for (int i = 0; i < src_i444_size; ++i) {
257
- src_i444[i] = fastrand() & 0xff;
258
- }
259
-
260
- int dst_i444_y_size = dst_width * dst_height;
261
- int dst_i444_uv_size = dst_width * dst_height;
262
- int dst_i444_size = dst_i444_y_size + dst_i444_uv_size * 2;
263
- align_buffer_page_end(dst_i444_c, dst_i444_size);
264
- align_buffer_page_end(dst_i444_opt, dst_i444_size);
265
- memset(dst_i444_c, 2, dst_i444_size);
266
- memset(dst_i444_opt, 3, dst_i444_size);
267
-
268
- MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
269
- I444Rotate(src_i444, src_width, src_i444 + src_i444_y_size, src_width,
270
- src_i444 + src_i444_y_size + src_i444_uv_size, src_width,
271
- dst_i444_c, dst_width, dst_i444_c + dst_i444_y_size, dst_width,
272
- dst_i444_c + dst_i444_y_size + dst_i444_uv_size, dst_width,
273
- src_width, src_height, mode);
274
-
275
- MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
276
- for (int i = 0; i < benchmark_iterations; ++i) {
277
- I444Rotate(src_i444, src_width, src_i444 + src_i444_y_size, src_width,
278
- src_i444 + src_i444_y_size + src_i444_uv_size, src_width,
279
- dst_i444_opt, dst_width, dst_i444_opt + dst_i444_y_size,
280
- dst_width, dst_i444_opt + dst_i444_y_size + dst_i444_uv_size,
281
- dst_width, src_width, src_height, mode);
282
- }
283
-
284
- // Rotation should be exact.
285
- for (int i = 0; i < dst_i444_size; ++i) {
286
- EXPECT_EQ(dst_i444_c[i], dst_i444_opt[i]);
287
- }
288
-
289
- free_aligned_buffer_page_end(dst_i444_c);
290
- free_aligned_buffer_page_end(dst_i444_opt);
291
- free_aligned_buffer_page_end(src_i444);
292
- }
293
-
294
- TEST_F(LibYUVRotateTest, I444Rotate0_Opt) {
295
- I444TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
296
- benchmark_height_, kRotate0, benchmark_iterations_,
297
- disable_cpu_flags_, benchmark_cpu_info_);
298
- }
299
-
300
- TEST_F(LibYUVRotateTest, I444Rotate90_Opt) {
301
- I444TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
302
- benchmark_width_, kRotate90, benchmark_iterations_,
303
- disable_cpu_flags_, benchmark_cpu_info_);
304
- }
305
-
306
- TEST_F(LibYUVRotateTest, I444Rotate180_Opt) {
307
- I444TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
308
- benchmark_height_, kRotate180, benchmark_iterations_,
309
- disable_cpu_flags_, benchmark_cpu_info_);
310
- }
311
-
312
- TEST_F(LibYUVRotateTest, I444Rotate270_Opt) {
313
- I444TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
314
- benchmark_width_, kRotate270, benchmark_iterations_,
315
- disable_cpu_flags_, benchmark_cpu_info_);
316
- }
317
-
318
- // TODO(fbarchard): Remove odd width tests.
319
- // Odd width tests work but disabled because they use C code and can be
320
- // tested by passing an odd width command line or environment variable.
321
- TEST_F(LibYUVRotateTest, DISABLED_I444Rotate0_Odd) {
322
- I444TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
323
- benchmark_width_ + 1, benchmark_height_ + 1, kRotate0,
324
- benchmark_iterations_, disable_cpu_flags_,
325
- benchmark_cpu_info_);
326
- }
327
-
328
- TEST_F(LibYUVRotateTest, DISABLED_I444Rotate90_Odd) {
329
- I444TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
330
- benchmark_height_ + 1, benchmark_width_ + 1, kRotate90,
331
- benchmark_iterations_, disable_cpu_flags_,
332
- benchmark_cpu_info_);
333
- }
334
-
335
- TEST_F(LibYUVRotateTest, DISABLED_I444Rotate180_Odd) {
336
- I444TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
337
- benchmark_width_ + 1, benchmark_height_ + 1, kRotate180,
338
- benchmark_iterations_, disable_cpu_flags_,
339
- benchmark_cpu_info_);
340
- }
341
-
342
- TEST_F(LibYUVRotateTest, DISABLED_I444Rotate270_Odd) {
343
- I444TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
344
- benchmark_height_ + 1, benchmark_width_ + 1, kRotate270,
345
- benchmark_iterations_, disable_cpu_flags_,
346
- benchmark_cpu_info_);
347
- }
348
-
349
- static void NV12TestRotate(int src_width,
350
- int src_height,
351
- int dst_width,
352
- int dst_height,
353
- libyuv::RotationMode mode,
354
- int benchmark_iterations,
355
- int disable_cpu_flags,
356
- int benchmark_cpu_info) {
357
- if (src_width < 1) {
358
- src_width = 1;
359
- }
360
- if (src_height == 0) { // allow negative for inversion test.
361
- src_height = 1;
362
- }
363
- if (dst_width < 1) {
364
- dst_width = 1;
365
- }
366
- if (dst_height < 1) {
367
- dst_height = 1;
368
- }
369
- int src_nv12_y_size = src_width * Abs(src_height);
370
- int src_nv12_uv_size =
371
- ((src_width + 1) / 2) * ((Abs(src_height) + 1) / 2) * 2;
372
- int src_nv12_size = src_nv12_y_size + src_nv12_uv_size;
373
- align_buffer_page_end(src_nv12, src_nv12_size);
374
- for (int i = 0; i < src_nv12_size; ++i) {
375
- src_nv12[i] = fastrand() & 0xff;
376
- }
377
-
378
- int dst_i420_y_size = dst_width * dst_height;
379
- int dst_i420_uv_size = ((dst_width + 1) / 2) * ((dst_height + 1) / 2);
380
- int dst_i420_size = dst_i420_y_size + dst_i420_uv_size * 2;
381
- align_buffer_page_end(dst_i420_c, dst_i420_size);
382
- align_buffer_page_end(dst_i420_opt, dst_i420_size);
383
- memset(dst_i420_c, 2, dst_i420_size);
384
- memset(dst_i420_opt, 3, dst_i420_size);
385
-
386
- MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
387
- NV12ToI420Rotate(src_nv12, src_width, src_nv12 + src_nv12_y_size,
388
- (src_width + 1) & ~1, dst_i420_c, dst_width,
389
- dst_i420_c + dst_i420_y_size, (dst_width + 1) / 2,
390
- dst_i420_c + dst_i420_y_size + dst_i420_uv_size,
391
- (dst_width + 1) / 2, src_width, src_height, mode);
392
-
393
- MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
394
- for (int i = 0; i < benchmark_iterations; ++i) {
395
- NV12ToI420Rotate(src_nv12, src_width, src_nv12 + src_nv12_y_size,
396
- (src_width + 1) & ~1, dst_i420_opt, dst_width,
397
- dst_i420_opt + dst_i420_y_size, (dst_width + 1) / 2,
398
- dst_i420_opt + dst_i420_y_size + dst_i420_uv_size,
399
- (dst_width + 1) / 2, src_width, src_height, mode);
400
- }
401
-
402
- // Rotation should be exact.
403
- for (int i = 0; i < dst_i420_size; ++i) {
404
- EXPECT_EQ(dst_i420_c[i], dst_i420_opt[i]);
405
- }
406
-
407
- free_aligned_buffer_page_end(dst_i420_c);
408
- free_aligned_buffer_page_end(dst_i420_opt);
409
- free_aligned_buffer_page_end(src_nv12);
410
- }
411
-
412
- TEST_F(LibYUVRotateTest, NV12Rotate0_Opt) {
413
- NV12TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
414
- benchmark_height_, kRotate0, benchmark_iterations_,
415
- disable_cpu_flags_, benchmark_cpu_info_);
416
- }
417
-
418
- TEST_F(LibYUVRotateTest, NV12Rotate90_Opt) {
419
- NV12TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
420
- benchmark_width_, kRotate90, benchmark_iterations_,
421
- disable_cpu_flags_, benchmark_cpu_info_);
422
- }
423
-
424
- TEST_F(LibYUVRotateTest, NV12Rotate180_Opt) {
425
- NV12TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
426
- benchmark_height_, kRotate180, benchmark_iterations_,
427
- disable_cpu_flags_, benchmark_cpu_info_);
428
- }
429
-
430
- TEST_F(LibYUVRotateTest, NV12Rotate270_Opt) {
431
- NV12TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
432
- benchmark_width_, kRotate270, benchmark_iterations_,
433
- disable_cpu_flags_, benchmark_cpu_info_);
434
- }
435
-
436
- TEST_F(LibYUVRotateTest, DISABLED_NV12Rotate0_Odd) {
437
- NV12TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
438
- benchmark_width_ + 1, benchmark_height_ + 1, kRotate0,
439
- benchmark_iterations_, disable_cpu_flags_,
440
- benchmark_cpu_info_);
441
- }
442
-
443
- TEST_F(LibYUVRotateTest, DISABLED_NV12Rotate90_Odd) {
444
- NV12TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
445
- benchmark_height_ + 1, benchmark_width_ + 1, kRotate90,
446
- benchmark_iterations_, disable_cpu_flags_,
447
- benchmark_cpu_info_);
448
- }
449
-
450
- TEST_F(LibYUVRotateTest, DISABLED_NV12Rotate180_Odd) {
451
- NV12TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
452
- benchmark_width_ + 1, benchmark_height_ + 1, kRotate180,
453
- benchmark_iterations_, disable_cpu_flags_,
454
- benchmark_cpu_info_);
455
- }
456
-
457
- TEST_F(LibYUVRotateTest, DISABLED_NV12Rotate270_Odd) {
458
- NV12TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
459
- benchmark_height_ + 1, benchmark_width_ + 1, kRotate270,
460
- benchmark_iterations_, disable_cpu_flags_,
461
- benchmark_cpu_info_);
462
- }
463
-
464
- TEST_F(LibYUVRotateTest, NV12Rotate0_Invert) {
465
- NV12TestRotate(benchmark_width_, -benchmark_height_, benchmark_width_,
466
- benchmark_height_, kRotate0, benchmark_iterations_,
467
- disable_cpu_flags_, benchmark_cpu_info_);
468
- }
469
-
470
- TEST_F(LibYUVRotateTest, NV12Rotate90_Invert) {
471
- NV12TestRotate(benchmark_width_, -benchmark_height_, benchmark_height_,
472
- benchmark_width_, kRotate90, benchmark_iterations_,
473
- disable_cpu_flags_, benchmark_cpu_info_);
474
- }
475
-
476
- TEST_F(LibYUVRotateTest, NV12Rotate180_Invert) {
477
- NV12TestRotate(benchmark_width_, -benchmark_height_, benchmark_width_,
478
- benchmark_height_, kRotate180, benchmark_iterations_,
479
- disable_cpu_flags_, benchmark_cpu_info_);
480
- }
481
-
482
- TEST_F(LibYUVRotateTest, NV12Rotate270_Invert) {
483
- NV12TestRotate(benchmark_width_, -benchmark_height_, benchmark_height_,
484
- benchmark_width_, kRotate270, benchmark_iterations_,
485
- disable_cpu_flags_, benchmark_cpu_info_);
486
- }
487
-
488
- // Test Android 420 to I420 Rotate
489
- #define TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, \
490
- SRC_SUBSAMP_Y, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
491
- W1280, N, NEG, OFF, PN, OFF_U, OFF_V, ROT) \
492
- TEST_F(LibYUVRotateTest, \
493
- SRC_FMT_PLANAR##To##FMT_PLANAR##Rotate##ROT##To##PN##N) { \
494
- const int kWidth = W1280; \
495
- const int kHeight = benchmark_height_; \
496
- const int kSizeUV = \
497
- SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); \
498
- align_buffer_page_end(src_y, kWidth* kHeight + OFF); \
499
- align_buffer_page_end(src_uv, \
500
- kSizeUV*((PIXEL_STRIDE == 3) ? 3 : 2) + OFF); \
501
- align_buffer_page_end(dst_y_c, kWidth* kHeight); \
502
- align_buffer_page_end(dst_u_c, SUBSAMPLE(kWidth, SUBSAMP_X) * \
503
- SUBSAMPLE(kHeight, SUBSAMP_Y)); \
504
- align_buffer_page_end(dst_v_c, SUBSAMPLE(kWidth, SUBSAMP_X) * \
505
- SUBSAMPLE(kHeight, SUBSAMP_Y)); \
506
- align_buffer_page_end(dst_y_opt, kWidth* kHeight); \
507
- align_buffer_page_end(dst_u_opt, SUBSAMPLE(kWidth, SUBSAMP_X) * \
508
- SUBSAMPLE(kHeight, SUBSAMP_Y)); \
509
- align_buffer_page_end(dst_v_opt, SUBSAMPLE(kWidth, SUBSAMP_X) * \
510
- SUBSAMPLE(kHeight, SUBSAMP_Y)); \
511
- uint8_t* src_u = src_uv + OFF_U; \
512
- uint8_t* src_v = src_uv + (PIXEL_STRIDE == 1 ? kSizeUV : OFF_V); \
513
- int src_stride_uv = SUBSAMPLE(kWidth, SUBSAMP_X) * PIXEL_STRIDE; \
514
- for (int i = 0; i < kHeight; ++i) \
515
- for (int j = 0; j < kWidth; ++j) \
516
- src_y[i * kWidth + j + OFF] = (fastrand() & 0xff); \
517
- for (int i = 0; i < SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); ++i) { \
518
- for (int j = 0; j < SUBSAMPLE(kWidth, SRC_SUBSAMP_X); ++j) { \
519
- src_u[(i * src_stride_uv) + j * PIXEL_STRIDE + OFF] = \
520
- (fastrand() & 0xff); \
521
- src_v[(i * src_stride_uv) + j * PIXEL_STRIDE + OFF] = \
522
- (fastrand() & 0xff); \
523
- } \
524
- } \
525
- memset(dst_y_c, 1, kWidth* kHeight); \
526
- memset(dst_u_c, 2, \
527
- SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
528
- memset(dst_v_c, 3, \
529
- SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
530
- memset(dst_y_opt, 101, kWidth* kHeight); \
531
- memset(dst_u_opt, 102, \
532
- SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
533
- memset(dst_v_opt, 103, \
534
- SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
535
- MaskCpuFlags(disable_cpu_flags_); \
536
- SRC_FMT_PLANAR##To##FMT_PLANAR##Rotate( \
537
- src_y + OFF, kWidth, src_u + OFF, SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \
538
- src_v + OFF, SUBSAMPLE(kWidth, SRC_SUBSAMP_X), PIXEL_STRIDE, dst_y_c, \
539
- kWidth, dst_u_c, SUBSAMPLE(kWidth, SUBSAMP_X), dst_v_c, \
540
- SUBSAMPLE(kWidth, SUBSAMP_X), kWidth, NEG kHeight, \
541
- (libyuv::RotationMode)ROT); \
542
- MaskCpuFlags(benchmark_cpu_info_); \
543
- for (int i = 0; i < benchmark_iterations_; ++i) { \
544
- SRC_FMT_PLANAR##To##FMT_PLANAR##Rotate( \
545
- src_y + OFF, kWidth, src_u + OFF, SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \
546
- src_v + OFF, SUBSAMPLE(kWidth, SRC_SUBSAMP_X), PIXEL_STRIDE, \
547
- dst_y_opt, kWidth, dst_u_opt, SUBSAMPLE(kWidth, SUBSAMP_X), \
548
- dst_v_opt, SUBSAMPLE(kWidth, SUBSAMP_X), kWidth, NEG kHeight, \
549
- (libyuv::RotationMode)ROT); \
550
- } \
551
- for (int i = 0; i < kHeight; ++i) { \
552
- for (int j = 0; j < kWidth; ++j) { \
553
- EXPECT_EQ(dst_y_c[i * kWidth + j], dst_y_opt[i * kWidth + j]); \
554
- } \
555
- } \
556
- for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \
557
- for (int j = 0; j < SUBSAMPLE(kWidth, SUBSAMP_X); ++j) { \
558
- EXPECT_EQ(dst_u_c[i * SUBSAMPLE(kWidth, SUBSAMP_X) + j], \
559
- dst_u_opt[i * SUBSAMPLE(kWidth, SUBSAMP_X) + j]); \
560
- } \
561
- } \
562
- for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \
563
- for (int j = 0; j < SUBSAMPLE(kWidth, SUBSAMP_X); ++j) { \
564
- EXPECT_EQ(dst_v_c[i * SUBSAMPLE(kWidth, SUBSAMP_X) + j], \
565
- dst_v_opt[i * SUBSAMPLE(kWidth, SUBSAMP_X) + j]); \
566
- } \
567
- } \
568
- free_aligned_buffer_page_end(dst_y_c); \
569
- free_aligned_buffer_page_end(dst_u_c); \
570
- free_aligned_buffer_page_end(dst_v_c); \
571
- free_aligned_buffer_page_end(dst_y_opt); \
572
- free_aligned_buffer_page_end(dst_u_opt); \
573
- free_aligned_buffer_page_end(dst_v_opt); \
574
- free_aligned_buffer_page_end(src_y); \
575
- free_aligned_buffer_page_end(src_uv); \
576
- }
577
-
578
- #define TESTAPLANARTOP(SRC_FMT_PLANAR, PN, PIXEL_STRIDE, OFF_U, OFF_V, \
579
- SRC_SUBSAMP_X, SRC_SUBSAMP_Y, FMT_PLANAR, SUBSAMP_X, \
580
- SUBSAMP_Y) \
581
- TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
582
- FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, benchmark_width_ + 1, \
583
- _Any, +, 0, PN, OFF_U, OFF_V, 0) \
584
- TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
585
- FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, benchmark_width_, \
586
- _Unaligned, +, 2, PN, OFF_U, OFF_V, 0) \
587
- TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
588
- FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, benchmark_width_, _Invert, \
589
- -, 0, PN, OFF_U, OFF_V, 0) \
590
- TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
591
- FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, benchmark_width_, _Opt, +, \
592
- 0, PN, OFF_U, OFF_V, 0) \
593
- TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
594
- FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, benchmark_width_, _Opt, +, \
595
- 0, PN, OFF_U, OFF_V, 180)
596
-
597
- TESTAPLANARTOP(Android420, I420, 1, 0, 0, 2, 2, I420, 2, 2)
598
- TESTAPLANARTOP(Android420, NV12, 2, 0, 1, 2, 2, I420, 2, 2)
599
- TESTAPLANARTOP(Android420, NV21, 2, 1, 0, 2, 2, I420, 2, 2)
600
- #undef TESTAPLANARTOP
601
- #undef TESTAPLANARTOPI
602
-
603
- static void I010TestRotate(int src_width,
604
- int src_height,
605
- int dst_width,
606
- int dst_height,
607
- libyuv::RotationMode mode,
608
- int benchmark_iterations,
609
- int disable_cpu_flags,
610
- int benchmark_cpu_info) {
611
- if (src_width < 1) {
612
- src_width = 1;
613
- }
614
- if (src_height == 0) {
615
- src_height = 1;
616
- }
617
- if (dst_width < 1) {
618
- dst_width = 1;
619
- }
620
- if (dst_height < 1) {
621
- dst_height = 1;
622
- }
623
- int src_i010_y_size = src_width * Abs(src_height);
624
- int src_i010_uv_size = ((src_width + 1) / 2) * ((Abs(src_height) + 1) / 2);
625
- int src_i010_size = src_i010_y_size + src_i010_uv_size * 2;
626
- align_buffer_page_end_16(src_i010, src_i010_size);
627
- for (int i = 0; i < src_i010_size; ++i) {
628
- src_i010[i] = fastrand() & 0x3ff;
629
- }
630
-
631
- int dst_i010_y_size = dst_width * dst_height;
632
- int dst_i010_uv_size = ((dst_width + 1) / 2) * ((dst_height + 1) / 2);
633
- int dst_i010_size = dst_i010_y_size + dst_i010_uv_size * 2;
634
- align_buffer_page_end_16(dst_i010_c, dst_i010_size);
635
- align_buffer_page_end_16(dst_i010_opt, dst_i010_size);
636
- memset(dst_i010_c, 2, dst_i010_size * 2);
637
- memset(dst_i010_opt, 3, dst_i010_size * 2);
638
-
639
- MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
640
- I010Rotate(src_i010, src_width, src_i010 + src_i010_y_size,
641
- (src_width + 1) / 2, src_i010 + src_i010_y_size + src_i010_uv_size,
642
- (src_width + 1) / 2, dst_i010_c, dst_width,
643
- dst_i010_c + dst_i010_y_size, (dst_width + 1) / 2,
644
- dst_i010_c + dst_i010_y_size + dst_i010_uv_size,
645
- (dst_width + 1) / 2, src_width, src_height, mode);
646
-
647
- MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
648
- for (int i = 0; i < benchmark_iterations; ++i) {
649
- I010Rotate(
650
- src_i010, src_width, src_i010 + src_i010_y_size, (src_width + 1) / 2,
651
- src_i010 + src_i010_y_size + src_i010_uv_size, (src_width + 1) / 2,
652
- dst_i010_opt, dst_width, dst_i010_opt + dst_i010_y_size,
653
- (dst_width + 1) / 2, dst_i010_opt + dst_i010_y_size + dst_i010_uv_size,
654
- (dst_width + 1) / 2, src_width, src_height, mode);
655
- }
656
-
657
- // Rotation should be exact.
658
- for (int i = 0; i < dst_i010_size; ++i) {
659
- EXPECT_EQ(dst_i010_c[i], dst_i010_opt[i]);
660
- }
661
-
662
- free_aligned_buffer_page_end_16(dst_i010_c);
663
- free_aligned_buffer_page_end_16(dst_i010_opt);
664
- free_aligned_buffer_page_end_16(src_i010);
665
- }
666
-
667
- TEST_F(LibYUVRotateTest, I010Rotate0_Opt) {
668
- I010TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
669
- benchmark_height_, kRotate0, benchmark_iterations_,
670
- disable_cpu_flags_, benchmark_cpu_info_);
671
- }
672
-
673
- TEST_F(LibYUVRotateTest, I010Rotate90_Opt) {
674
- I010TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
675
- benchmark_width_, kRotate90, benchmark_iterations_,
676
- disable_cpu_flags_, benchmark_cpu_info_);
677
- }
678
-
679
- TEST_F(LibYUVRotateTest, I010Rotate180_Opt) {
680
- I010TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
681
- benchmark_height_, kRotate180, benchmark_iterations_,
682
- disable_cpu_flags_, benchmark_cpu_info_);
683
- }
684
-
685
- TEST_F(LibYUVRotateTest, I010Rotate270_Opt) {
686
- I010TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
687
- benchmark_width_, kRotate270, benchmark_iterations_,
688
- disable_cpu_flags_, benchmark_cpu_info_);
689
- }
690
-
691
- static void I210TestRotate(int src_width,
692
- int src_height,
693
- int dst_width,
694
- int dst_height,
695
- libyuv::RotationMode mode,
696
- int benchmark_iterations,
697
- int disable_cpu_flags,
698
- int benchmark_cpu_info) {
699
- if (src_width < 1) {
700
- src_width = 1;
701
- }
702
- if (src_height == 0) {
703
- src_height = 1;
704
- }
705
- if (dst_width < 1) {
706
- dst_width = 1;
707
- }
708
- if (dst_height < 1) {
709
- dst_height = 1;
710
- }
711
- int src_i210_y_size = src_width * Abs(src_height);
712
- int src_i210_uv_size = ((src_width + 1) / 2) * Abs(src_height);
713
- int src_i210_size = src_i210_y_size + src_i210_uv_size * 2;
714
- align_buffer_page_end_16(src_i210, src_i210_size);
715
- for (int i = 0; i < src_i210_size; ++i) {
716
- src_i210[i] = fastrand() & 0x3ff;
717
- }
718
-
719
- int dst_i210_y_size = dst_width * dst_height;
720
- int dst_i210_uv_size = ((dst_width + 1) / 2) * dst_height;
721
- int dst_i210_size = dst_i210_y_size + dst_i210_uv_size * 2;
722
- align_buffer_page_end_16(dst_i210_c, dst_i210_size);
723
- align_buffer_page_end_16(dst_i210_opt, dst_i210_size);
724
- memset(dst_i210_c, 2, dst_i210_size * 2);
725
- memset(dst_i210_opt, 3, dst_i210_size * 2);
726
-
727
- MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
728
- I210Rotate(src_i210, src_width, src_i210 + src_i210_y_size,
729
- (src_width + 1) / 2, src_i210 + src_i210_y_size + src_i210_uv_size,
730
- (src_width + 1) / 2, dst_i210_c, dst_width,
731
- dst_i210_c + dst_i210_y_size, (dst_width + 1) / 2,
732
- dst_i210_c + dst_i210_y_size + dst_i210_uv_size,
733
- (dst_width + 1) / 2, src_width, src_height, mode);
734
-
735
- MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
736
- for (int i = 0; i < benchmark_iterations; ++i) {
737
- I210Rotate(
738
- src_i210, src_width, src_i210 + src_i210_y_size, (src_width + 1) / 2,
739
- src_i210 + src_i210_y_size + src_i210_uv_size, (src_width + 1) / 2,
740
- dst_i210_opt, dst_width, dst_i210_opt + dst_i210_y_size,
741
- (dst_width + 1) / 2, dst_i210_opt + dst_i210_y_size + dst_i210_uv_size,
742
- (dst_width + 1) / 2, src_width, src_height, mode);
743
- }
744
-
745
- // Rotation should be exact.
746
- for (int i = 0; i < dst_i210_size; ++i) {
747
- EXPECT_EQ(dst_i210_c[i], dst_i210_opt[i]);
748
- }
749
-
750
- free_aligned_buffer_page_end_16(dst_i210_c);
751
- free_aligned_buffer_page_end_16(dst_i210_opt);
752
- free_aligned_buffer_page_end_16(src_i210);
753
- }
754
-
755
- TEST_F(LibYUVRotateTest, I210Rotate0_Opt) {
756
- I210TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
757
- benchmark_height_, kRotate0, benchmark_iterations_,
758
- disable_cpu_flags_, benchmark_cpu_info_);
759
- }
760
-
761
- TEST_F(LibYUVRotateTest, I210Rotate90_Opt) {
762
- I210TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
763
- benchmark_width_, kRotate90, benchmark_iterations_,
764
- disable_cpu_flags_, benchmark_cpu_info_);
765
- }
766
-
767
- TEST_F(LibYUVRotateTest, I210Rotate180_Opt) {
768
- I210TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
769
- benchmark_height_, kRotate180, benchmark_iterations_,
770
- disable_cpu_flags_, benchmark_cpu_info_);
771
- }
772
-
773
- TEST_F(LibYUVRotateTest, I210Rotate270_Opt) {
774
- I210TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
775
- benchmark_width_, kRotate270, benchmark_iterations_,
776
- disable_cpu_flags_, benchmark_cpu_info_);
777
- }
778
-
779
- static void I410TestRotate(int src_width,
780
- int src_height,
781
- int dst_width,
782
- int dst_height,
783
- libyuv::RotationMode mode,
784
- int benchmark_iterations,
785
- int disable_cpu_flags,
786
- int benchmark_cpu_info) {
787
- if (src_width < 1) {
788
- src_width = 1;
789
- }
790
- if (src_height == 0) {
791
- src_height = 1;
792
- }
793
- if (dst_width < 1) {
794
- dst_width = 1;
795
- }
796
- if (dst_height < 1) {
797
- dst_height = 1;
798
- }
799
- int src_i410_y_size = src_width * Abs(src_height);
800
- int src_i410_uv_size = src_width * Abs(src_height);
801
- int src_i410_size = src_i410_y_size + src_i410_uv_size * 2;
802
- align_buffer_page_end_16(src_i410, src_i410_size);
803
- for (int i = 0; i < src_i410_size; ++i) {
804
- src_i410[i] = fastrand() & 0x3ff;
805
- }
806
-
807
- int dst_i410_y_size = dst_width * dst_height;
808
- int dst_i410_uv_size = dst_width * dst_height;
809
- int dst_i410_size = dst_i410_y_size + dst_i410_uv_size * 2;
810
- align_buffer_page_end_16(dst_i410_c, dst_i410_size);
811
- align_buffer_page_end_16(dst_i410_opt, dst_i410_size);
812
- memset(dst_i410_c, 2, dst_i410_size * 2);
813
- memset(dst_i410_opt, 3, dst_i410_size * 2);
814
-
815
- MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
816
- I410Rotate(src_i410, src_width, src_i410 + src_i410_y_size, src_width,
817
- src_i410 + src_i410_y_size + src_i410_uv_size, src_width,
818
- dst_i410_c, dst_width, dst_i410_c + dst_i410_y_size, dst_width,
819
- dst_i410_c + dst_i410_y_size + dst_i410_uv_size, dst_width,
820
- src_width, src_height, mode);
821
-
822
- MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
823
- for (int i = 0; i < benchmark_iterations; ++i) {
824
- I410Rotate(src_i410, src_width, src_i410 + src_i410_y_size, src_width,
825
- src_i410 + src_i410_y_size + src_i410_uv_size, src_width,
826
- dst_i410_opt, dst_width, dst_i410_opt + dst_i410_y_size,
827
- dst_width, dst_i410_opt + dst_i410_y_size + dst_i410_uv_size,
828
- dst_width, src_width, src_height, mode);
829
- }
830
-
831
- // Rotation should be exact.
832
- for (int i = 0; i < dst_i410_size; ++i) {
833
- EXPECT_EQ(dst_i410_c[i], dst_i410_opt[i]);
834
- }
835
-
836
- free_aligned_buffer_page_end_16(dst_i410_c);
837
- free_aligned_buffer_page_end_16(dst_i410_opt);
838
- free_aligned_buffer_page_end_16(src_i410);
839
- }
840
-
841
- TEST_F(LibYUVRotateTest, I410Rotate0_Opt) {
842
- I410TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
843
- benchmark_height_, kRotate0, benchmark_iterations_,
844
- disable_cpu_flags_, benchmark_cpu_info_);
845
- }
846
-
847
- TEST_F(LibYUVRotateTest, I410Rotate90_Opt) {
848
- I410TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
849
- benchmark_width_, kRotate90, benchmark_iterations_,
850
- disable_cpu_flags_, benchmark_cpu_info_);
851
- }
852
-
853
- TEST_F(LibYUVRotateTest, I410Rotate180_Opt) {
854
- I410TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
855
- benchmark_height_, kRotate180, benchmark_iterations_,
856
- disable_cpu_flags_, benchmark_cpu_info_);
857
- }
858
-
859
- TEST_F(LibYUVRotateTest, I410Rotate270_Opt) {
860
- I410TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
861
- benchmark_width_, kRotate270, benchmark_iterations_,
862
- disable_cpu_flags_, benchmark_cpu_info_);
863
- }
864
-
865
- #if defined(ENABLE_ROW_TESTS)
866
-
867
- TEST_F(LibYUVRotateTest, Transpose4x4_Test) {
868
- // dst width and height
869
- const int width = 4;
870
- const int height = 4;
871
- int src_pixels[4][4];
872
- int dst_pixels_c[4][4];
873
- int dst_pixels_opt[4][4];
874
-
875
- for (int i = 0; i < 4; ++i) {
876
- for (int j = 0; j < 4; ++j) {
877
- src_pixels[i][j] = i * 10 + j;
878
- }
879
- }
880
- memset(dst_pixels_c, 1, width * height * 4);
881
- memset(dst_pixels_opt, 2, width * height * 4);
882
-
883
- Transpose4x4_32_C((const uint8_t*)src_pixels, height * 4,
884
- (uint8_t*)dst_pixels_c, width * 4, width);
885
-
886
- const int benchmark_iterations =
887
- (benchmark_iterations_ * benchmark_width_ * benchmark_height_ + 15) /
888
- (4 * 4);
889
- for (int i = 0; i < benchmark_iterations; ++i) {
890
- #if defined(HAS_TRANSPOSE4X4_32_NEON)
891
- if (TestCpuFlag(kCpuHasNEON)) {
892
- Transpose4x4_32_NEON((const uint8_t*)src_pixels, height * 4,
893
- (uint8_t*)dst_pixels_opt, width * 4, width);
894
- } else
895
- #elif defined(HAS_TRANSPOSE4X4_32_SSE2)
896
- if (TestCpuFlag(kCpuHasSSE2)) {
897
- Transpose4x4_32_SSE2((const uint8_t*)src_pixels, height * 4,
898
- (uint8_t*)dst_pixels_opt, width * 4, width);
899
- } else
900
- #endif
901
- {
902
- Transpose4x4_32_C((const uint8_t*)src_pixels, height * 4,
903
- (uint8_t*)dst_pixels_opt, width * 4, width);
904
- }
905
- }
906
-
907
- for (int i = 0; i < 4; ++i) {
908
- for (int j = 0; j < 4; ++j) {
909
- EXPECT_EQ(dst_pixels_c[i][j], src_pixels[j][i]);
910
- EXPECT_EQ(dst_pixels_c[i][j], dst_pixels_opt[i][j]);
911
- }
912
- }
913
- }
914
-
915
- TEST_F(LibYUVRotateTest, Transpose4x4_Opt) {
916
- // dst width and height
917
- const int width = ((benchmark_width_ * benchmark_height_ + 3) / 4 + 3) & ~3;
918
- const int height = 4;
919
- align_buffer_page_end(src_pixels, height * width * 4);
920
- align_buffer_page_end(dst_pixels_c, width * height * 4);
921
- align_buffer_page_end(dst_pixels_opt, width * height * 4);
922
-
923
- MemRandomize(src_pixels, height * width * 4);
924
- memset(dst_pixels_c, 1, width * height * 4);
925
- memset(dst_pixels_opt, 2, width * height * 4);
926
-
927
- Transpose4x4_32_C((const uint8_t*)src_pixels, height * 4,
928
- (uint8_t*)dst_pixels_c, width * 4, width);
929
-
930
- for (int i = 0; i < benchmark_iterations_; ++i) {
931
- #if defined(HAS_TRANSPOSE4X4_32_NEON)
932
- if (TestCpuFlag(kCpuHasNEON)) {
933
- Transpose4x4_32_NEON((const uint8_t*)src_pixels, height * 4,
934
- (uint8_t*)dst_pixels_opt, width * 4, width);
935
- } else
936
- #elif defined(HAS_TRANSPOSE4X4_32_AVX2)
937
- if (TestCpuFlag(kCpuHasAVX2)) {
938
- Transpose4x4_32_AVX2((const uint8_t*)src_pixels, height * 4,
939
- (uint8_t*)dst_pixels_opt, width * 4, width);
940
- } else if (TestCpuFlag(kCpuHasSSE2)) {
941
- Transpose4x4_32_SSE2((const uint8_t*)src_pixels, height * 4,
942
- (uint8_t*)dst_pixels_opt, width * 4, width);
943
- } else
944
- #endif
945
- {
946
- Transpose4x4_32_C((const uint8_t*)src_pixels, height * 4,
947
- (uint8_t*)dst_pixels_opt, width * 4, width);
948
- }
949
- }
950
-
951
- for (int i = 0; i < width * height; ++i) {
952
- EXPECT_EQ(dst_pixels_c[i], dst_pixels_opt[i]);
953
- }
954
-
955
- free_aligned_buffer_page_end(src_pixels);
956
- free_aligned_buffer_page_end(dst_pixels_c);
957
- free_aligned_buffer_page_end(dst_pixels_opt);
958
- }
959
-
960
- #endif // ENABLE_ROW_TESTS
961
-
962
- } // namespace libyuv
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 <stdlib.h>
12
+
13
+ #include "../unit_test/unit_test.h"
14
+ #include "libyuv/cpu_id.h"
15
+ #include "libyuv/rotate.h"
16
+
17
+ #ifdef ENABLE_ROW_TESTS
18
+ #include "libyuv/rotate_row.h"
19
+ #endif
20
+
21
+ namespace libyuv {
22
+
23
+ #define SUBSAMPLE(v, a) ((((v) + (a)-1)) / (a))
24
+
25
+ static void I420TestRotate(int src_width,
26
+ int src_height,
27
+ int dst_width,
28
+ int dst_height,
29
+ libyuv::RotationMode mode,
30
+ int benchmark_iterations,
31
+ int disable_cpu_flags,
32
+ int benchmark_cpu_info) {
33
+ if (src_width < 1) {
34
+ src_width = 1;
35
+ }
36
+ if (src_height == 0) {
37
+ src_height = 1;
38
+ }
39
+ if (dst_width < 1) {
40
+ dst_width = 1;
41
+ }
42
+ if (dst_height < 1) {
43
+ dst_height = 1;
44
+ }
45
+ int src_i420_y_size = src_width * Abs(src_height);
46
+ int src_i420_uv_size = ((src_width + 1) / 2) * ((Abs(src_height) + 1) / 2);
47
+ int src_i420_size = src_i420_y_size + src_i420_uv_size * 2;
48
+ align_buffer_page_end(src_i420, src_i420_size);
49
+ for (int i = 0; i < src_i420_size; ++i) {
50
+ src_i420[i] = fastrand() & 0xff;
51
+ }
52
+
53
+ int dst_i420_y_size = dst_width * dst_height;
54
+ int dst_i420_uv_size = ((dst_width + 1) / 2) * ((dst_height + 1) / 2);
55
+ int dst_i420_size = dst_i420_y_size + dst_i420_uv_size * 2;
56
+ align_buffer_page_end(dst_i420_c, dst_i420_size);
57
+ align_buffer_page_end(dst_i420_opt, dst_i420_size);
58
+ memset(dst_i420_c, 2, dst_i420_size);
59
+ memset(dst_i420_opt, 3, dst_i420_size);
60
+
61
+ MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
62
+ I420Rotate(src_i420, src_width, src_i420 + src_i420_y_size,
63
+ (src_width + 1) / 2, src_i420 + src_i420_y_size + src_i420_uv_size,
64
+ (src_width + 1) / 2, dst_i420_c, dst_width,
65
+ dst_i420_c + dst_i420_y_size, (dst_width + 1) / 2,
66
+ dst_i420_c + dst_i420_y_size + dst_i420_uv_size,
67
+ (dst_width + 1) / 2, src_width, src_height, mode);
68
+
69
+ MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
70
+ for (int i = 0; i < benchmark_iterations; ++i) {
71
+ I420Rotate(
72
+ src_i420, src_width, src_i420 + src_i420_y_size, (src_width + 1) / 2,
73
+ src_i420 + src_i420_y_size + src_i420_uv_size, (src_width + 1) / 2,
74
+ dst_i420_opt, dst_width, dst_i420_opt + dst_i420_y_size,
75
+ (dst_width + 1) / 2, dst_i420_opt + dst_i420_y_size + dst_i420_uv_size,
76
+ (dst_width + 1) / 2, src_width, src_height, mode);
77
+ }
78
+
79
+ // Rotation should be exact.
80
+ for (int i = 0; i < dst_i420_size; ++i) {
81
+ EXPECT_EQ(dst_i420_c[i], dst_i420_opt[i]);
82
+ }
83
+
84
+ free_aligned_buffer_page_end(dst_i420_c);
85
+ free_aligned_buffer_page_end(dst_i420_opt);
86
+ free_aligned_buffer_page_end(src_i420);
87
+ }
88
+
89
+ TEST_F(LibYUVRotateTest, I420Rotate0_Opt) {
90
+ I420TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
91
+ benchmark_height_, kRotate0, benchmark_iterations_,
92
+ disable_cpu_flags_, benchmark_cpu_info_);
93
+ }
94
+
95
+ TEST_F(LibYUVRotateTest, I420Rotate90_Opt) {
96
+ I420TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
97
+ benchmark_width_, kRotate90, benchmark_iterations_,
98
+ disable_cpu_flags_, benchmark_cpu_info_);
99
+ }
100
+
101
+ TEST_F(LibYUVRotateTest, I420Rotate180_Opt) {
102
+ I420TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
103
+ benchmark_height_, kRotate180, benchmark_iterations_,
104
+ disable_cpu_flags_, benchmark_cpu_info_);
105
+ }
106
+
107
+ TEST_F(LibYUVRotateTest, I420Rotate270_Opt) {
108
+ I420TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
109
+ benchmark_width_, kRotate270, benchmark_iterations_,
110
+ disable_cpu_flags_, benchmark_cpu_info_);
111
+ }
112
+
113
+ // TODO(fbarchard): Remove odd width tests.
114
+ // Odd width tests work but disabled because they use C code and can be
115
+ // tested by passing an odd width command line or environment variable.
116
+ TEST_F(LibYUVRotateTest, DISABLED_I420Rotate0_Odd) {
117
+ I420TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
118
+ benchmark_width_ + 1, benchmark_height_ + 1, kRotate0,
119
+ benchmark_iterations_, disable_cpu_flags_,
120
+ benchmark_cpu_info_);
121
+ }
122
+
123
+ TEST_F(LibYUVRotateTest, DISABLED_I420Rotate90_Odd) {
124
+ I420TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
125
+ benchmark_height_ + 1, benchmark_width_ + 1, kRotate90,
126
+ benchmark_iterations_, disable_cpu_flags_,
127
+ benchmark_cpu_info_);
128
+ }
129
+
130
+ TEST_F(LibYUVRotateTest, DISABLED_I420Rotate180_Odd) {
131
+ I420TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
132
+ benchmark_width_ + 1, benchmark_height_ + 1, kRotate180,
133
+ benchmark_iterations_, disable_cpu_flags_,
134
+ benchmark_cpu_info_);
135
+ }
136
+
137
+ TEST_F(LibYUVRotateTest, DISABLED_I420Rotate270_Odd) {
138
+ I420TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
139
+ benchmark_height_ + 1, benchmark_width_ + 1, kRotate270,
140
+ benchmark_iterations_, disable_cpu_flags_,
141
+ benchmark_cpu_info_);
142
+ }
143
+
144
+ static void I422TestRotate(int src_width,
145
+ int src_height,
146
+ int dst_width,
147
+ int dst_height,
148
+ libyuv::RotationMode mode,
149
+ int benchmark_iterations,
150
+ int disable_cpu_flags,
151
+ int benchmark_cpu_info) {
152
+ if (src_width < 1) {
153
+ src_width = 1;
154
+ }
155
+ if (src_height == 0) {
156
+ src_height = 1;
157
+ }
158
+ if (dst_width < 1) {
159
+ dst_width = 1;
160
+ }
161
+ if (dst_height < 1) {
162
+ dst_height = 1;
163
+ }
164
+ int src_i422_y_size = src_width * Abs(src_height);
165
+ int src_i422_uv_size = ((src_width + 1) / 2) * Abs(src_height);
166
+ int src_i422_size = src_i422_y_size + src_i422_uv_size * 2;
167
+ align_buffer_page_end(src_i422, src_i422_size);
168
+ for (int i = 0; i < src_i422_size; ++i) {
169
+ src_i422[i] = fastrand() & 0xff;
170
+ }
171
+
172
+ int dst_i422_y_size = dst_width * dst_height;
173
+ int dst_i422_uv_size = ((dst_width + 1) / 2) * dst_height;
174
+ int dst_i422_size = dst_i422_y_size + dst_i422_uv_size * 2;
175
+ align_buffer_page_end(dst_i422_c, dst_i422_size);
176
+ align_buffer_page_end(dst_i422_opt, dst_i422_size);
177
+ memset(dst_i422_c, 2, dst_i422_size);
178
+ memset(dst_i422_opt, 3, dst_i422_size);
179
+
180
+ MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
181
+ I422Rotate(src_i422, src_width, src_i422 + src_i422_y_size,
182
+ (src_width + 1) / 2, src_i422 + src_i422_y_size + src_i422_uv_size,
183
+ (src_width + 1) / 2, dst_i422_c, dst_width,
184
+ dst_i422_c + dst_i422_y_size, (dst_width + 1) / 2,
185
+ dst_i422_c + dst_i422_y_size + dst_i422_uv_size,
186
+ (dst_width + 1) / 2, src_width, src_height, mode);
187
+
188
+ MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
189
+ for (int i = 0; i < benchmark_iterations; ++i) {
190
+ I422Rotate(
191
+ src_i422, src_width, src_i422 + src_i422_y_size, (src_width + 1) / 2,
192
+ src_i422 + src_i422_y_size + src_i422_uv_size, (src_width + 1) / 2,
193
+ dst_i422_opt, dst_width, dst_i422_opt + dst_i422_y_size,
194
+ (dst_width + 1) / 2, dst_i422_opt + dst_i422_y_size + dst_i422_uv_size,
195
+ (dst_width + 1) / 2, src_width, src_height, mode);
196
+ }
197
+
198
+ // Rotation should be exact.
199
+ for (int i = 0; i < dst_i422_size; ++i) {
200
+ EXPECT_EQ(dst_i422_c[i], dst_i422_opt[i]);
201
+ }
202
+
203
+ free_aligned_buffer_page_end(dst_i422_c);
204
+ free_aligned_buffer_page_end(dst_i422_opt);
205
+ free_aligned_buffer_page_end(src_i422);
206
+ }
207
+
208
+ TEST_F(LibYUVRotateTest, I422Rotate0_Opt) {
209
+ I422TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
210
+ benchmark_height_, kRotate0, benchmark_iterations_,
211
+ disable_cpu_flags_, benchmark_cpu_info_);
212
+ }
213
+
214
+ TEST_F(LibYUVRotateTest, I422Rotate90_Opt) {
215
+ I422TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
216
+ benchmark_width_, kRotate90, benchmark_iterations_,
217
+ disable_cpu_flags_, benchmark_cpu_info_);
218
+ }
219
+
220
+ TEST_F(LibYUVRotateTest, I422Rotate180_Opt) {
221
+ I422TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
222
+ benchmark_height_, kRotate180, benchmark_iterations_,
223
+ disable_cpu_flags_, benchmark_cpu_info_);
224
+ }
225
+
226
+ TEST_F(LibYUVRotateTest, I422Rotate270_Opt) {
227
+ I422TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
228
+ benchmark_width_, kRotate270, benchmark_iterations_,
229
+ disable_cpu_flags_, benchmark_cpu_info_);
230
+ }
231
+
232
+ static void I444TestRotate(int src_width,
233
+ int src_height,
234
+ int dst_width,
235
+ int dst_height,
236
+ libyuv::RotationMode mode,
237
+ int benchmark_iterations,
238
+ int disable_cpu_flags,
239
+ int benchmark_cpu_info) {
240
+ if (src_width < 1) {
241
+ src_width = 1;
242
+ }
243
+ if (src_height == 0) {
244
+ src_height = 1;
245
+ }
246
+ if (dst_width < 1) {
247
+ dst_width = 1;
248
+ }
249
+ if (dst_height < 1) {
250
+ dst_height = 1;
251
+ }
252
+ int src_i444_y_size = src_width * Abs(src_height);
253
+ int src_i444_uv_size = src_width * Abs(src_height);
254
+ int src_i444_size = src_i444_y_size + src_i444_uv_size * 2;
255
+ align_buffer_page_end(src_i444, src_i444_size);
256
+ for (int i = 0; i < src_i444_size; ++i) {
257
+ src_i444[i] = fastrand() & 0xff;
258
+ }
259
+
260
+ int dst_i444_y_size = dst_width * dst_height;
261
+ int dst_i444_uv_size = dst_width * dst_height;
262
+ int dst_i444_size = dst_i444_y_size + dst_i444_uv_size * 2;
263
+ align_buffer_page_end(dst_i444_c, dst_i444_size);
264
+ align_buffer_page_end(dst_i444_opt, dst_i444_size);
265
+ memset(dst_i444_c, 2, dst_i444_size);
266
+ memset(dst_i444_opt, 3, dst_i444_size);
267
+
268
+ MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
269
+ I444Rotate(src_i444, src_width, src_i444 + src_i444_y_size, src_width,
270
+ src_i444 + src_i444_y_size + src_i444_uv_size, src_width,
271
+ dst_i444_c, dst_width, dst_i444_c + dst_i444_y_size, dst_width,
272
+ dst_i444_c + dst_i444_y_size + dst_i444_uv_size, dst_width,
273
+ src_width, src_height, mode);
274
+
275
+ MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
276
+ for (int i = 0; i < benchmark_iterations; ++i) {
277
+ I444Rotate(src_i444, src_width, src_i444 + src_i444_y_size, src_width,
278
+ src_i444 + src_i444_y_size + src_i444_uv_size, src_width,
279
+ dst_i444_opt, dst_width, dst_i444_opt + dst_i444_y_size,
280
+ dst_width, dst_i444_opt + dst_i444_y_size + dst_i444_uv_size,
281
+ dst_width, src_width, src_height, mode);
282
+ }
283
+
284
+ // Rotation should be exact.
285
+ for (int i = 0; i < dst_i444_size; ++i) {
286
+ EXPECT_EQ(dst_i444_c[i], dst_i444_opt[i]);
287
+ }
288
+
289
+ free_aligned_buffer_page_end(dst_i444_c);
290
+ free_aligned_buffer_page_end(dst_i444_opt);
291
+ free_aligned_buffer_page_end(src_i444);
292
+ }
293
+
294
+ TEST_F(LibYUVRotateTest, I444Rotate0_Opt) {
295
+ I444TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
296
+ benchmark_height_, kRotate0, benchmark_iterations_,
297
+ disable_cpu_flags_, benchmark_cpu_info_);
298
+ }
299
+
300
+ TEST_F(LibYUVRotateTest, I444Rotate90_Opt) {
301
+ I444TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
302
+ benchmark_width_, kRotate90, benchmark_iterations_,
303
+ disable_cpu_flags_, benchmark_cpu_info_);
304
+ }
305
+
306
+ TEST_F(LibYUVRotateTest, I444Rotate180_Opt) {
307
+ I444TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
308
+ benchmark_height_, kRotate180, benchmark_iterations_,
309
+ disable_cpu_flags_, benchmark_cpu_info_);
310
+ }
311
+
312
+ TEST_F(LibYUVRotateTest, I444Rotate270_Opt) {
313
+ I444TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
314
+ benchmark_width_, kRotate270, benchmark_iterations_,
315
+ disable_cpu_flags_, benchmark_cpu_info_);
316
+ }
317
+
318
+ // TODO(fbarchard): Remove odd width tests.
319
+ // Odd width tests work but disabled because they use C code and can be
320
+ // tested by passing an odd width command line or environment variable.
321
+ TEST_F(LibYUVRotateTest, DISABLED_I444Rotate0_Odd) {
322
+ I444TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
323
+ benchmark_width_ + 1, benchmark_height_ + 1, kRotate0,
324
+ benchmark_iterations_, disable_cpu_flags_,
325
+ benchmark_cpu_info_);
326
+ }
327
+
328
+ TEST_F(LibYUVRotateTest, DISABLED_I444Rotate90_Odd) {
329
+ I444TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
330
+ benchmark_height_ + 1, benchmark_width_ + 1, kRotate90,
331
+ benchmark_iterations_, disable_cpu_flags_,
332
+ benchmark_cpu_info_);
333
+ }
334
+
335
+ TEST_F(LibYUVRotateTest, DISABLED_I444Rotate180_Odd) {
336
+ I444TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
337
+ benchmark_width_ + 1, benchmark_height_ + 1, kRotate180,
338
+ benchmark_iterations_, disable_cpu_flags_,
339
+ benchmark_cpu_info_);
340
+ }
341
+
342
+ TEST_F(LibYUVRotateTest, DISABLED_I444Rotate270_Odd) {
343
+ I444TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
344
+ benchmark_height_ + 1, benchmark_width_ + 1, kRotate270,
345
+ benchmark_iterations_, disable_cpu_flags_,
346
+ benchmark_cpu_info_);
347
+ }
348
+
349
+ static void NV12TestRotate(int src_width,
350
+ int src_height,
351
+ int dst_width,
352
+ int dst_height,
353
+ libyuv::RotationMode mode,
354
+ int benchmark_iterations,
355
+ int disable_cpu_flags,
356
+ int benchmark_cpu_info) {
357
+ if (src_width < 1) {
358
+ src_width = 1;
359
+ }
360
+ if (src_height == 0) { // allow negative for inversion test.
361
+ src_height = 1;
362
+ }
363
+ if (dst_width < 1) {
364
+ dst_width = 1;
365
+ }
366
+ if (dst_height < 1) {
367
+ dst_height = 1;
368
+ }
369
+ int src_nv12_y_size = src_width * Abs(src_height);
370
+ int src_nv12_uv_size =
371
+ ((src_width + 1) / 2) * ((Abs(src_height) + 1) / 2) * 2;
372
+ int src_nv12_size = src_nv12_y_size + src_nv12_uv_size;
373
+ align_buffer_page_end(src_nv12, src_nv12_size);
374
+ for (int i = 0; i < src_nv12_size; ++i) {
375
+ src_nv12[i] = fastrand() & 0xff;
376
+ }
377
+
378
+ int dst_i420_y_size = dst_width * dst_height;
379
+ int dst_i420_uv_size = ((dst_width + 1) / 2) * ((dst_height + 1) / 2);
380
+ int dst_i420_size = dst_i420_y_size + dst_i420_uv_size * 2;
381
+ align_buffer_page_end(dst_i420_c, dst_i420_size);
382
+ align_buffer_page_end(dst_i420_opt, dst_i420_size);
383
+ memset(dst_i420_c, 2, dst_i420_size);
384
+ memset(dst_i420_opt, 3, dst_i420_size);
385
+
386
+ MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
387
+ NV12ToI420Rotate(src_nv12, src_width, src_nv12 + src_nv12_y_size,
388
+ (src_width + 1) & ~1, dst_i420_c, dst_width,
389
+ dst_i420_c + dst_i420_y_size, (dst_width + 1) / 2,
390
+ dst_i420_c + dst_i420_y_size + dst_i420_uv_size,
391
+ (dst_width + 1) / 2, src_width, src_height, mode);
392
+
393
+ MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
394
+ for (int i = 0; i < benchmark_iterations; ++i) {
395
+ NV12ToI420Rotate(src_nv12, src_width, src_nv12 + src_nv12_y_size,
396
+ (src_width + 1) & ~1, dst_i420_opt, dst_width,
397
+ dst_i420_opt + dst_i420_y_size, (dst_width + 1) / 2,
398
+ dst_i420_opt + dst_i420_y_size + dst_i420_uv_size,
399
+ (dst_width + 1) / 2, src_width, src_height, mode);
400
+ }
401
+
402
+ // Rotation should be exact.
403
+ for (int i = 0; i < dst_i420_size; ++i) {
404
+ EXPECT_EQ(dst_i420_c[i], dst_i420_opt[i]);
405
+ }
406
+
407
+ free_aligned_buffer_page_end(dst_i420_c);
408
+ free_aligned_buffer_page_end(dst_i420_opt);
409
+ free_aligned_buffer_page_end(src_nv12);
410
+ }
411
+
412
+ TEST_F(LibYUVRotateTest, NV12Rotate0_Opt) {
413
+ NV12TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
414
+ benchmark_height_, kRotate0, benchmark_iterations_,
415
+ disable_cpu_flags_, benchmark_cpu_info_);
416
+ }
417
+
418
+ TEST_F(LibYUVRotateTest, NV12Rotate90_Opt) {
419
+ NV12TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
420
+ benchmark_width_, kRotate90, benchmark_iterations_,
421
+ disable_cpu_flags_, benchmark_cpu_info_);
422
+ }
423
+
424
+ TEST_F(LibYUVRotateTest, NV12Rotate180_Opt) {
425
+ NV12TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
426
+ benchmark_height_, kRotate180, benchmark_iterations_,
427
+ disable_cpu_flags_, benchmark_cpu_info_);
428
+ }
429
+
430
+ TEST_F(LibYUVRotateTest, NV12Rotate270_Opt) {
431
+ NV12TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
432
+ benchmark_width_, kRotate270, benchmark_iterations_,
433
+ disable_cpu_flags_, benchmark_cpu_info_);
434
+ }
435
+
436
+ TEST_F(LibYUVRotateTest, DISABLED_NV12Rotate0_Odd) {
437
+ NV12TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
438
+ benchmark_width_ + 1, benchmark_height_ + 1, kRotate0,
439
+ benchmark_iterations_, disable_cpu_flags_,
440
+ benchmark_cpu_info_);
441
+ }
442
+
443
+ TEST_F(LibYUVRotateTest, DISABLED_NV12Rotate90_Odd) {
444
+ NV12TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
445
+ benchmark_height_ + 1, benchmark_width_ + 1, kRotate90,
446
+ benchmark_iterations_, disable_cpu_flags_,
447
+ benchmark_cpu_info_);
448
+ }
449
+
450
+ TEST_F(LibYUVRotateTest, DISABLED_NV12Rotate180_Odd) {
451
+ NV12TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
452
+ benchmark_width_ + 1, benchmark_height_ + 1, kRotate180,
453
+ benchmark_iterations_, disable_cpu_flags_,
454
+ benchmark_cpu_info_);
455
+ }
456
+
457
+ TEST_F(LibYUVRotateTest, DISABLED_NV12Rotate270_Odd) {
458
+ NV12TestRotate(benchmark_width_ + 1, benchmark_height_ + 1,
459
+ benchmark_height_ + 1, benchmark_width_ + 1, kRotate270,
460
+ benchmark_iterations_, disable_cpu_flags_,
461
+ benchmark_cpu_info_);
462
+ }
463
+
464
+ TEST_F(LibYUVRotateTest, NV12Rotate0_Invert) {
465
+ NV12TestRotate(benchmark_width_, -benchmark_height_, benchmark_width_,
466
+ benchmark_height_, kRotate0, benchmark_iterations_,
467
+ disable_cpu_flags_, benchmark_cpu_info_);
468
+ }
469
+
470
+ TEST_F(LibYUVRotateTest, NV12Rotate90_Invert) {
471
+ NV12TestRotate(benchmark_width_, -benchmark_height_, benchmark_height_,
472
+ benchmark_width_, kRotate90, benchmark_iterations_,
473
+ disable_cpu_flags_, benchmark_cpu_info_);
474
+ }
475
+
476
+ TEST_F(LibYUVRotateTest, NV12Rotate180_Invert) {
477
+ NV12TestRotate(benchmark_width_, -benchmark_height_, benchmark_width_,
478
+ benchmark_height_, kRotate180, benchmark_iterations_,
479
+ disable_cpu_flags_, benchmark_cpu_info_);
480
+ }
481
+
482
+ TEST_F(LibYUVRotateTest, NV12Rotate270_Invert) {
483
+ NV12TestRotate(benchmark_width_, -benchmark_height_, benchmark_height_,
484
+ benchmark_width_, kRotate270, benchmark_iterations_,
485
+ disable_cpu_flags_, benchmark_cpu_info_);
486
+ }
487
+
488
+ // Test Android 420 to I420 Rotate
489
+ #define TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, \
490
+ SRC_SUBSAMP_Y, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
491
+ W1280, N, NEG, OFF, PN, OFF_U, OFF_V, ROT) \
492
+ TEST_F(LibYUVRotateTest, \
493
+ SRC_FMT_PLANAR##To##FMT_PLANAR##Rotate##ROT##To##PN##N) { \
494
+ const int kWidth = W1280; \
495
+ const int kHeight = benchmark_height_; \
496
+ const int kSizeUV = \
497
+ SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); \
498
+ align_buffer_page_end(src_y, kWidth* kHeight + OFF); \
499
+ align_buffer_page_end(src_uv, \
500
+ kSizeUV*((PIXEL_STRIDE == 3) ? 3 : 2) + OFF); \
501
+ align_buffer_page_end(dst_y_c, kWidth* kHeight); \
502
+ align_buffer_page_end(dst_u_c, SUBSAMPLE(kWidth, SUBSAMP_X) * \
503
+ SUBSAMPLE(kHeight, SUBSAMP_Y)); \
504
+ align_buffer_page_end(dst_v_c, SUBSAMPLE(kWidth, SUBSAMP_X) * \
505
+ SUBSAMPLE(kHeight, SUBSAMP_Y)); \
506
+ align_buffer_page_end(dst_y_opt, kWidth* kHeight); \
507
+ align_buffer_page_end(dst_u_opt, SUBSAMPLE(kWidth, SUBSAMP_X) * \
508
+ SUBSAMPLE(kHeight, SUBSAMP_Y)); \
509
+ align_buffer_page_end(dst_v_opt, SUBSAMPLE(kWidth, SUBSAMP_X) * \
510
+ SUBSAMPLE(kHeight, SUBSAMP_Y)); \
511
+ uint8_t* src_u = src_uv + OFF_U; \
512
+ uint8_t* src_v = src_uv + (PIXEL_STRIDE == 1 ? kSizeUV : OFF_V); \
513
+ int src_stride_uv = SUBSAMPLE(kWidth, SUBSAMP_X) * PIXEL_STRIDE; \
514
+ for (int i = 0; i < kHeight; ++i) \
515
+ for (int j = 0; j < kWidth; ++j) \
516
+ src_y[i * kWidth + j + OFF] = (fastrand() & 0xff); \
517
+ for (int i = 0; i < SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); ++i) { \
518
+ for (int j = 0; j < SUBSAMPLE(kWidth, SRC_SUBSAMP_X); ++j) { \
519
+ src_u[(i * src_stride_uv) + j * PIXEL_STRIDE + OFF] = \
520
+ (fastrand() & 0xff); \
521
+ src_v[(i * src_stride_uv) + j * PIXEL_STRIDE + OFF] = \
522
+ (fastrand() & 0xff); \
523
+ } \
524
+ } \
525
+ memset(dst_y_c, 1, kWidth* kHeight); \
526
+ memset(dst_u_c, 2, \
527
+ SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
528
+ memset(dst_v_c, 3, \
529
+ SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
530
+ memset(dst_y_opt, 101, kWidth* kHeight); \
531
+ memset(dst_u_opt, 102, \
532
+ SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
533
+ memset(dst_v_opt, 103, \
534
+ SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
535
+ MaskCpuFlags(disable_cpu_flags_); \
536
+ SRC_FMT_PLANAR##To##FMT_PLANAR##Rotate( \
537
+ src_y + OFF, kWidth, src_u + OFF, SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \
538
+ src_v + OFF, SUBSAMPLE(kWidth, SRC_SUBSAMP_X), PIXEL_STRIDE, dst_y_c, \
539
+ kWidth, dst_u_c, SUBSAMPLE(kWidth, SUBSAMP_X), dst_v_c, \
540
+ SUBSAMPLE(kWidth, SUBSAMP_X), kWidth, NEG kHeight, \
541
+ (libyuv::RotationMode)ROT); \
542
+ MaskCpuFlags(benchmark_cpu_info_); \
543
+ for (int i = 0; i < benchmark_iterations_; ++i) { \
544
+ SRC_FMT_PLANAR##To##FMT_PLANAR##Rotate( \
545
+ src_y + OFF, kWidth, src_u + OFF, SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \
546
+ src_v + OFF, SUBSAMPLE(kWidth, SRC_SUBSAMP_X), PIXEL_STRIDE, \
547
+ dst_y_opt, kWidth, dst_u_opt, SUBSAMPLE(kWidth, SUBSAMP_X), \
548
+ dst_v_opt, SUBSAMPLE(kWidth, SUBSAMP_X), kWidth, NEG kHeight, \
549
+ (libyuv::RotationMode)ROT); \
550
+ } \
551
+ for (int i = 0; i < kHeight; ++i) { \
552
+ for (int j = 0; j < kWidth; ++j) { \
553
+ EXPECT_EQ(dst_y_c[i * kWidth + j], dst_y_opt[i * kWidth + j]); \
554
+ } \
555
+ } \
556
+ for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \
557
+ for (int j = 0; j < SUBSAMPLE(kWidth, SUBSAMP_X); ++j) { \
558
+ EXPECT_EQ(dst_u_c[i * SUBSAMPLE(kWidth, SUBSAMP_X) + j], \
559
+ dst_u_opt[i * SUBSAMPLE(kWidth, SUBSAMP_X) + j]); \
560
+ } \
561
+ } \
562
+ for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \
563
+ for (int j = 0; j < SUBSAMPLE(kWidth, SUBSAMP_X); ++j) { \
564
+ EXPECT_EQ(dst_v_c[i * SUBSAMPLE(kWidth, SUBSAMP_X) + j], \
565
+ dst_v_opt[i * SUBSAMPLE(kWidth, SUBSAMP_X) + j]); \
566
+ } \
567
+ } \
568
+ free_aligned_buffer_page_end(dst_y_c); \
569
+ free_aligned_buffer_page_end(dst_u_c); \
570
+ free_aligned_buffer_page_end(dst_v_c); \
571
+ free_aligned_buffer_page_end(dst_y_opt); \
572
+ free_aligned_buffer_page_end(dst_u_opt); \
573
+ free_aligned_buffer_page_end(dst_v_opt); \
574
+ free_aligned_buffer_page_end(src_y); \
575
+ free_aligned_buffer_page_end(src_uv); \
576
+ }
577
+
578
+ #define TESTAPLANARTOP(SRC_FMT_PLANAR, PN, PIXEL_STRIDE, OFF_U, OFF_V, \
579
+ SRC_SUBSAMP_X, SRC_SUBSAMP_Y, FMT_PLANAR, SUBSAMP_X, \
580
+ SUBSAMP_Y) \
581
+ TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
582
+ FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, benchmark_width_ + 1, \
583
+ _Any, +, 0, PN, OFF_U, OFF_V, 0) \
584
+ TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
585
+ FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, benchmark_width_, \
586
+ _Unaligned, +, 2, PN, OFF_U, OFF_V, 0) \
587
+ TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
588
+ FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, benchmark_width_, _Invert, \
589
+ -, 0, PN, OFF_U, OFF_V, 0) \
590
+ TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
591
+ FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, benchmark_width_, _Opt, +, \
592
+ 0, PN, OFF_U, OFF_V, 0) \
593
+ TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
594
+ FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, benchmark_width_, _Opt, +, \
595
+ 0, PN, OFF_U, OFF_V, 180)
596
+
597
+ TESTAPLANARTOP(Android420, I420, 1, 0, 0, 2, 2, I420, 2, 2)
598
+ TESTAPLANARTOP(Android420, NV12, 2, 0, 1, 2, 2, I420, 2, 2)
599
+ TESTAPLANARTOP(Android420, NV21, 2, 1, 0, 2, 2, I420, 2, 2)
600
+ #undef TESTAPLANARTOP
601
+ #undef TESTAPLANARTOPI
602
+
603
+ static void I010TestRotate(int src_width,
604
+ int src_height,
605
+ int dst_width,
606
+ int dst_height,
607
+ libyuv::RotationMode mode,
608
+ int benchmark_iterations,
609
+ int disable_cpu_flags,
610
+ int benchmark_cpu_info) {
611
+ if (src_width < 1) {
612
+ src_width = 1;
613
+ }
614
+ if (src_height == 0) {
615
+ src_height = 1;
616
+ }
617
+ if (dst_width < 1) {
618
+ dst_width = 1;
619
+ }
620
+ if (dst_height < 1) {
621
+ dst_height = 1;
622
+ }
623
+ int src_i010_y_size = src_width * Abs(src_height);
624
+ int src_i010_uv_size = ((src_width + 1) / 2) * ((Abs(src_height) + 1) / 2);
625
+ int src_i010_size = src_i010_y_size + src_i010_uv_size * 2;
626
+ align_buffer_page_end_16(src_i010, src_i010_size);
627
+ for (int i = 0; i < src_i010_size; ++i) {
628
+ src_i010[i] = fastrand() & 0x3ff;
629
+ }
630
+
631
+ int dst_i010_y_size = dst_width * dst_height;
632
+ int dst_i010_uv_size = ((dst_width + 1) / 2) * ((dst_height + 1) / 2);
633
+ int dst_i010_size = dst_i010_y_size + dst_i010_uv_size * 2;
634
+ align_buffer_page_end_16(dst_i010_c, dst_i010_size);
635
+ align_buffer_page_end_16(dst_i010_opt, dst_i010_size);
636
+ memset(dst_i010_c, 2, dst_i010_size * 2);
637
+ memset(dst_i010_opt, 3, dst_i010_size * 2);
638
+
639
+ MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
640
+ I010Rotate(src_i010, src_width, src_i010 + src_i010_y_size,
641
+ (src_width + 1) / 2, src_i010 + src_i010_y_size + src_i010_uv_size,
642
+ (src_width + 1) / 2, dst_i010_c, dst_width,
643
+ dst_i010_c + dst_i010_y_size, (dst_width + 1) / 2,
644
+ dst_i010_c + dst_i010_y_size + dst_i010_uv_size,
645
+ (dst_width + 1) / 2, src_width, src_height, mode);
646
+
647
+ MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
648
+ for (int i = 0; i < benchmark_iterations; ++i) {
649
+ I010Rotate(
650
+ src_i010, src_width, src_i010 + src_i010_y_size, (src_width + 1) / 2,
651
+ src_i010 + src_i010_y_size + src_i010_uv_size, (src_width + 1) / 2,
652
+ dst_i010_opt, dst_width, dst_i010_opt + dst_i010_y_size,
653
+ (dst_width + 1) / 2, dst_i010_opt + dst_i010_y_size + dst_i010_uv_size,
654
+ (dst_width + 1) / 2, src_width, src_height, mode);
655
+ }
656
+
657
+ // Rotation should be exact.
658
+ for (int i = 0; i < dst_i010_size; ++i) {
659
+ EXPECT_EQ(dst_i010_c[i], dst_i010_opt[i]);
660
+ }
661
+
662
+ free_aligned_buffer_page_end_16(dst_i010_c);
663
+ free_aligned_buffer_page_end_16(dst_i010_opt);
664
+ free_aligned_buffer_page_end_16(src_i010);
665
+ }
666
+
667
+ TEST_F(LibYUVRotateTest, I010Rotate0_Opt) {
668
+ I010TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
669
+ benchmark_height_, kRotate0, benchmark_iterations_,
670
+ disable_cpu_flags_, benchmark_cpu_info_);
671
+ }
672
+
673
+ TEST_F(LibYUVRotateTest, I010Rotate90_Opt) {
674
+ I010TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
675
+ benchmark_width_, kRotate90, benchmark_iterations_,
676
+ disable_cpu_flags_, benchmark_cpu_info_);
677
+ }
678
+
679
+ TEST_F(LibYUVRotateTest, I010Rotate180_Opt) {
680
+ I010TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
681
+ benchmark_height_, kRotate180, benchmark_iterations_,
682
+ disable_cpu_flags_, benchmark_cpu_info_);
683
+ }
684
+
685
+ TEST_F(LibYUVRotateTest, I010Rotate270_Opt) {
686
+ I010TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
687
+ benchmark_width_, kRotate270, benchmark_iterations_,
688
+ disable_cpu_flags_, benchmark_cpu_info_);
689
+ }
690
+
691
+ static void I210TestRotate(int src_width,
692
+ int src_height,
693
+ int dst_width,
694
+ int dst_height,
695
+ libyuv::RotationMode mode,
696
+ int benchmark_iterations,
697
+ int disable_cpu_flags,
698
+ int benchmark_cpu_info) {
699
+ if (src_width < 1) {
700
+ src_width = 1;
701
+ }
702
+ if (src_height == 0) {
703
+ src_height = 1;
704
+ }
705
+ if (dst_width < 1) {
706
+ dst_width = 1;
707
+ }
708
+ if (dst_height < 1) {
709
+ dst_height = 1;
710
+ }
711
+ int src_i210_y_size = src_width * Abs(src_height);
712
+ int src_i210_uv_size = ((src_width + 1) / 2) * Abs(src_height);
713
+ int src_i210_size = src_i210_y_size + src_i210_uv_size * 2;
714
+ align_buffer_page_end_16(src_i210, src_i210_size);
715
+ for (int i = 0; i < src_i210_size; ++i) {
716
+ src_i210[i] = fastrand() & 0x3ff;
717
+ }
718
+
719
+ int dst_i210_y_size = dst_width * dst_height;
720
+ int dst_i210_uv_size = ((dst_width + 1) / 2) * dst_height;
721
+ int dst_i210_size = dst_i210_y_size + dst_i210_uv_size * 2;
722
+ align_buffer_page_end_16(dst_i210_c, dst_i210_size);
723
+ align_buffer_page_end_16(dst_i210_opt, dst_i210_size);
724
+ memset(dst_i210_c, 2, dst_i210_size * 2);
725
+ memset(dst_i210_opt, 3, dst_i210_size * 2);
726
+
727
+ MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
728
+ I210Rotate(src_i210, src_width, src_i210 + src_i210_y_size,
729
+ (src_width + 1) / 2, src_i210 + src_i210_y_size + src_i210_uv_size,
730
+ (src_width + 1) / 2, dst_i210_c, dst_width,
731
+ dst_i210_c + dst_i210_y_size, (dst_width + 1) / 2,
732
+ dst_i210_c + dst_i210_y_size + dst_i210_uv_size,
733
+ (dst_width + 1) / 2, src_width, src_height, mode);
734
+
735
+ MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
736
+ for (int i = 0; i < benchmark_iterations; ++i) {
737
+ I210Rotate(
738
+ src_i210, src_width, src_i210 + src_i210_y_size, (src_width + 1) / 2,
739
+ src_i210 + src_i210_y_size + src_i210_uv_size, (src_width + 1) / 2,
740
+ dst_i210_opt, dst_width, dst_i210_opt + dst_i210_y_size,
741
+ (dst_width + 1) / 2, dst_i210_opt + dst_i210_y_size + dst_i210_uv_size,
742
+ (dst_width + 1) / 2, src_width, src_height, mode);
743
+ }
744
+
745
+ // Rotation should be exact.
746
+ for (int i = 0; i < dst_i210_size; ++i) {
747
+ EXPECT_EQ(dst_i210_c[i], dst_i210_opt[i]);
748
+ }
749
+
750
+ free_aligned_buffer_page_end_16(dst_i210_c);
751
+ free_aligned_buffer_page_end_16(dst_i210_opt);
752
+ free_aligned_buffer_page_end_16(src_i210);
753
+ }
754
+
755
+ TEST_F(LibYUVRotateTest, I210Rotate0_Opt) {
756
+ I210TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
757
+ benchmark_height_, kRotate0, benchmark_iterations_,
758
+ disable_cpu_flags_, benchmark_cpu_info_);
759
+ }
760
+
761
+ TEST_F(LibYUVRotateTest, I210Rotate90_Opt) {
762
+ I210TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
763
+ benchmark_width_, kRotate90, benchmark_iterations_,
764
+ disable_cpu_flags_, benchmark_cpu_info_);
765
+ }
766
+
767
+ TEST_F(LibYUVRotateTest, I210Rotate180_Opt) {
768
+ I210TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
769
+ benchmark_height_, kRotate180, benchmark_iterations_,
770
+ disable_cpu_flags_, benchmark_cpu_info_);
771
+ }
772
+
773
+ TEST_F(LibYUVRotateTest, I210Rotate270_Opt) {
774
+ I210TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
775
+ benchmark_width_, kRotate270, benchmark_iterations_,
776
+ disable_cpu_flags_, benchmark_cpu_info_);
777
+ }
778
+
779
+ static void I410TestRotate(int src_width,
780
+ int src_height,
781
+ int dst_width,
782
+ int dst_height,
783
+ libyuv::RotationMode mode,
784
+ int benchmark_iterations,
785
+ int disable_cpu_flags,
786
+ int benchmark_cpu_info) {
787
+ if (src_width < 1) {
788
+ src_width = 1;
789
+ }
790
+ if (src_height == 0) {
791
+ src_height = 1;
792
+ }
793
+ if (dst_width < 1) {
794
+ dst_width = 1;
795
+ }
796
+ if (dst_height < 1) {
797
+ dst_height = 1;
798
+ }
799
+ int src_i410_y_size = src_width * Abs(src_height);
800
+ int src_i410_uv_size = src_width * Abs(src_height);
801
+ int src_i410_size = src_i410_y_size + src_i410_uv_size * 2;
802
+ align_buffer_page_end_16(src_i410, src_i410_size);
803
+ for (int i = 0; i < src_i410_size; ++i) {
804
+ src_i410[i] = fastrand() & 0x3ff;
805
+ }
806
+
807
+ int dst_i410_y_size = dst_width * dst_height;
808
+ int dst_i410_uv_size = dst_width * dst_height;
809
+ int dst_i410_size = dst_i410_y_size + dst_i410_uv_size * 2;
810
+ align_buffer_page_end_16(dst_i410_c, dst_i410_size);
811
+ align_buffer_page_end_16(dst_i410_opt, dst_i410_size);
812
+ memset(dst_i410_c, 2, dst_i410_size * 2);
813
+ memset(dst_i410_opt, 3, dst_i410_size * 2);
814
+
815
+ MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
816
+ I410Rotate(src_i410, src_width, src_i410 + src_i410_y_size, src_width,
817
+ src_i410 + src_i410_y_size + src_i410_uv_size, src_width,
818
+ dst_i410_c, dst_width, dst_i410_c + dst_i410_y_size, dst_width,
819
+ dst_i410_c + dst_i410_y_size + dst_i410_uv_size, dst_width,
820
+ src_width, src_height, mode);
821
+
822
+ MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
823
+ for (int i = 0; i < benchmark_iterations; ++i) {
824
+ I410Rotate(src_i410, src_width, src_i410 + src_i410_y_size, src_width,
825
+ src_i410 + src_i410_y_size + src_i410_uv_size, src_width,
826
+ dst_i410_opt, dst_width, dst_i410_opt + dst_i410_y_size,
827
+ dst_width, dst_i410_opt + dst_i410_y_size + dst_i410_uv_size,
828
+ dst_width, src_width, src_height, mode);
829
+ }
830
+
831
+ // Rotation should be exact.
832
+ for (int i = 0; i < dst_i410_size; ++i) {
833
+ EXPECT_EQ(dst_i410_c[i], dst_i410_opt[i]);
834
+ }
835
+
836
+ free_aligned_buffer_page_end_16(dst_i410_c);
837
+ free_aligned_buffer_page_end_16(dst_i410_opt);
838
+ free_aligned_buffer_page_end_16(src_i410);
839
+ }
840
+
841
+ TEST_F(LibYUVRotateTest, I410Rotate0_Opt) {
842
+ I410TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
843
+ benchmark_height_, kRotate0, benchmark_iterations_,
844
+ disable_cpu_flags_, benchmark_cpu_info_);
845
+ }
846
+
847
+ TEST_F(LibYUVRotateTest, I410Rotate90_Opt) {
848
+ I410TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
849
+ benchmark_width_, kRotate90, benchmark_iterations_,
850
+ disable_cpu_flags_, benchmark_cpu_info_);
851
+ }
852
+
853
+ TEST_F(LibYUVRotateTest, I410Rotate180_Opt) {
854
+ I410TestRotate(benchmark_width_, benchmark_height_, benchmark_width_,
855
+ benchmark_height_, kRotate180, benchmark_iterations_,
856
+ disable_cpu_flags_, benchmark_cpu_info_);
857
+ }
858
+
859
+ TEST_F(LibYUVRotateTest, I410Rotate270_Opt) {
860
+ I410TestRotate(benchmark_width_, benchmark_height_, benchmark_height_,
861
+ benchmark_width_, kRotate270, benchmark_iterations_,
862
+ disable_cpu_flags_, benchmark_cpu_info_);
863
+ }
864
+
865
+ #if defined(ENABLE_ROW_TESTS)
866
+
867
+ TEST_F(LibYUVRotateTest, Transpose4x4_Test) {
868
+ // dst width and height
869
+ const int width = 4;
870
+ const int height = 4;
871
+ int src_pixels[4][4];
872
+ int dst_pixels_c[4][4];
873
+ int dst_pixels_opt[4][4];
874
+
875
+ for (int i = 0; i < 4; ++i) {
876
+ for (int j = 0; j < 4; ++j) {
877
+ src_pixels[i][j] = i * 10 + j;
878
+ }
879
+ }
880
+ memset(dst_pixels_c, 1, width * height * 4);
881
+ memset(dst_pixels_opt, 2, width * height * 4);
882
+
883
+ Transpose4x4_32_C((const uint8_t*)src_pixels, height * 4,
884
+ (uint8_t*)dst_pixels_c, width * 4, width);
885
+
886
+ const int benchmark_iterations =
887
+ (benchmark_iterations_ * benchmark_width_ * benchmark_height_ + 15) /
888
+ (4 * 4);
889
+ for (int i = 0; i < benchmark_iterations; ++i) {
890
+ #if defined(HAS_TRANSPOSE4X4_32_NEON)
891
+ if (TestCpuFlag(kCpuHasNEON)) {
892
+ Transpose4x4_32_NEON((const uint8_t*)src_pixels, height * 4,
893
+ (uint8_t*)dst_pixels_opt, width * 4, width);
894
+ } else
895
+ #elif defined(HAS_TRANSPOSE4X4_32_SSE2)
896
+ if (TestCpuFlag(kCpuHasSSE2)) {
897
+ Transpose4x4_32_SSE2((const uint8_t*)src_pixels, height * 4,
898
+ (uint8_t*)dst_pixels_opt, width * 4, width);
899
+ } else
900
+ #endif
901
+ {
902
+ Transpose4x4_32_C((const uint8_t*)src_pixels, height * 4,
903
+ (uint8_t*)dst_pixels_opt, width * 4, width);
904
+ }
905
+ }
906
+
907
+ for (int i = 0; i < 4; ++i) {
908
+ for (int j = 0; j < 4; ++j) {
909
+ EXPECT_EQ(dst_pixels_c[i][j], src_pixels[j][i]);
910
+ EXPECT_EQ(dst_pixels_c[i][j], dst_pixels_opt[i][j]);
911
+ }
912
+ }
913
+ }
914
+
915
+ TEST_F(LibYUVRotateTest, Transpose4x4_Opt) {
916
+ // dst width and height
917
+ const int width = ((benchmark_width_ * benchmark_height_ + 3) / 4 + 3) & ~3;
918
+ const int height = 4;
919
+ align_buffer_page_end(src_pixels, height * width * 4);
920
+ align_buffer_page_end(dst_pixels_c, width * height * 4);
921
+ align_buffer_page_end(dst_pixels_opt, width * height * 4);
922
+
923
+ MemRandomize(src_pixels, height * width * 4);
924
+ memset(dst_pixels_c, 1, width * height * 4);
925
+ memset(dst_pixels_opt, 2, width * height * 4);
926
+
927
+ Transpose4x4_32_C((const uint8_t*)src_pixels, height * 4,
928
+ (uint8_t*)dst_pixels_c, width * 4, width);
929
+
930
+ for (int i = 0; i < benchmark_iterations_; ++i) {
931
+ #if defined(HAS_TRANSPOSE4X4_32_NEON)
932
+ if (TestCpuFlag(kCpuHasNEON)) {
933
+ Transpose4x4_32_NEON((const uint8_t*)src_pixels, height * 4,
934
+ (uint8_t*)dst_pixels_opt, width * 4, width);
935
+ } else
936
+ #elif defined(HAS_TRANSPOSE4X4_32_AVX2)
937
+ if (TestCpuFlag(kCpuHasAVX2)) {
938
+ Transpose4x4_32_AVX2((const uint8_t*)src_pixels, height * 4,
939
+ (uint8_t*)dst_pixels_opt, width * 4, width);
940
+ } else if (TestCpuFlag(kCpuHasSSE2)) {
941
+ Transpose4x4_32_SSE2((const uint8_t*)src_pixels, height * 4,
942
+ (uint8_t*)dst_pixels_opt, width * 4, width);
943
+ } else
944
+ #endif
945
+ {
946
+ Transpose4x4_32_C((const uint8_t*)src_pixels, height * 4,
947
+ (uint8_t*)dst_pixels_opt, width * 4, width);
948
+ }
949
+ }
950
+
951
+ for (int i = 0; i < width * height; ++i) {
952
+ EXPECT_EQ(dst_pixels_c[i], dst_pixels_opt[i]);
953
+ }
954
+
955
+ free_aligned_buffer_page_end(src_pixels);
956
+ free_aligned_buffer_page_end(dst_pixels_c);
957
+ free_aligned_buffer_page_end(dst_pixels_opt);
958
+ }
959
+
960
+ #endif // ENABLE_ROW_TESTS
961
+
962
+ } // namespace libyuv