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,2133 +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 <assert.h>
12
- #include <stdlib.h>
13
- #include <time.h>
14
-
15
- #include "libyuv/basic_types.h"
16
- #include "libyuv/compare.h"
17
- #include "libyuv/convert.h"
18
- #include "libyuv/convert_argb.h"
19
- #include "libyuv/convert_from.h"
20
- #include "libyuv/convert_from_argb.h"
21
- #include "libyuv/cpu_id.h"
22
- #ifdef HAVE_JPEG
23
- #include "libyuv/mjpeg_decoder.h"
24
- #endif
25
- #include "../unit_test/unit_test.h"
26
- #include "libyuv/planar_functions.h"
27
- #include "libyuv/rotate.h"
28
- #include "libyuv/video_common.h"
29
-
30
- #if defined(__riscv) && !defined(__clang__)
31
- #define DISABLE_SLOW_TESTS
32
- #undef ENABLE_FULL_TESTS
33
- #define LEAN_TESTS
34
- #endif
35
-
36
- // Some functions fail on big endian. Enable these tests on all cpus except
37
- // PowerPC, but they are not optimized so disabled by default.
38
- #if !defined(DISABLE_SLOW_TESTS) && !defined(__powerpc__)
39
- #define LITTLE_ENDIAN_ONLY_TEST 1
40
- #endif
41
- #if !defined(DISABLE_SLOW_TESTS) || defined(__x86_64__) || defined(__i386__)
42
- // SLOW TESTS are those that are unoptimized C code.
43
- // FULL TESTS are optimized but test many variations of the same code.
44
- #define ENABLE_FULL_TESTS
45
- #endif
46
-
47
- namespace libyuv {
48
-
49
- // Alias to copy pixels as is
50
- #define AR30ToAR30 ARGBCopy
51
- #define ABGRToABGR ARGBCopy
52
-
53
- // subsample amount uses a divide.
54
- #define SUBSAMPLE(v, a) ((((v) + (a)-1)) / (a))
55
-
56
- #define ALIGNINT(V, ALIGN) (((V) + (ALIGN)-1) / (ALIGN) * (ALIGN))
57
-
58
- // Planar test
59
-
60
- #define TESTPLANARTOPI(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, \
61
- SRC_SUBSAMP_Y, FMT_PLANAR, DST_T, DST_BPC, \
62
- DST_SUBSAMP_X, DST_SUBSAMP_Y, W1280, N, NEG, OFF, \
63
- SRC_DEPTH) \
64
- TEST_F(LibYUVConvertTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \
65
- static_assert(SRC_BPC == 1 || SRC_BPC == 2, "SRC BPC unsupported"); \
66
- static_assert(DST_BPC == 1 || DST_BPC == 2, "DST BPC unsupported"); \
67
- static_assert(SRC_SUBSAMP_X == 1 || SRC_SUBSAMP_X == 2, \
68
- "SRC_SUBSAMP_X unsupported"); \
69
- static_assert(SRC_SUBSAMP_Y == 1 || SRC_SUBSAMP_Y == 2, \
70
- "SRC_SUBSAMP_Y unsupported"); \
71
- static_assert(DST_SUBSAMP_X == 1 || DST_SUBSAMP_X == 2, \
72
- "DST_SUBSAMP_X unsupported"); \
73
- static_assert(DST_SUBSAMP_Y == 1 || DST_SUBSAMP_Y == 2, \
74
- "DST_SUBSAMP_Y unsupported"); \
75
- const int kWidth = W1280; \
76
- const int kHeight = benchmark_height_; \
77
- const int kSrcHalfWidth = SUBSAMPLE(kWidth, SRC_SUBSAMP_X); \
78
- const int kSrcHalfHeight = SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); \
79
- const int kDstHalfWidth = SUBSAMPLE(kWidth, DST_SUBSAMP_X); \
80
- const int kDstHalfHeight = SUBSAMPLE(kHeight, DST_SUBSAMP_Y); \
81
- align_buffer_page_end(src_y, kWidth* kHeight* SRC_BPC + OFF); \
82
- align_buffer_page_end(src_u, \
83
- kSrcHalfWidth* kSrcHalfHeight* SRC_BPC + OFF); \
84
- align_buffer_page_end(src_v, \
85
- kSrcHalfWidth* kSrcHalfHeight* SRC_BPC + OFF); \
86
- align_buffer_page_end(dst_y_c, kWidth* kHeight* DST_BPC); \
87
- align_buffer_page_end(dst_u_c, kDstHalfWidth* kDstHalfHeight* DST_BPC); \
88
- align_buffer_page_end(dst_v_c, kDstHalfWidth* kDstHalfHeight* DST_BPC); \
89
- align_buffer_page_end(dst_y_opt, kWidth* kHeight* DST_BPC); \
90
- align_buffer_page_end(dst_u_opt, kDstHalfWidth* kDstHalfHeight* DST_BPC); \
91
- align_buffer_page_end(dst_v_opt, kDstHalfWidth* kDstHalfHeight* DST_BPC); \
92
- MemRandomize(src_y + OFF, kWidth * kHeight * SRC_BPC); \
93
- MemRandomize(src_u + OFF, kSrcHalfWidth * kSrcHalfHeight * SRC_BPC); \
94
- MemRandomize(src_v + OFF, kSrcHalfWidth * kSrcHalfHeight * SRC_BPC); \
95
- SRC_T* src_y_p = reinterpret_cast<SRC_T*>(src_y + OFF); \
96
- SRC_T* src_u_p = reinterpret_cast<SRC_T*>(src_u + OFF); \
97
- SRC_T* src_v_p = reinterpret_cast<SRC_T*>(src_v + OFF); \
98
- for (int i = 0; i < kWidth * kHeight; ++i) { \
99
- src_y_p[i] = src_y_p[i] & ((1 << SRC_DEPTH) - 1); \
100
- } \
101
- for (int i = 0; i < kSrcHalfWidth * kSrcHalfHeight; ++i) { \
102
- src_u_p[i] = src_u_p[i] & ((1 << SRC_DEPTH) - 1); \
103
- src_v_p[i] = src_v_p[i] & ((1 << SRC_DEPTH) - 1); \
104
- } \
105
- memset(dst_y_c, 1, kWidth* kHeight* DST_BPC); \
106
- memset(dst_u_c, 2, kDstHalfWidth* kDstHalfHeight* DST_BPC); \
107
- memset(dst_v_c, 3, kDstHalfWidth* kDstHalfHeight* DST_BPC); \
108
- memset(dst_y_opt, 101, kWidth* kHeight* DST_BPC); \
109
- memset(dst_u_opt, 102, kDstHalfWidth* kDstHalfHeight* DST_BPC); \
110
- memset(dst_v_opt, 103, kDstHalfWidth* kDstHalfHeight* DST_BPC); \
111
- MaskCpuFlags(disable_cpu_flags_); \
112
- SRC_FMT_PLANAR##To##FMT_PLANAR( \
113
- src_y_p, kWidth, src_u_p, kSrcHalfWidth, src_v_p, kSrcHalfWidth, \
114
- reinterpret_cast<DST_T*>(dst_y_c), kWidth, \
115
- reinterpret_cast<DST_T*>(dst_u_c), kDstHalfWidth, \
116
- reinterpret_cast<DST_T*>(dst_v_c), kDstHalfWidth, kWidth, \
117
- NEG kHeight); \
118
- MaskCpuFlags(benchmark_cpu_info_); \
119
- for (int i = 0; i < benchmark_iterations_; ++i) { \
120
- SRC_FMT_PLANAR##To##FMT_PLANAR( \
121
- src_y_p, kWidth, src_u_p, kSrcHalfWidth, src_v_p, kSrcHalfWidth, \
122
- reinterpret_cast<DST_T*>(dst_y_opt), kWidth, \
123
- reinterpret_cast<DST_T*>(dst_u_opt), kDstHalfWidth, \
124
- reinterpret_cast<DST_T*>(dst_v_opt), kDstHalfWidth, kWidth, \
125
- NEG kHeight); \
126
- } \
127
- for (int i = 0; i < kHeight * kWidth * DST_BPC; ++i) { \
128
- EXPECT_EQ(dst_y_c[i], dst_y_opt[i]); \
129
- } \
130
- for (int i = 0; i < kDstHalfWidth * kDstHalfHeight * DST_BPC; ++i) { \
131
- EXPECT_EQ(dst_u_c[i], dst_u_opt[i]); \
132
- EXPECT_EQ(dst_v_c[i], dst_v_opt[i]); \
133
- } \
134
- free_aligned_buffer_page_end(dst_y_c); \
135
- free_aligned_buffer_page_end(dst_u_c); \
136
- free_aligned_buffer_page_end(dst_v_c); \
137
- free_aligned_buffer_page_end(dst_y_opt); \
138
- free_aligned_buffer_page_end(dst_u_opt); \
139
- free_aligned_buffer_page_end(dst_v_opt); \
140
- free_aligned_buffer_page_end(src_y); \
141
- free_aligned_buffer_page_end(src_u); \
142
- free_aligned_buffer_page_end(src_v); \
143
- }
144
-
145
- #if defined(ENABLE_FULL_TESTS)
146
- #define TESTPLANARTOP(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, \
147
- SRC_SUBSAMP_Y, FMT_PLANAR, DST_T, DST_BPC, \
148
- DST_SUBSAMP_X, DST_SUBSAMP_Y, SRC_DEPTH) \
149
- TESTPLANARTOPI(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
150
- FMT_PLANAR, DST_T, DST_BPC, DST_SUBSAMP_X, DST_SUBSAMP_Y, \
151
- benchmark_width_ + 1, _Any, +, 0, SRC_DEPTH) \
152
- TESTPLANARTOPI(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
153
- FMT_PLANAR, DST_T, DST_BPC, DST_SUBSAMP_X, DST_SUBSAMP_Y, \
154
- benchmark_width_, _Unaligned, +, 2, SRC_DEPTH) \
155
- TESTPLANARTOPI(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
156
- FMT_PLANAR, DST_T, DST_BPC, DST_SUBSAMP_X, DST_SUBSAMP_Y, \
157
- benchmark_width_, _Invert, -, 0, SRC_DEPTH) \
158
- TESTPLANARTOPI(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
159
- FMT_PLANAR, DST_T, DST_BPC, DST_SUBSAMP_X, DST_SUBSAMP_Y, \
160
- benchmark_width_, _Opt, +, 0, SRC_DEPTH)
161
- #else
162
- #define TESTPLANARTOP(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, \
163
- SRC_SUBSAMP_Y, FMT_PLANAR, DST_T, DST_BPC, \
164
- DST_SUBSAMP_X, DST_SUBSAMP_Y, SRC_DEPTH) \
165
- TESTPLANARTOPI(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
166
- FMT_PLANAR, DST_T, DST_BPC, DST_SUBSAMP_X, DST_SUBSAMP_Y, \
167
- benchmark_width_, _Opt, +, 0, SRC_DEPTH)
168
- #endif
169
-
170
- TESTPLANARTOP(I420, uint8_t, 1, 2, 2, I420, uint8_t, 1, 2, 2, 8)
171
- TESTPLANARTOP(I422, uint8_t, 1, 2, 1, I420, uint8_t, 1, 2, 2, 8)
172
- TESTPLANARTOP(I444, uint8_t, 1, 1, 1, I420, uint8_t, 1, 2, 2, 8)
173
- TESTPLANARTOP(I420, uint8_t, 1, 2, 2, I422, uint8_t, 1, 2, 1, 8)
174
- TESTPLANARTOP(I420, uint8_t, 1, 2, 2, I444, uint8_t, 1, 1, 1, 8)
175
- TESTPLANARTOP(I420, uint8_t, 1, 2, 2, I420Mirror, uint8_t, 1, 2, 2, 8)
176
- TESTPLANARTOP(I422, uint8_t, 1, 2, 1, I422, uint8_t, 1, 2, 1, 8)
177
- TESTPLANARTOP(I422, uint8_t, 1, 2, 1, I444, uint8_t, 1, 1, 1, 8)
178
- TESTPLANARTOP(I444, uint8_t, 1, 1, 1, I444, uint8_t, 1, 1, 1, 8)
179
- TESTPLANARTOP(I010, uint16_t, 2, 2, 2, I010, uint16_t, 2, 2, 2, 10)
180
- TESTPLANARTOP(I420, uint8_t, 1, 2, 2, I010, uint16_t, 2, 2, 2, 8)
181
- TESTPLANARTOP(I420, uint8_t, 1, 2, 2, I012, uint16_t, 2, 2, 2, 8)
182
- TESTPLANARTOP(H010, uint16_t, 2, 2, 2, H010, uint16_t, 2, 2, 2, 10)
183
- TESTPLANARTOP(H010, uint16_t, 2, 2, 2, H420, uint8_t, 1, 2, 2, 10)
184
- TESTPLANARTOP(H420, uint8_t, 1, 2, 2, H010, uint16_t, 2, 2, 2, 8)
185
- TESTPLANARTOP(H420, uint8_t, 1, 2, 2, H012, uint16_t, 2, 2, 2, 8)
186
- TESTPLANARTOP(J420, uint8_t, 1, 2, 2, I420, uint8_t, 1, 2, 2, 8)
187
- TESTPLANARTOP(I010, uint16_t, 2, 2, 2, I410, uint16_t, 2, 1, 1, 10)
188
- TESTPLANARTOP(I210, uint16_t, 2, 2, 1, I410, uint16_t, 2, 1, 1, 10)
189
- TESTPLANARTOP(I012, uint16_t, 2, 2, 2, I412, uint16_t, 2, 1, 1, 12)
190
- TESTPLANARTOP(I212, uint16_t, 2, 2, 1, I412, uint16_t, 2, 1, 1, 12)
191
- TESTPLANARTOP(I410, uint16_t, 2, 1, 1, I010, uint16_t, 2, 2, 2, 10)
192
- TESTPLANARTOP(I210, uint16_t, 2, 2, 1, I010, uint16_t, 2, 2, 2, 10)
193
- TESTPLANARTOP(I412, uint16_t, 2, 1, 1, I012, uint16_t, 2, 2, 2, 12)
194
- TESTPLANARTOP(I212, uint16_t, 2, 2, 1, I012, uint16_t, 2, 2, 2, 12)
195
- TESTPLANARTOP(I010, uint16_t, 2, 2, 2, I420, uint8_t, 1, 2, 2, 10)
196
- TESTPLANARTOP(I210, uint16_t, 2, 2, 1, I420, uint8_t, 1, 2, 2, 10)
197
- TESTPLANARTOP(I210, uint16_t, 2, 2, 1, I422, uint8_t, 1, 2, 1, 10)
198
- TESTPLANARTOP(I410, uint16_t, 2, 1, 1, I420, uint8_t, 1, 2, 2, 10)
199
- TESTPLANARTOP(I410, uint16_t, 2, 1, 1, I444, uint8_t, 1, 1, 1, 10)
200
- TESTPLANARTOP(I012, uint16_t, 2, 2, 2, I420, uint8_t, 1, 2, 2, 12)
201
- TESTPLANARTOP(I212, uint16_t, 2, 2, 1, I420, uint8_t, 1, 2, 2, 12)
202
- TESTPLANARTOP(I212, uint16_t, 2, 2, 1, I422, uint8_t, 1, 2, 1, 12)
203
- TESTPLANARTOP(I412, uint16_t, 2, 1, 1, I420, uint8_t, 1, 2, 2, 12)
204
- TESTPLANARTOP(I412, uint16_t, 2, 1, 1, I444, uint8_t, 1, 1, 1, 12)
205
-
206
- // Test Android 420 to I420
207
- #define TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, \
208
- SRC_SUBSAMP_Y, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
209
- W1280, N, NEG, OFF, PN, OFF_U, OFF_V) \
210
- TEST_F(LibYUVConvertTest, SRC_FMT_PLANAR##To##FMT_PLANAR##To##PN##N) { \
211
- const int kWidth = W1280; \
212
- const int kHeight = benchmark_height_; \
213
- const int kSizeUV = \
214
- SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); \
215
- align_buffer_page_end(src_y, kWidth* kHeight + OFF); \
216
- align_buffer_page_end(src_uv, \
217
- kSizeUV*((PIXEL_STRIDE == 3) ? 3 : 2) + OFF); \
218
- align_buffer_page_end(dst_y_c, kWidth* kHeight); \
219
- align_buffer_page_end(dst_u_c, SUBSAMPLE(kWidth, SUBSAMP_X) * \
220
- SUBSAMPLE(kHeight, SUBSAMP_Y)); \
221
- align_buffer_page_end(dst_v_c, SUBSAMPLE(kWidth, SUBSAMP_X) * \
222
- SUBSAMPLE(kHeight, SUBSAMP_Y)); \
223
- align_buffer_page_end(dst_y_opt, kWidth* kHeight); \
224
- align_buffer_page_end(dst_u_opt, SUBSAMPLE(kWidth, SUBSAMP_X) * \
225
- SUBSAMPLE(kHeight, SUBSAMP_Y)); \
226
- align_buffer_page_end(dst_v_opt, SUBSAMPLE(kWidth, SUBSAMP_X) * \
227
- SUBSAMPLE(kHeight, SUBSAMP_Y)); \
228
- uint8_t* src_u = src_uv + OFF_U; \
229
- uint8_t* src_v = src_uv + (PIXEL_STRIDE == 1 ? kSizeUV : OFF_V); \
230
- int src_stride_uv = SUBSAMPLE(kWidth, SUBSAMP_X) * PIXEL_STRIDE; \
231
- for (int i = 0; i < kHeight; ++i) \
232
- for (int j = 0; j < kWidth; ++j) \
233
- src_y[i * kWidth + j + OFF] = (fastrand() & 0xff); \
234
- for (int i = 0; i < SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); ++i) { \
235
- for (int j = 0; j < SUBSAMPLE(kWidth, SRC_SUBSAMP_X); ++j) { \
236
- src_u[(i * src_stride_uv) + j * PIXEL_STRIDE + OFF] = \
237
- (fastrand() & 0xff); \
238
- src_v[(i * src_stride_uv) + j * PIXEL_STRIDE + OFF] = \
239
- (fastrand() & 0xff); \
240
- } \
241
- } \
242
- memset(dst_y_c, 1, kWidth* kHeight); \
243
- memset(dst_u_c, 2, \
244
- SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
245
- memset(dst_v_c, 3, \
246
- SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
247
- memset(dst_y_opt, 101, kWidth* kHeight); \
248
- memset(dst_u_opt, 102, \
249
- SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
250
- memset(dst_v_opt, 103, \
251
- SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
252
- MaskCpuFlags(disable_cpu_flags_); \
253
- SRC_FMT_PLANAR##To##FMT_PLANAR( \
254
- src_y + OFF, kWidth, src_u + OFF, SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \
255
- src_v + OFF, SUBSAMPLE(kWidth, SRC_SUBSAMP_X), PIXEL_STRIDE, dst_y_c, \
256
- kWidth, dst_u_c, SUBSAMPLE(kWidth, SUBSAMP_X), dst_v_c, \
257
- SUBSAMPLE(kWidth, SUBSAMP_X), kWidth, NEG kHeight); \
258
- MaskCpuFlags(benchmark_cpu_info_); \
259
- for (int i = 0; i < benchmark_iterations_; ++i) { \
260
- SRC_FMT_PLANAR##To##FMT_PLANAR( \
261
- src_y + OFF, kWidth, src_u + OFF, SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \
262
- src_v + OFF, SUBSAMPLE(kWidth, SRC_SUBSAMP_X), PIXEL_STRIDE, \
263
- dst_y_opt, kWidth, dst_u_opt, SUBSAMPLE(kWidth, SUBSAMP_X), \
264
- dst_v_opt, SUBSAMPLE(kWidth, SUBSAMP_X), kWidth, NEG kHeight); \
265
- } \
266
- for (int i = 0; i < kHeight; ++i) { \
267
- for (int j = 0; j < kWidth; ++j) { \
268
- EXPECT_EQ(dst_y_c[i * kWidth + j], dst_y_opt[i * kWidth + j]); \
269
- } \
270
- } \
271
- for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \
272
- for (int j = 0; j < SUBSAMPLE(kWidth, SUBSAMP_X); ++j) { \
273
- EXPECT_EQ(dst_u_c[i * SUBSAMPLE(kWidth, SUBSAMP_X) + j], \
274
- dst_u_opt[i * SUBSAMPLE(kWidth, SUBSAMP_X) + j]); \
275
- } \
276
- } \
277
- for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \
278
- for (int j = 0; j < SUBSAMPLE(kWidth, SUBSAMP_X); ++j) { \
279
- EXPECT_EQ(dst_v_c[i * SUBSAMPLE(kWidth, SUBSAMP_X) + j], \
280
- dst_v_opt[i * SUBSAMPLE(kWidth, SUBSAMP_X) + j]); \
281
- } \
282
- } \
283
- free_aligned_buffer_page_end(dst_y_c); \
284
- free_aligned_buffer_page_end(dst_u_c); \
285
- free_aligned_buffer_page_end(dst_v_c); \
286
- free_aligned_buffer_page_end(dst_y_opt); \
287
- free_aligned_buffer_page_end(dst_u_opt); \
288
- free_aligned_buffer_page_end(dst_v_opt); \
289
- free_aligned_buffer_page_end(src_y); \
290
- free_aligned_buffer_page_end(src_uv); \
291
- }
292
-
293
- #if defined(ENABLE_FULL_TESTS)
294
- #define TESTAPLANARTOP(SRC_FMT_PLANAR, PN, PIXEL_STRIDE, OFF_U, OFF_V, \
295
- SRC_SUBSAMP_X, SRC_SUBSAMP_Y, FMT_PLANAR, SUBSAMP_X, \
296
- SUBSAMP_Y) \
297
- TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
298
- FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, benchmark_width_ + 1, \
299
- _Any, +, 0, PN, OFF_U, OFF_V) \
300
- TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
301
- FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, benchmark_width_, \
302
- _Unaligned, +, 2, PN, OFF_U, OFF_V) \
303
- TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
304
- FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, benchmark_width_, _Invert, \
305
- -, 0, PN, OFF_U, OFF_V) \
306
- TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
307
- FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, benchmark_width_, _Opt, +, \
308
- 0, PN, OFF_U, OFF_V)
309
- #else
310
- #define TESTAPLANARTOP(SRC_FMT_PLANAR, PN, PIXEL_STRIDE, OFF_U, OFF_V, \
311
- SRC_SUBSAMP_X, SRC_SUBSAMP_Y, FMT_PLANAR, SUBSAMP_X, \
312
- SUBSAMP_Y) \
313
- TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
314
- FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, benchmark_width_, _Opt, +, \
315
- 0, PN, OFF_U, OFF_V)
316
- #endif
317
-
318
- TESTAPLANARTOP(Android420, I420, 1, 0, 0, 2, 2, I420, 2, 2)
319
- TESTAPLANARTOP(Android420, NV12, 2, 0, 1, 2, 2, I420, 2, 2)
320
- TESTAPLANARTOP(Android420, NV21, 2, 1, 0, 2, 2, I420, 2, 2)
321
- #undef TESTAPLANARTOP
322
- #undef TESTAPLANARTOPI
323
-
324
- // wrapper to keep API the same
325
- static int I400ToNV21(const uint8_t* src_y,
326
- int src_stride_y,
327
- const uint8_t* /* src_u */,
328
- int /* src_stride_u */,
329
- const uint8_t* /* src_v */,
330
- int /* src_stride_v */,
331
- uint8_t* dst_y,
332
- int dst_stride_y,
333
- uint8_t* dst_vu,
334
- int dst_stride_vu,
335
- int width,
336
- int height) {
337
- return I400ToNV21(src_y, src_stride_y, dst_y, dst_stride_y, dst_vu,
338
- dst_stride_vu, width, height);
339
- }
340
-
341
- #define TESTPLANARTOBPI(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, \
342
- SRC_SUBSAMP_Y, FMT_PLANAR, DST_T, DST_BPC, \
343
- DST_SUBSAMP_X, DST_SUBSAMP_Y, W1280, N, NEG, OFF, \
344
- SRC_DEPTH) \
345
- TEST_F(LibYUVConvertTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \
346
- static_assert(SRC_BPC == 1 || SRC_BPC == 2, "SRC BPC unsupported"); \
347
- static_assert(DST_BPC == 1 || DST_BPC == 2, "DST BPC unsupported"); \
348
- static_assert(SRC_SUBSAMP_X == 1 || SRC_SUBSAMP_X == 2, \
349
- "SRC_SUBSAMP_X unsupported"); \
350
- static_assert(SRC_SUBSAMP_Y == 1 || SRC_SUBSAMP_Y == 2, \
351
- "SRC_SUBSAMP_Y unsupported"); \
352
- static_assert(DST_SUBSAMP_X == 1 || DST_SUBSAMP_X == 2, \
353
- "DST_SUBSAMP_X unsupported"); \
354
- static_assert(DST_SUBSAMP_Y == 1 || DST_SUBSAMP_Y == 2, \
355
- "DST_SUBSAMP_Y unsupported"); \
356
- const int kWidth = W1280; \
357
- const int kHeight = benchmark_height_; \
358
- const int kSrcHalfWidth = SUBSAMPLE(kWidth, SRC_SUBSAMP_X); \
359
- const int kSrcHalfHeight = SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); \
360
- const int kDstHalfWidth = SUBSAMPLE(kWidth, DST_SUBSAMP_X); \
361
- const int kDstHalfHeight = SUBSAMPLE(kHeight, DST_SUBSAMP_Y); \
362
- align_buffer_page_end(src_y, kWidth* kHeight* SRC_BPC + OFF); \
363
- align_buffer_page_end(src_u, \
364
- kSrcHalfWidth* kSrcHalfHeight* SRC_BPC + OFF); \
365
- align_buffer_page_end(src_v, \
366
- kSrcHalfWidth* kSrcHalfHeight* SRC_BPC + OFF); \
367
- align_buffer_page_end(dst_y_c, kWidth* kHeight* DST_BPC); \
368
- align_buffer_page_end(dst_uv_c, \
369
- kDstHalfWidth* kDstHalfHeight* DST_BPC * 2); \
370
- align_buffer_page_end(dst_y_opt, kWidth* kHeight* DST_BPC); \
371
- align_buffer_page_end(dst_uv_opt, \
372
- kDstHalfWidth* kDstHalfHeight* DST_BPC * 2); \
373
- MemRandomize(src_y + OFF, kWidth * kHeight * SRC_BPC); \
374
- MemRandomize(src_u + OFF, kSrcHalfWidth * kSrcHalfHeight * SRC_BPC); \
375
- MemRandomize(src_v + OFF, kSrcHalfWidth * kSrcHalfHeight * SRC_BPC); \
376
- SRC_T* src_y_p = reinterpret_cast<SRC_T*>(src_y + OFF); \
377
- SRC_T* src_u_p = reinterpret_cast<SRC_T*>(src_u + OFF); \
378
- SRC_T* src_v_p = reinterpret_cast<SRC_T*>(src_v + OFF); \
379
- for (int i = 0; i < kWidth * kHeight; ++i) { \
380
- src_y_p[i] = src_y_p[i] & ((1 << SRC_DEPTH) - 1); \
381
- } \
382
- for (int i = 0; i < kSrcHalfWidth * kSrcHalfHeight; ++i) { \
383
- src_u_p[i] = src_u_p[i] & ((1 << SRC_DEPTH) - 1); \
384
- src_v_p[i] = src_v_p[i] & ((1 << SRC_DEPTH) - 1); \
385
- } \
386
- memset(dst_y_c, 1, kWidth* kHeight* DST_BPC); \
387
- memset(dst_uv_c, 2, kDstHalfWidth* kDstHalfHeight* DST_BPC * 2); \
388
- memset(dst_y_opt, 101, kWidth* kHeight* DST_BPC); \
389
- memset(dst_uv_opt, 102, kDstHalfWidth* kDstHalfHeight* DST_BPC * 2); \
390
- MaskCpuFlags(disable_cpu_flags_); \
391
- SRC_FMT_PLANAR##To##FMT_PLANAR(src_y_p, kWidth, src_u_p, kSrcHalfWidth, \
392
- src_v_p, kSrcHalfWidth, \
393
- reinterpret_cast<DST_T*>(dst_y_c), kWidth, \
394
- reinterpret_cast<DST_T*>(dst_uv_c), \
395
- kDstHalfWidth * 2, kWidth, NEG kHeight); \
396
- MaskCpuFlags(benchmark_cpu_info_); \
397
- for (int i = 0; i < benchmark_iterations_; ++i) { \
398
- SRC_FMT_PLANAR##To##FMT_PLANAR( \
399
- src_y_p, kWidth, src_u_p, kSrcHalfWidth, src_v_p, kSrcHalfWidth, \
400
- reinterpret_cast<DST_T*>(dst_y_opt), kWidth, \
401
- reinterpret_cast<DST_T*>(dst_uv_opt), kDstHalfWidth * 2, kWidth, \
402
- NEG kHeight); \
403
- } \
404
- for (int i = 0; i < kHeight * kWidth * DST_BPC; ++i) { \
405
- EXPECT_EQ(dst_y_c[i], dst_y_opt[i]); \
406
- } \
407
- for (int i = 0; i < kDstHalfWidth * kDstHalfHeight * DST_BPC * 2; ++i) { \
408
- EXPECT_EQ(dst_uv_c[i], dst_uv_opt[i]); \
409
- } \
410
- free_aligned_buffer_page_end(dst_y_c); \
411
- free_aligned_buffer_page_end(dst_uv_c); \
412
- free_aligned_buffer_page_end(dst_y_opt); \
413
- free_aligned_buffer_page_end(dst_uv_opt); \
414
- free_aligned_buffer_page_end(src_y); \
415
- free_aligned_buffer_page_end(src_u); \
416
- free_aligned_buffer_page_end(src_v); \
417
- }
418
-
419
- #if defined(ENABLE_FULL_TESTS)
420
- #define TESTPLANARTOBP(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, \
421
- SRC_SUBSAMP_Y, FMT_PLANAR, DST_T, DST_BPC, \
422
- DST_SUBSAMP_X, DST_SUBSAMP_Y, SRC_DEPTH) \
423
- TESTPLANARTOBPI(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, \
424
- SRC_SUBSAMP_Y, FMT_PLANAR, DST_T, DST_BPC, DST_SUBSAMP_X, \
425
- DST_SUBSAMP_Y, benchmark_width_ + 1, _Any, +, 0, SRC_DEPTH) \
426
- TESTPLANARTOBPI(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, \
427
- SRC_SUBSAMP_Y, FMT_PLANAR, DST_T, DST_BPC, DST_SUBSAMP_X, \
428
- DST_SUBSAMP_Y, benchmark_width_, _Unaligned, +, 2, \
429
- SRC_DEPTH) \
430
- TESTPLANARTOBPI(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, \
431
- SRC_SUBSAMP_Y, FMT_PLANAR, DST_T, DST_BPC, DST_SUBSAMP_X, \
432
- DST_SUBSAMP_Y, benchmark_width_, _Invert, -, 0, SRC_DEPTH) \
433
- TESTPLANARTOBPI(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, \
434
- SRC_SUBSAMP_Y, FMT_PLANAR, DST_T, DST_BPC, DST_SUBSAMP_X, \
435
- DST_SUBSAMP_Y, benchmark_width_, _Opt, +, 0, SRC_DEPTH)
436
- #else
437
- #define TESTPLANARTOBP(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, \
438
- SRC_SUBSAMP_Y, FMT_PLANAR, DST_T, DST_BPC, \
439
- DST_SUBSAMP_X, DST_SUBSAMP_Y, SRC_DEPTH) \
440
- TESTPLANARTOBPI(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, \
441
- SRC_SUBSAMP_Y, FMT_PLANAR, DST_T, DST_BPC, DST_SUBSAMP_X, \
442
- DST_SUBSAMP_Y, benchmark_width_, _Opt, +, 0, SRC_DEPTH)
443
- #endif
444
-
445
- TESTPLANARTOBP(I420, uint8_t, 1, 2, 2, NV12, uint8_t, 1, 2, 2, 8)
446
- TESTPLANARTOBP(I420, uint8_t, 1, 2, 2, NV21, uint8_t, 1, 2, 2, 8)
447
- TESTPLANARTOBP(I422, uint8_t, 1, 2, 1, NV21, uint8_t, 1, 2, 2, 8)
448
- TESTPLANARTOBP(I444, uint8_t, 1, 1, 1, NV12, uint8_t, 1, 2, 2, 8)
449
- TESTPLANARTOBP(I444, uint8_t, 1, 1, 1, NV21, uint8_t, 1, 2, 2, 8)
450
- TESTPLANARTOBP(I400, uint8_t, 1, 2, 2, NV21, uint8_t, 1, 2, 2, 8)
451
- TESTPLANARTOBP(I010, uint16_t, 2, 2, 2, NV12, uint8_t, 1, 2, 2, 8)
452
- TESTPLANARTOBP(I010, uint16_t, 2, 2, 2, P010, uint16_t, 2, 2, 2, 10)
453
- TESTPLANARTOBP(I210, uint16_t, 2, 2, 1, P210, uint16_t, 2, 2, 1, 10)
454
- TESTPLANARTOBP(I012, uint16_t, 2, 2, 2, P012, uint16_t, 2, 2, 2, 12)
455
- TESTPLANARTOBP(I212, uint16_t, 2, 2, 1, P212, uint16_t, 2, 2, 1, 12)
456
-
457
- #define TESTBPTOBPI(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, \
458
- SRC_SUBSAMP_Y, FMT_PLANAR, DST_T, DST_BPC, DST_SUBSAMP_X, \
459
- DST_SUBSAMP_Y, W1280, N, NEG, OFF, DOY, SRC_DEPTH, \
460
- TILE_WIDTH, TILE_HEIGHT) \
461
- TEST_F(LibYUVConvertTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \
462
- static_assert(DST_BPC == 1 || DST_BPC == 2, "DST BPC unsupported"); \
463
- static_assert(SRC_SUBSAMP_X == 1 || SRC_SUBSAMP_X == 2, \
464
- "SRC_SUBSAMP_X unsupported"); \
465
- static_assert(SRC_SUBSAMP_Y == 1 || SRC_SUBSAMP_Y == 2, \
466
- "SRC_SUBSAMP_Y unsupported"); \
467
- static_assert(DST_SUBSAMP_X == 1 || DST_SUBSAMP_X == 2, \
468
- "DST_SUBSAMP_X unsupported"); \
469
- static_assert(DST_SUBSAMP_Y == 1 || DST_SUBSAMP_Y == 2, \
470
- "DST_SUBSAMP_Y unsupported"); \
471
- const int kWidth = W1280; \
472
- const int kHeight = benchmark_height_; \
473
- const int kSrcHalfWidth = SUBSAMPLE(kWidth, SRC_SUBSAMP_X); \
474
- const int kDstHalfWidth = SUBSAMPLE(kWidth, DST_SUBSAMP_X); \
475
- const int kDstHalfHeight = SUBSAMPLE(kHeight, DST_SUBSAMP_Y); \
476
- const int kPaddedWidth = (kWidth + (TILE_WIDTH - 1)) & ~(TILE_WIDTH - 1); \
477
- const int kPaddedHeight = \
478
- (kHeight + (TILE_HEIGHT - 1)) & ~(TILE_HEIGHT - 1); \
479
- const int kSrcHalfPaddedWidth = SUBSAMPLE(kPaddedWidth, SRC_SUBSAMP_X); \
480
- const int kSrcHalfPaddedHeight = SUBSAMPLE(kPaddedHeight, SRC_SUBSAMP_Y); \
481
- align_buffer_page_end(src_y, kPaddedWidth* kPaddedHeight* SRC_BPC + OFF); \
482
- align_buffer_page_end( \
483
- src_uv, \
484
- 2 * kSrcHalfPaddedWidth * kSrcHalfPaddedHeight * SRC_BPC + OFF); \
485
- align_buffer_page_end(dst_y_c, kWidth* kHeight* DST_BPC); \
486
- align_buffer_page_end(dst_uv_c, \
487
- 2 * kDstHalfWidth * kDstHalfHeight * DST_BPC); \
488
- align_buffer_page_end(dst_y_opt, kWidth* kHeight* DST_BPC); \
489
- align_buffer_page_end(dst_uv_opt, \
490
- 2 * kDstHalfWidth * kDstHalfHeight * DST_BPC); \
491
- SRC_T* src_y_p = reinterpret_cast<SRC_T*>(src_y + OFF); \
492
- SRC_T* src_uv_p = reinterpret_cast<SRC_T*>(src_uv + OFF); \
493
- for (int i = 0; \
494
- i < kPaddedWidth * kPaddedHeight * SRC_BPC / (int)sizeof(SRC_T); \
495
- ++i) { \
496
- src_y_p[i] = \
497
- (fastrand() & (((SRC_T)(-1)) << ((8 * SRC_BPC) - SRC_DEPTH))); \
498
- } \
499
- for (int i = 0; i < kSrcHalfPaddedWidth * kSrcHalfPaddedHeight * 2 * \
500
- SRC_BPC / (int)sizeof(SRC_T); \
501
- ++i) { \
502
- src_uv_p[i] = \
503
- (fastrand() & (((SRC_T)(-1)) << ((8 * SRC_BPC) - SRC_DEPTH))); \
504
- } \
505
- memset(dst_y_c, 1, kWidth* kHeight* DST_BPC); \
506
- memset(dst_uv_c, 2, 2 * kDstHalfWidth * kDstHalfHeight * DST_BPC); \
507
- memset(dst_y_opt, 101, kWidth* kHeight* DST_BPC); \
508
- memset(dst_uv_opt, 102, 2 * kDstHalfWidth * kDstHalfHeight * DST_BPC); \
509
- MaskCpuFlags(disable_cpu_flags_); \
510
- SRC_FMT_PLANAR##To##FMT_PLANAR( \
511
- src_y_p, kWidth* SRC_BPC / (int)sizeof(SRC_T), src_uv_p, \
512
- 2 * kSrcHalfWidth * SRC_BPC / (int)sizeof(SRC_T), \
513
- DOY ? reinterpret_cast<DST_T*>(dst_y_c) : NULL, kWidth, \
514
- reinterpret_cast<DST_T*>(dst_uv_c), 2 * kDstHalfWidth, kWidth, \
515
- NEG kHeight); \
516
- MaskCpuFlags(benchmark_cpu_info_); \
517
- for (int i = 0; i < benchmark_iterations_; ++i) { \
518
- SRC_FMT_PLANAR##To##FMT_PLANAR( \
519
- src_y_p, kWidth* SRC_BPC / (int)sizeof(SRC_T), src_uv_p, \
520
- 2 * kSrcHalfWidth * SRC_BPC / (int)sizeof(SRC_T), \
521
- DOY ? reinterpret_cast<DST_T*>(dst_y_opt) : NULL, kWidth, \
522
- reinterpret_cast<DST_T*>(dst_uv_opt), 2 * kDstHalfWidth, kWidth, \
523
- NEG kHeight); \
524
- } \
525
- if (DOY) { \
526
- for (int i = 0; i < kHeight; ++i) { \
527
- for (int j = 0; j < kWidth; ++j) { \
528
- EXPECT_EQ(dst_y_c[i * kWidth + j], dst_y_opt[i * kWidth + j]); \
529
- } \
530
- } \
531
- } \
532
- for (int i = 0; i < kDstHalfHeight; ++i) { \
533
- for (int j = 0; j < 2 * kDstHalfWidth; ++j) { \
534
- EXPECT_EQ(dst_uv_c[i * 2 * kDstHalfWidth + j], \
535
- dst_uv_opt[i * 2 * kDstHalfWidth + j]); \
536
- } \
537
- } \
538
- free_aligned_buffer_page_end(dst_y_c); \
539
- free_aligned_buffer_page_end(dst_uv_c); \
540
- free_aligned_buffer_page_end(dst_y_opt); \
541
- free_aligned_buffer_page_end(dst_uv_opt); \
542
- free_aligned_buffer_page_end(src_y); \
543
- free_aligned_buffer_page_end(src_uv); \
544
- }
545
-
546
- #if defined(ENABLE_FULL_TESTS)
547
- #define TESTBPTOBP(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, \
548
- SRC_SUBSAMP_Y, FMT_PLANAR, DST_T, DST_BPC, DST_SUBSAMP_X, \
549
- DST_SUBSAMP_Y, SRC_DEPTH, TILE_WIDTH, TILE_HEIGHT) \
550
- TESTBPTOBPI(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
551
- FMT_PLANAR, DST_T, DST_BPC, DST_SUBSAMP_X, DST_SUBSAMP_Y, \
552
- benchmark_width_ + 1, _Any, +, 0, 1, SRC_DEPTH, TILE_WIDTH, \
553
- TILE_HEIGHT) \
554
- TESTBPTOBPI(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
555
- FMT_PLANAR, DST_T, DST_BPC, DST_SUBSAMP_X, DST_SUBSAMP_Y, \
556
- benchmark_width_, _Unaligned, +, 2, 1, SRC_DEPTH, TILE_WIDTH, \
557
- TILE_HEIGHT) \
558
- TESTBPTOBPI(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
559
- FMT_PLANAR, DST_T, DST_BPC, DST_SUBSAMP_X, DST_SUBSAMP_Y, \
560
- benchmark_width_, _Invert, -, 0, 1, SRC_DEPTH, TILE_WIDTH, \
561
- TILE_HEIGHT) \
562
- TESTBPTOBPI(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
563
- FMT_PLANAR, DST_T, DST_BPC, DST_SUBSAMP_X, DST_SUBSAMP_Y, \
564
- benchmark_width_, _Opt, +, 0, 1, SRC_DEPTH, TILE_WIDTH, \
565
- TILE_HEIGHT) \
566
- TESTBPTOBPI(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
567
- FMT_PLANAR, DST_T, DST_BPC, DST_SUBSAMP_X, DST_SUBSAMP_Y, \
568
- benchmark_width_, _NullY, +, 0, 0, SRC_DEPTH, TILE_WIDTH, \
569
- TILE_HEIGHT)
570
- #else
571
- #define TESTBPTOBP(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, \
572
- SRC_SUBSAMP_Y, FMT_PLANAR, DST_T, DST_BPC, DST_SUBSAMP_X, \
573
- DST_SUBSAMP_Y, SRC_DEPTH, TILE_WIDTH, TILE_HEIGHT) \
574
- TESTBPTOBPI(SRC_FMT_PLANAR, SRC_T, SRC_BPC, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
575
- FMT_PLANAR, DST_T, DST_BPC, DST_SUBSAMP_X, DST_SUBSAMP_Y, \
576
- benchmark_width_, _NullY, +, 0, 0, SRC_DEPTH, TILE_WIDTH, \
577
- TILE_HEIGHT)
578
- #endif
579
-
580
- TESTBPTOBP(NV21, uint8_t, 1, 2, 2, NV12, uint8_t, 1, 2, 2, 8, 1, 1)
581
- TESTBPTOBP(NV12, uint8_t, 1, 2, 2, NV12Mirror, uint8_t, 1, 2, 2, 8, 1, 1)
582
- TESTBPTOBP(NV12, uint8_t, 1, 2, 2, NV24, uint8_t, 1, 1, 1, 8, 1, 1)
583
- TESTBPTOBP(NV16, uint8_t, 1, 2, 1, NV24, uint8_t, 1, 1, 1, 8, 1, 1)
584
- TESTBPTOBP(P010, uint16_t, 2, 2, 2, P410, uint16_t, 2, 1, 1, 10, 1, 1)
585
- TESTBPTOBP(P210, uint16_t, 2, 2, 1, P410, uint16_t, 2, 1, 1, 10, 1, 1)
586
- TESTBPTOBP(P012, uint16_t, 2, 2, 2, P412, uint16_t, 2, 1, 1, 10, 1, 1)
587
- TESTBPTOBP(P212, uint16_t, 2, 2, 1, P412, uint16_t, 2, 1, 1, 12, 1, 1)
588
- TESTBPTOBP(P016, uint16_t, 2, 2, 2, P416, uint16_t, 2, 1, 1, 12, 1, 1)
589
- TESTBPTOBP(P216, uint16_t, 2, 2, 1, P416, uint16_t, 2, 1, 1, 12, 1, 1)
590
- TESTBPTOBP(MM21, uint8_t, 1, 2, 2, NV12, uint8_t, 1, 2, 2, 8, 16, 32)
591
- TESTBPTOBP(MT2T, uint8_t, 10 / 8, 2, 2, P010, uint16_t, 2, 2, 2, 10, 16, 32)
592
- TESTBPTOBP(P010, uint16_t, 2, 2, 2, NV12, uint8_t, 1, 2, 2, 8, 1, 1)
593
-
594
- #define TESTATOPLANARI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
595
- W1280, N, NEG, OFF) \
596
- TEST_F(LibYUVConvertTest, FMT_A##To##FMT_PLANAR##N) { \
597
- const int kWidth = W1280; \
598
- const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \
599
- const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \
600
- const int kStride = (kStrideUV * SUBSAMP_X * 8 * BPP_A + 7) / 8; \
601
- align_buffer_page_end(src_argb, kStride* kHeight + OFF); \
602
- align_buffer_page_end(dst_y_c, kWidth* kHeight); \
603
- align_buffer_page_end(dst_uv_c, \
604
- kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
605
- align_buffer_page_end(dst_y_opt, kWidth* kHeight); \
606
- align_buffer_page_end(dst_uv_opt, \
607
- kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
608
- memset(dst_y_c, 1, kWidth* kHeight); \
609
- memset(dst_uv_c, 2, kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
610
- memset(dst_y_opt, 101, kWidth* kHeight); \
611
- memset(dst_uv_opt, 102, kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
612
- for (int i = 0; i < kHeight; ++i) \
613
- for (int j = 0; j < kStride; ++j) \
614
- src_argb[(i * kStride) + j + OFF] = (fastrand() & 0xff); \
615
- MaskCpuFlags(disable_cpu_flags_); \
616
- FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, dst_y_c, kWidth, dst_uv_c, \
617
- kStrideUV * 2, dst_uv_c + kStrideUV, kStrideUV * 2, \
618
- kWidth, NEG kHeight); \
619
- MaskCpuFlags(benchmark_cpu_info_); \
620
- for (int i = 0; i < benchmark_iterations_; ++i) { \
621
- FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, dst_y_opt, kWidth, \
622
- dst_uv_opt, kStrideUV * 2, dst_uv_opt + kStrideUV, \
623
- kStrideUV * 2, kWidth, NEG kHeight); \
624
- } \
625
- for (int i = 0; i < kHeight; ++i) { \
626
- for (int j = 0; j < kWidth; ++j) { \
627
- EXPECT_EQ(dst_y_c[i * kWidth + j], dst_y_opt[i * kWidth + j]); \
628
- } \
629
- } \
630
- for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y) * 2; ++i) { \
631
- for (int j = 0; j < kStrideUV; ++j) { \
632
- EXPECT_EQ(dst_uv_c[i * kStrideUV + j], dst_uv_opt[i * kStrideUV + j]); \
633
- } \
634
- } \
635
- free_aligned_buffer_page_end(dst_y_c); \
636
- free_aligned_buffer_page_end(dst_uv_c); \
637
- free_aligned_buffer_page_end(dst_y_opt); \
638
- free_aligned_buffer_page_end(dst_uv_opt); \
639
- free_aligned_buffer_page_end(src_argb); \
640
- }
641
-
642
- #if defined(ENABLE_FULL_TESTS)
643
- #define TESTATOPLANAR(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y) \
644
- TESTATOPLANARI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
645
- benchmark_width_ + 1, _Any, +, 0) \
646
- TESTATOPLANARI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
647
- benchmark_width_, _Unaligned, +, 2) \
648
- TESTATOPLANARI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
649
- benchmark_width_, _Invert, -, 0) \
650
- TESTATOPLANARI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
651
- benchmark_width_, _Opt, +, 0)
652
- #else
653
- #define TESTATOPLANAR(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y) \
654
- TESTATOPLANARI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
655
- benchmark_width_, _Opt, +, 0)
656
- #endif
657
-
658
- TESTATOPLANAR(ABGR, 4, 1, I420, 2, 2)
659
- TESTATOPLANAR(ARGB, 4, 1, I420, 2, 2)
660
- TESTATOPLANAR(ARGB, 4, 1, I422, 2, 1)
661
- TESTATOPLANAR(ARGB, 4, 1, I444, 1, 1)
662
- TESTATOPLANAR(ARGB, 4, 1, J420, 2, 2)
663
- TESTATOPLANAR(ARGB, 4, 1, J422, 2, 1)
664
- TESTATOPLANAR(ARGB, 4, 1, J444, 1, 1)
665
- TESTATOPLANAR(ABGR, 4, 1, J420, 2, 2)
666
- TESTATOPLANAR(ABGR, 4, 1, J422, 2, 1)
667
- #ifdef LITTLE_ENDIAN_ONLY_TEST
668
- TESTATOPLANAR(ARGB4444, 2, 1, I420, 2, 2)
669
- TESTATOPLANAR(RGB565, 2, 1, I420, 2, 2)
670
- TESTATOPLANAR(ARGB1555, 2, 1, I420, 2, 2)
671
- #endif
672
- TESTATOPLANAR(BGRA, 4, 1, I420, 2, 2)
673
- TESTATOPLANAR(I400, 1, 1, I420, 2, 2)
674
- TESTATOPLANAR(J400, 1, 1, J420, 2, 2)
675
- TESTATOPLANAR(RAW, 3, 1, I420, 2, 2)
676
- TESTATOPLANAR(RAW, 3, 1, I444, 1, 1)
677
- TESTATOPLANAR(RAW, 3, 1, J420, 2, 2)
678
- TESTATOPLANAR(RAW, 3, 1, J444, 1, 1)
679
- TESTATOPLANAR(RGB24, 3, 1, I420, 2, 2)
680
- TESTATOPLANAR(RGB24, 3, 1, J420, 2, 2)
681
- TESTATOPLANAR(RGBA, 4, 1, I420, 2, 2)
682
- TESTATOPLANAR(UYVY, 2, 1, I420, 2, 2)
683
- TESTATOPLANAR(UYVY, 2, 1, I422, 2, 1)
684
- TESTATOPLANAR(YUY2, 2, 1, I420, 2, 2)
685
- TESTATOPLANAR(YUY2, 2, 1, I422, 2, 1)
686
-
687
- #define TESTATOPLANARAI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, \
688
- SUBSAMP_Y, W1280, N, NEG, OFF) \
689
- TEST_F(LibYUVConvertTest, FMT_A##To##FMT_PLANAR##N) { \
690
- const int kWidth = W1280; \
691
- const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \
692
- const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \
693
- const int kStride = (kStrideUV * SUBSAMP_X * 8 * BPP_A + 7) / 8; \
694
- align_buffer_page_end(src_argb, kStride* kHeight + OFF); \
695
- align_buffer_page_end(dst_a_c, kWidth* kHeight); \
696
- align_buffer_page_end(dst_y_c, kWidth* kHeight); \
697
- align_buffer_page_end(dst_uv_c, \
698
- kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
699
- align_buffer_page_end(dst_a_opt, kWidth* kHeight); \
700
- align_buffer_page_end(dst_y_opt, kWidth* kHeight); \
701
- align_buffer_page_end(dst_uv_opt, \
702
- kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
703
- memset(dst_a_c, 1, kWidth* kHeight); \
704
- memset(dst_y_c, 2, kWidth* kHeight); \
705
- memset(dst_uv_c, 3, kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
706
- memset(dst_a_opt, 101, kWidth* kHeight); \
707
- memset(dst_y_opt, 102, kWidth* kHeight); \
708
- memset(dst_uv_opt, 103, kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
709
- for (int i = 0; i < kHeight; ++i) \
710
- for (int j = 0; j < kStride; ++j) \
711
- src_argb[(i * kStride) + j + OFF] = (fastrand() & 0xff); \
712
- MaskCpuFlags(disable_cpu_flags_); \
713
- FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, dst_y_c, kWidth, dst_uv_c, \
714
- kStrideUV * 2, dst_uv_c + kStrideUV, kStrideUV * 2, \
715
- dst_a_c, kWidth, kWidth, NEG kHeight); \
716
- MaskCpuFlags(benchmark_cpu_info_); \
717
- for (int i = 0; i < benchmark_iterations_; ++i) { \
718
- FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, dst_y_opt, kWidth, \
719
- dst_uv_opt, kStrideUV * 2, dst_uv_opt + kStrideUV, \
720
- kStrideUV * 2, dst_a_opt, kWidth, kWidth, \
721
- NEG kHeight); \
722
- } \
723
- for (int i = 0; i < kHeight; ++i) { \
724
- for (int j = 0; j < kWidth; ++j) { \
725
- EXPECT_EQ(dst_y_c[i * kWidth + j], dst_y_opt[i * kWidth + j]); \
726
- EXPECT_EQ(dst_a_c[i * kWidth + j], dst_a_opt[i * kWidth + j]); \
727
- } \
728
- } \
729
- for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y) * 2; ++i) { \
730
- for (int j = 0; j < kStrideUV; ++j) { \
731
- EXPECT_EQ(dst_uv_c[i * kStrideUV + j], dst_uv_opt[i * kStrideUV + j]); \
732
- } \
733
- } \
734
- free_aligned_buffer_page_end(dst_a_c); \
735
- free_aligned_buffer_page_end(dst_y_c); \
736
- free_aligned_buffer_page_end(dst_uv_c); \
737
- free_aligned_buffer_page_end(dst_a_opt); \
738
- free_aligned_buffer_page_end(dst_y_opt); \
739
- free_aligned_buffer_page_end(dst_uv_opt); \
740
- free_aligned_buffer_page_end(src_argb); \
741
- }
742
-
743
- #if defined(ENABLE_FULL_TESTS)
744
- #define TESTATOPLANARA(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y) \
745
- TESTATOPLANARAI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
746
- benchmark_width_ + 1, _Any, +, 0) \
747
- TESTATOPLANARAI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
748
- benchmark_width_, _Unaligned, +, 2) \
749
- TESTATOPLANARAI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
750
- benchmark_width_, _Invert, -, 0) \
751
- TESTATOPLANARAI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
752
- benchmark_width_, _Opt, +, 0)
753
- #else
754
- #define TESTATOPLANARA(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y) \
755
- TESTATOPLANARAI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
756
- benchmark_width_, _Opt, +, 0)
757
- #endif
758
-
759
- TESTATOPLANARA(ARGB, 4, 1, I420Alpha, 2, 2)
760
-
761
- #define TESTATOBPI(FMT_A, SUB_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
762
- W1280, N, NEG, OFF) \
763
- TEST_F(LibYUVConvertTest, FMT_A##To##FMT_PLANAR##N) { \
764
- const int kWidth = W1280; \
765
- const int kHeight = benchmark_height_; \
766
- const int kStride = SUBSAMPLE(kWidth, SUB_A) * BPP_A; \
767
- const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \
768
- align_buffer_page_end(src_argb, kStride* kHeight + OFF); \
769
- align_buffer_page_end(dst_y_c, kWidth* kHeight); \
770
- align_buffer_page_end(dst_uv_c, \
771
- kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
772
- align_buffer_page_end(dst_y_opt, kWidth* kHeight); \
773
- align_buffer_page_end(dst_uv_opt, \
774
- kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
775
- for (int i = 0; i < kHeight; ++i) \
776
- for (int j = 0; j < kStride; ++j) \
777
- src_argb[(i * kStride) + j + OFF] = (fastrand() & 0xff); \
778
- memset(dst_y_c, 1, kWidth* kHeight); \
779
- memset(dst_uv_c, 2, kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
780
- memset(dst_y_opt, 101, kWidth* kHeight); \
781
- memset(dst_uv_opt, 102, kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \
782
- MaskCpuFlags(disable_cpu_flags_); \
783
- FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, dst_y_c, kWidth, dst_uv_c, \
784
- kStrideUV * 2, kWidth, NEG kHeight); \
785
- MaskCpuFlags(benchmark_cpu_info_); \
786
- for (int i = 0; i < benchmark_iterations_; ++i) { \
787
- FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, dst_y_opt, kWidth, \
788
- dst_uv_opt, kStrideUV * 2, kWidth, NEG kHeight); \
789
- } \
790
- for (int i = 0; i < kHeight; ++i) { \
791
- for (int j = 0; j < kWidth; ++j) { \
792
- EXPECT_EQ(dst_y_c[i * kWidth + j], dst_y_opt[i * kWidth + j]); \
793
- } \
794
- } \
795
- for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \
796
- for (int j = 0; j < kStrideUV * 2; ++j) { \
797
- EXPECT_EQ(dst_uv_c[i * kStrideUV * 2 + j], \
798
- dst_uv_opt[i * kStrideUV * 2 + j]); \
799
- } \
800
- } \
801
- free_aligned_buffer_page_end(dst_y_c); \
802
- free_aligned_buffer_page_end(dst_uv_c); \
803
- free_aligned_buffer_page_end(dst_y_opt); \
804
- free_aligned_buffer_page_end(dst_uv_opt); \
805
- free_aligned_buffer_page_end(src_argb); \
806
- }
807
-
808
- #if defined(ENABLE_FULL_TESTS)
809
- #define TESTATOBP(FMT_A, SUB_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y) \
810
- TESTATOBPI(FMT_A, SUB_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
811
- benchmark_width_ + 1, _Any, +, 0) \
812
- TESTATOBPI(FMT_A, SUB_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
813
- benchmark_width_, _Unaligned, +, 2) \
814
- TESTATOBPI(FMT_A, SUB_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
815
- benchmark_width_, _Invert, -, 0) \
816
- TESTATOBPI(FMT_A, SUB_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
817
- benchmark_width_, _Opt, +, 0)
818
- #else
819
- #define TESTATOBP(FMT_A, SUB_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y) \
820
- TESTATOBPI(FMT_A, SUB_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
821
- benchmark_width_, _Opt, +, 0)
822
- #endif
823
-
824
- TESTATOBP(ARGB, 1, 4, NV12, 2, 2)
825
- TESTATOBP(ARGB, 1, 4, NV21, 2, 2)
826
- TESTATOBP(ABGR, 1, 4, NV12, 2, 2)
827
- TESTATOBP(ABGR, 1, 4, NV21, 2, 2)
828
- TESTATOBP(RAW, 1, 3, JNV21, 2, 2)
829
- TESTATOBP(YUY2, 2, 4, NV12, 2, 2)
830
- TESTATOBP(UYVY, 2, 4, NV12, 2, 2)
831
- TESTATOBP(AYUV, 1, 4, NV12, 2, 2)
832
- TESTATOBP(AYUV, 1, 4, NV21, 2, 2)
833
-
834
- #if !defined(LEAN_TESTS)
835
-
836
- #ifdef HAVE_JPEG
837
- TEST_F(LibYUVConvertTest, ValidateJpeg) {
838
- const int kOff = 10;
839
- const int kMinJpeg = 64;
840
- const int kImageSize = benchmark_width_ * benchmark_height_ >= kMinJpeg
841
- ? benchmark_width_ * benchmark_height_
842
- : kMinJpeg;
843
- const int kSize = kImageSize + kOff;
844
- align_buffer_page_end(orig_pixels, kSize);
845
-
846
- // No SOI or EOI. Expect fail.
847
- memset(orig_pixels, 0, kSize);
848
- EXPECT_FALSE(ValidateJpeg(orig_pixels, kSize));
849
-
850
- // Test special value that matches marker start.
851
- memset(orig_pixels, 0xff, kSize);
852
- EXPECT_FALSE(ValidateJpeg(orig_pixels, kSize));
853
-
854
- // EOI, SOI. Expect pass.
855
- orig_pixels[0] = 0xff;
856
- orig_pixels[1] = 0xd8; // SOI.
857
- orig_pixels[2] = 0xff;
858
- orig_pixels[kSize - kOff + 0] = 0xff;
859
- orig_pixels[kSize - kOff + 1] = 0xd9; // EOI.
860
- for (int times = 0; times < benchmark_iterations_; ++times) {
861
- EXPECT_TRUE(ValidateJpeg(orig_pixels, kSize));
862
- }
863
- free_aligned_buffer_page_end(orig_pixels);
864
- }
865
-
866
- TEST_F(LibYUVConvertTest, ValidateJpegLarge) {
867
- const int kOff = 10;
868
- const int kMinJpeg = 64;
869
- const int kImageSize = benchmark_width_ * benchmark_height_ >= kMinJpeg
870
- ? benchmark_width_ * benchmark_height_
871
- : kMinJpeg;
872
- const int kSize = kImageSize + kOff;
873
- const int kMultiple = 10;
874
- const int kBufSize = kImageSize * kMultiple + kOff;
875
- align_buffer_page_end(orig_pixels, kBufSize);
876
-
877
- // No SOI or EOI. Expect fail.
878
- memset(orig_pixels, 0, kBufSize);
879
- EXPECT_FALSE(ValidateJpeg(orig_pixels, kBufSize));
880
-
881
- // EOI, SOI. Expect pass.
882
- orig_pixels[0] = 0xff;
883
- orig_pixels[1] = 0xd8; // SOI.
884
- orig_pixels[2] = 0xff;
885
- orig_pixels[kSize - kOff + 0] = 0xff;
886
- orig_pixels[kSize - kOff + 1] = 0xd9; // EOI.
887
- for (int times = 0; times < benchmark_iterations_; ++times) {
888
- EXPECT_TRUE(ValidateJpeg(orig_pixels, kBufSize));
889
- }
890
- free_aligned_buffer_page_end(orig_pixels);
891
- }
892
-
893
- TEST_F(LibYUVConvertTest, InvalidateJpeg) {
894
- const int kOff = 10;
895
- const int kMinJpeg = 64;
896
- const int kImageSize = benchmark_width_ * benchmark_height_ >= kMinJpeg
897
- ? benchmark_width_ * benchmark_height_
898
- : kMinJpeg;
899
- const int kSize = kImageSize + kOff;
900
- align_buffer_page_end(orig_pixels, kSize);
901
-
902
- // NULL pointer. Expect fail.
903
- EXPECT_FALSE(ValidateJpeg(NULL, kSize));
904
-
905
- // Negative size. Expect fail.
906
- EXPECT_FALSE(ValidateJpeg(orig_pixels, -1));
907
-
908
- // Too large size. Expect fail.
909
- EXPECT_FALSE(ValidateJpeg(orig_pixels, 0xfb000000ull));
910
-
911
- // No SOI or EOI. Expect fail.
912
- memset(orig_pixels, 0, kSize);
913
- EXPECT_FALSE(ValidateJpeg(orig_pixels, kSize));
914
-
915
- // SOI but no EOI. Expect fail.
916
- orig_pixels[0] = 0xff;
917
- orig_pixels[1] = 0xd8; // SOI.
918
- orig_pixels[2] = 0xff;
919
- for (int times = 0; times < benchmark_iterations_; ++times) {
920
- EXPECT_FALSE(ValidateJpeg(orig_pixels, kSize));
921
- }
922
-
923
- // EOI but no SOI. Expect fail.
924
- orig_pixels[0] = 0;
925
- orig_pixels[1] = 0;
926
- orig_pixels[kSize - kOff + 0] = 0xff;
927
- orig_pixels[kSize - kOff + 1] = 0xd9; // EOI.
928
- EXPECT_FALSE(ValidateJpeg(orig_pixels, kSize));
929
-
930
- free_aligned_buffer_page_end(orig_pixels);
931
- }
932
-
933
- TEST_F(LibYUVConvertTest, FuzzJpeg) {
934
- // SOI but no EOI. Expect fail.
935
- for (int times = 0; times < benchmark_iterations_; ++times) {
936
- const int kSize = fastrand() % 5000 + 3;
937
- align_buffer_page_end(orig_pixels, kSize);
938
- MemRandomize(orig_pixels, kSize);
939
-
940
- // Add SOI so frame will be scanned.
941
- orig_pixels[0] = 0xff;
942
- orig_pixels[1] = 0xd8; // SOI.
943
- orig_pixels[2] = 0xff;
944
- orig_pixels[kSize - 1] = 0xff;
945
- ValidateJpeg(orig_pixels,
946
- kSize); // Failure normally expected.
947
- free_aligned_buffer_page_end(orig_pixels);
948
- }
949
- }
950
-
951
- // Test data created in GIMP. In export jpeg, disable
952
- // thumbnails etc, choose a subsampling, and use low quality
953
- // (50) to keep size small. Generated with xxd -i test.jpg
954
- // test 0 is J400
955
- static const uint8_t kTest0Jpg[] = {
956
- 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01,
957
- 0x01, 0x01, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43,
958
- 0x00, 0x10, 0x0b, 0x0c, 0x0e, 0x0c, 0x0a, 0x10, 0x0e, 0x0d, 0x0e, 0x12,
959
- 0x11, 0x10, 0x13, 0x18, 0x28, 0x1a, 0x18, 0x16, 0x16, 0x18, 0x31, 0x23,
960
- 0x25, 0x1d, 0x28, 0x3a, 0x33, 0x3d, 0x3c, 0x39, 0x33, 0x38, 0x37, 0x40,
961
- 0x48, 0x5c, 0x4e, 0x40, 0x44, 0x57, 0x45, 0x37, 0x38, 0x50, 0x6d, 0x51,
962
- 0x57, 0x5f, 0x62, 0x67, 0x68, 0x67, 0x3e, 0x4d, 0x71, 0x79, 0x70, 0x64,
963
- 0x78, 0x5c, 0x65, 0x67, 0x63, 0xff, 0xc2, 0x00, 0x0b, 0x08, 0x00, 0x10,
964
- 0x00, 0x20, 0x01, 0x01, 0x11, 0x00, 0xff, 0xc4, 0x00, 0x17, 0x00, 0x01,
965
- 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
966
- 0x00, 0x00, 0x00, 0x03, 0x04, 0x01, 0x02, 0xff, 0xda, 0x00, 0x08, 0x01,
967
- 0x01, 0x00, 0x00, 0x00, 0x01, 0x43, 0x7e, 0xa7, 0x97, 0x57, 0xff, 0xc4,
968
- 0x00, 0x1b, 0x10, 0x00, 0x03, 0x00, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00,
969
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x11, 0x00, 0x03,
970
- 0x10, 0x12, 0x13, 0xff, 0xda, 0x00, 0x08, 0x01, 0x01, 0x00, 0x01, 0x05,
971
- 0x02, 0x3b, 0xc0, 0x6f, 0x66, 0x76, 0x56, 0x23, 0x87, 0x99, 0x0d, 0x26,
972
- 0x62, 0xf6, 0xbf, 0xff, 0xc4, 0x00, 0x1e, 0x10, 0x00, 0x02, 0x01, 0x03,
973
- 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
974
- 0x00, 0x11, 0x21, 0x02, 0x12, 0x32, 0x10, 0x31, 0x71, 0x81, 0xa1, 0xff,
975
- 0xda, 0x00, 0x08, 0x01, 0x01, 0x00, 0x06, 0x3f, 0x02, 0x4b, 0xb3, 0x28,
976
- 0x32, 0xd2, 0xed, 0xf9, 0x1d, 0x3e, 0x13, 0x51, 0x73, 0x83, 0xff, 0xc4,
977
- 0x00, 0x1c, 0x10, 0x01, 0x01, 0x01, 0x00, 0x02, 0x03, 0x01, 0x00, 0x00,
978
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x11, 0x00, 0x21, 0x51,
979
- 0x31, 0x61, 0x81, 0xf0, 0xff, 0xda, 0x00, 0x08, 0x01, 0x01, 0x00, 0x01,
980
- 0x3f, 0x21, 0x65, 0x6e, 0x31, 0x86, 0x28, 0xf9, 0x30, 0xdc, 0x27, 0xdb,
981
- 0xa9, 0x01, 0xf3, 0xde, 0x02, 0xa0, 0xed, 0x1e, 0x34, 0x68, 0x23, 0xf9,
982
- 0xc6, 0x48, 0x5d, 0x7a, 0x35, 0x02, 0xf5, 0x6f, 0xff, 0xda, 0x00, 0x08,
983
- 0x01, 0x01, 0x00, 0x00, 0x00, 0x10, 0x35, 0xff, 0xc4, 0x00, 0x1f, 0x10,
984
- 0x01, 0x00, 0x02, 0x01, 0x04, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
985
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x11, 0x31, 0x41, 0x61, 0x71, 0x91,
986
- 0x21, 0x81, 0xd1, 0xb1, 0xff, 0xda, 0x00, 0x08, 0x01, 0x01, 0x00, 0x01,
987
- 0x3f, 0x10, 0x0b, 0x30, 0xe9, 0x58, 0xbe, 0x1a, 0xfd, 0x88, 0xab, 0x8b,
988
- 0x34, 0x74, 0x80, 0x4b, 0xb5, 0xd5, 0xab, 0xcd, 0x46, 0x96, 0x2e, 0xec,
989
- 0xbd, 0xaa, 0x78, 0x47, 0x5c, 0x47, 0xa7, 0x30, 0x49, 0xad, 0x88, 0x7c,
990
- 0x40, 0x74, 0x30, 0xff, 0x00, 0x23, 0x1d, 0x03, 0x0b, 0xb7, 0xd4, 0xff,
991
- 0xd9};
992
- static const size_t kTest0JpgLen = 421;
993
-
994
- // test 1 is J444
995
- static const uint8_t kTest1Jpg[] = {
996
- 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01,
997
- 0x01, 0x01, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43,
998
- 0x00, 0x10, 0x0b, 0x0c, 0x0e, 0x0c, 0x0a, 0x10, 0x0e, 0x0d, 0x0e, 0x12,
999
- 0x11, 0x10, 0x13, 0x18, 0x28, 0x1a, 0x18, 0x16, 0x16, 0x18, 0x31, 0x23,
1000
- 0x25, 0x1d, 0x28, 0x3a, 0x33, 0x3d, 0x3c, 0x39, 0x33, 0x38, 0x37, 0x40,
1001
- 0x48, 0x5c, 0x4e, 0x40, 0x44, 0x57, 0x45, 0x37, 0x38, 0x50, 0x6d, 0x51,
1002
- 0x57, 0x5f, 0x62, 0x67, 0x68, 0x67, 0x3e, 0x4d, 0x71, 0x79, 0x70, 0x64,
1003
- 0x78, 0x5c, 0x65, 0x67, 0x63, 0xff, 0xdb, 0x00, 0x43, 0x01, 0x11, 0x12,
1004
- 0x12, 0x18, 0x15, 0x18, 0x2f, 0x1a, 0x1a, 0x2f, 0x63, 0x42, 0x38, 0x42,
1005
- 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
1006
- 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
1007
- 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
1008
- 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
1009
- 0x63, 0x63, 0xff, 0xc2, 0x00, 0x11, 0x08, 0x00, 0x10, 0x00, 0x20, 0x03,
1010
- 0x01, 0x11, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xc4, 0x00,
1011
- 0x17, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1012
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x01, 0x02, 0xff, 0xc4,
1013
- 0x00, 0x16, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1014
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x03, 0xff, 0xda,
1015
- 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x10, 0x03, 0x10, 0x00, 0x00, 0x01,
1016
- 0x40, 0x8f, 0x26, 0xe8, 0xf4, 0xcc, 0xf9, 0x69, 0x2b, 0x1b, 0x2a, 0xcb,
1017
- 0xff, 0xc4, 0x00, 0x1b, 0x10, 0x00, 0x03, 0x00, 0x02, 0x03, 0x00, 0x00,
1018
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x11,
1019
- 0x00, 0x03, 0x10, 0x12, 0x13, 0xff, 0xda, 0x00, 0x08, 0x01, 0x01, 0x00,
1020
- 0x01, 0x05, 0x02, 0x3b, 0x80, 0x6f, 0x56, 0x76, 0x56, 0x23, 0x87, 0x99,
1021
- 0x0d, 0x26, 0x62, 0xf6, 0xbf, 0xff, 0xc4, 0x00, 0x19, 0x11, 0x01, 0x00,
1022
- 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1023
- 0x00, 0x00, 0x01, 0x00, 0x10, 0x11, 0x02, 0x12, 0xff, 0xda, 0x00, 0x08,
1024
- 0x01, 0x03, 0x01, 0x01, 0x3f, 0x01, 0xf1, 0x00, 0x27, 0x45, 0xbb, 0x31,
1025
- 0xaf, 0xff, 0xc4, 0x00, 0x1a, 0x11, 0x00, 0x02, 0x03, 0x01, 0x01, 0x00,
1026
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
1027
- 0x02, 0x10, 0x11, 0x41, 0x12, 0xff, 0xda, 0x00, 0x08, 0x01, 0x02, 0x01,
1028
- 0x01, 0x3f, 0x01, 0xf6, 0x4b, 0x5f, 0x48, 0xb3, 0x69, 0x63, 0x35, 0x72,
1029
- 0xbf, 0xff, 0xc4, 0x00, 0x1e, 0x10, 0x00, 0x02, 0x01, 0x03, 0x05, 0x00,
1030
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11,
1031
- 0x21, 0x02, 0x12, 0x32, 0x10, 0x31, 0x71, 0x81, 0xa1, 0xff, 0xda, 0x00,
1032
- 0x08, 0x01, 0x01, 0x00, 0x06, 0x3f, 0x02, 0x4b, 0xb3, 0x28, 0x32, 0xd2,
1033
- 0xed, 0xf9, 0x1d, 0x3e, 0x13, 0x51, 0x73, 0x83, 0xff, 0xc4, 0x00, 0x1c,
1034
- 0x10, 0x01, 0x01, 0x01, 0x00, 0x02, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00,
1035
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x11, 0x00, 0x21, 0x51, 0x31, 0x61,
1036
- 0x81, 0xf0, 0xff, 0xda, 0x00, 0x08, 0x01, 0x01, 0x00, 0x01, 0x3f, 0x21,
1037
- 0x75, 0x6e, 0x31, 0x94, 0x28, 0xf9, 0x30, 0xdc, 0x27, 0xdb, 0xa9, 0x01,
1038
- 0xf3, 0xde, 0x02, 0xa0, 0xed, 0x1e, 0x34, 0x68, 0x23, 0xf9, 0xc6, 0x48,
1039
- 0x5d, 0x7a, 0x35, 0x02, 0xf5, 0x6f, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01,
1040
- 0x00, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, 0x26, 0x61, 0xd4, 0xff,
1041
- 0xc4, 0x00, 0x1a, 0x11, 0x00, 0x03, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00,
1042
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x11, 0x21,
1043
- 0x31, 0x41, 0x51, 0xff, 0xda, 0x00, 0x08, 0x01, 0x03, 0x01, 0x01, 0x3f,
1044
- 0x10, 0x54, 0xa8, 0xbf, 0x50, 0x87, 0xb0, 0x9d, 0x8b, 0xc4, 0x6a, 0x26,
1045
- 0x6b, 0x2a, 0x9c, 0x1f, 0xff, 0xc4, 0x00, 0x18, 0x11, 0x01, 0x01, 0x01,
1046
- 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1047
- 0x00, 0x01, 0x00, 0x11, 0x21, 0x51, 0xff, 0xda, 0x00, 0x08, 0x01, 0x02,
1048
- 0x01, 0x01, 0x3f, 0x10, 0x70, 0xe1, 0x3e, 0xd1, 0x8e, 0x0d, 0xe1, 0xb5,
1049
- 0xd5, 0x91, 0x76, 0x43, 0x82, 0x45, 0x4c, 0x7b, 0x7f, 0xff, 0xc4, 0x00,
1050
- 0x1f, 0x10, 0x01, 0x00, 0x02, 0x01, 0x04, 0x03, 0x01, 0x00, 0x00, 0x00,
1051
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x11, 0x31, 0x41, 0x61,
1052
- 0x71, 0x91, 0x21, 0x81, 0xd1, 0xb1, 0xff, 0xda, 0x00, 0x08, 0x01, 0x01,
1053
- 0x00, 0x01, 0x3f, 0x10, 0x1b, 0x30, 0xe9, 0x58, 0xbe, 0x1a, 0xfd, 0x8a,
1054
- 0xeb, 0x8b, 0x34, 0x74, 0x80, 0x4b, 0xb5, 0xd5, 0xab, 0xcd, 0x46, 0x96,
1055
- 0x2e, 0xec, 0xbd, 0xaa, 0x78, 0x47, 0x5c, 0x47, 0xa7, 0x30, 0x49, 0xad,
1056
- 0x88, 0x7c, 0x40, 0x74, 0x30, 0xff, 0x00, 0x23, 0x1d, 0x03, 0x0b, 0xb7,
1057
- 0xd4, 0xff, 0xd9};
1058
- static const size_t kTest1JpgLen = 735;
1059
-
1060
- // test 2 is J420
1061
- static const uint8_t kTest2Jpg[] = {
1062
- 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01,
1063
- 0x01, 0x01, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43,
1064
- 0x00, 0x10, 0x0b, 0x0c, 0x0e, 0x0c, 0x0a, 0x10, 0x0e, 0x0d, 0x0e, 0x12,
1065
- 0x11, 0x10, 0x13, 0x18, 0x28, 0x1a, 0x18, 0x16, 0x16, 0x18, 0x31, 0x23,
1066
- 0x25, 0x1d, 0x28, 0x3a, 0x33, 0x3d, 0x3c, 0x39, 0x33, 0x38, 0x37, 0x40,
1067
- 0x48, 0x5c, 0x4e, 0x40, 0x44, 0x57, 0x45, 0x37, 0x38, 0x50, 0x6d, 0x51,
1068
- 0x57, 0x5f, 0x62, 0x67, 0x68, 0x67, 0x3e, 0x4d, 0x71, 0x79, 0x70, 0x64,
1069
- 0x78, 0x5c, 0x65, 0x67, 0x63, 0xff, 0xdb, 0x00, 0x43, 0x01, 0x11, 0x12,
1070
- 0x12, 0x18, 0x15, 0x18, 0x2f, 0x1a, 0x1a, 0x2f, 0x63, 0x42, 0x38, 0x42,
1071
- 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
1072
- 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
1073
- 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
1074
- 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
1075
- 0x63, 0x63, 0xff, 0xc2, 0x00, 0x11, 0x08, 0x00, 0x10, 0x00, 0x20, 0x03,
1076
- 0x01, 0x22, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xc4, 0x00,
1077
- 0x18, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1078
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x05, 0x01, 0x02, 0x04, 0xff,
1079
- 0xc4, 0x00, 0x16, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
1080
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x02, 0xff,
1081
- 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x10, 0x03, 0x10, 0x00, 0x00,
1082
- 0x01, 0x20, 0xe7, 0x28, 0xa3, 0x0b, 0x2e, 0x2d, 0xcf, 0xff, 0xc4, 0x00,
1083
- 0x1b, 0x10, 0x00, 0x03, 0x00, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
1084
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x11, 0x00, 0x03, 0x10,
1085
- 0x12, 0x13, 0xff, 0xda, 0x00, 0x08, 0x01, 0x01, 0x00, 0x01, 0x05, 0x02,
1086
- 0x3b, 0x80, 0x6f, 0x56, 0x76, 0x56, 0x23, 0x87, 0x99, 0x0d, 0x26, 0x62,
1087
- 0xf6, 0xbf, 0xff, 0xc4, 0x00, 0x17, 0x11, 0x01, 0x00, 0x03, 0x00, 0x00,
1088
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1089
- 0x01, 0x11, 0x21, 0xff, 0xda, 0x00, 0x08, 0x01, 0x03, 0x01, 0x01, 0x3f,
1090
- 0x01, 0xc8, 0x53, 0xff, 0xc4, 0x00, 0x16, 0x11, 0x01, 0x01, 0x01, 0x00,
1091
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1092
- 0x00, 0x11, 0x32, 0xff, 0xda, 0x00, 0x08, 0x01, 0x02, 0x01, 0x01, 0x3f,
1093
- 0x01, 0xd2, 0xc7, 0xff, 0xc4, 0x00, 0x1e, 0x10, 0x00, 0x02, 0x01, 0x03,
1094
- 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1095
- 0x00, 0x11, 0x21, 0x02, 0x12, 0x32, 0x10, 0x31, 0x71, 0x81, 0xa1, 0xff,
1096
- 0xda, 0x00, 0x08, 0x01, 0x01, 0x00, 0x06, 0x3f, 0x02, 0x4b, 0xb3, 0x28,
1097
- 0x32, 0xd2, 0xed, 0xf9, 0x1d, 0x3e, 0x13, 0x51, 0x73, 0x83, 0xff, 0xc4,
1098
- 0x00, 0x1c, 0x10, 0x01, 0x01, 0x01, 0x00, 0x02, 0x03, 0x01, 0x00, 0x00,
1099
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x11, 0x00, 0x21, 0x51,
1100
- 0x31, 0x61, 0x81, 0xf0, 0xff, 0xda, 0x00, 0x08, 0x01, 0x01, 0x00, 0x01,
1101
- 0x3f, 0x21, 0x75, 0x6e, 0x31, 0x94, 0x28, 0xf9, 0x30, 0xdc, 0x27, 0xdb,
1102
- 0xa9, 0x01, 0xf3, 0xde, 0x02, 0xa0, 0xed, 0x1e, 0x34, 0x68, 0x23, 0xf9,
1103
- 0xc6, 0x48, 0x5d, 0x7a, 0x35, 0x02, 0xf5, 0x6f, 0xff, 0xda, 0x00, 0x0c,
1104
- 0x03, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, 0x13, 0x5f,
1105
- 0xff, 0xc4, 0x00, 0x17, 0x11, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
1106
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x11,
1107
- 0x21, 0xff, 0xda, 0x00, 0x08, 0x01, 0x03, 0x01, 0x01, 0x3f, 0x10, 0x0e,
1108
- 0xa1, 0x3a, 0x76, 0xff, 0xc4, 0x00, 0x17, 0x11, 0x01, 0x01, 0x01, 0x01,
1109
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1110
- 0x01, 0x00, 0x21, 0x11, 0xff, 0xda, 0x00, 0x08, 0x01, 0x02, 0x01, 0x01,
1111
- 0x3f, 0x10, 0x57, 0x0b, 0x08, 0x70, 0xdb, 0xff, 0xc4, 0x00, 0x1f, 0x10,
1112
- 0x01, 0x00, 0x02, 0x01, 0x04, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
1113
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x11, 0x31, 0x41, 0x61, 0x71, 0x91,
1114
- 0x21, 0x81, 0xd1, 0xb1, 0xff, 0xda, 0x00, 0x08, 0x01, 0x01, 0x00, 0x01,
1115
- 0x3f, 0x10, 0x1b, 0x30, 0xe9, 0x58, 0xbe, 0x1a, 0xfd, 0x8a, 0xeb, 0x8b,
1116
- 0x34, 0x74, 0x80, 0x4b, 0xb5, 0xd5, 0xab, 0xcd, 0x46, 0x96, 0x2e, 0xec,
1117
- 0xbd, 0xaa, 0x78, 0x47, 0x5c, 0x47, 0xa7, 0x30, 0x49, 0xad, 0x88, 0x7c,
1118
- 0x40, 0x74, 0x30, 0xff, 0x00, 0x23, 0x1d, 0x03, 0x0b, 0xb7, 0xd4, 0xff,
1119
- 0xd9};
1120
- static const size_t kTest2JpgLen = 685;
1121
-
1122
- // test 3 is J422
1123
- static const uint8_t kTest3Jpg[] = {
1124
- 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01,
1125
- 0x01, 0x01, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43,
1126
- 0x00, 0x10, 0x0b, 0x0c, 0x0e, 0x0c, 0x0a, 0x10, 0x0e, 0x0d, 0x0e, 0x12,
1127
- 0x11, 0x10, 0x13, 0x18, 0x28, 0x1a, 0x18, 0x16, 0x16, 0x18, 0x31, 0x23,
1128
- 0x25, 0x1d, 0x28, 0x3a, 0x33, 0x3d, 0x3c, 0x39, 0x33, 0x38, 0x37, 0x40,
1129
- 0x48, 0x5c, 0x4e, 0x40, 0x44, 0x57, 0x45, 0x37, 0x38, 0x50, 0x6d, 0x51,
1130
- 0x57, 0x5f, 0x62, 0x67, 0x68, 0x67, 0x3e, 0x4d, 0x71, 0x79, 0x70, 0x64,
1131
- 0x78, 0x5c, 0x65, 0x67, 0x63, 0xff, 0xdb, 0x00, 0x43, 0x01, 0x11, 0x12,
1132
- 0x12, 0x18, 0x15, 0x18, 0x2f, 0x1a, 0x1a, 0x2f, 0x63, 0x42, 0x38, 0x42,
1133
- 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
1134
- 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
1135
- 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
1136
- 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
1137
- 0x63, 0x63, 0xff, 0xc2, 0x00, 0x11, 0x08, 0x00, 0x10, 0x00, 0x20, 0x03,
1138
- 0x01, 0x21, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xc4, 0x00,
1139
- 0x17, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1140
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x01, 0x02, 0xff, 0xc4,
1141
- 0x00, 0x17, 0x01, 0x00, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1142
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x00, 0xff,
1143
- 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x10, 0x03, 0x10, 0x00, 0x00,
1144
- 0x01, 0x43, 0x8d, 0x1f, 0xa2, 0xb3, 0xca, 0x1b, 0x57, 0x0f, 0xff, 0xc4,
1145
- 0x00, 0x1b, 0x10, 0x00, 0x03, 0x00, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00,
1146
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x11, 0x00, 0x03,
1147
- 0x10, 0x12, 0x13, 0xff, 0xda, 0x00, 0x08, 0x01, 0x01, 0x00, 0x01, 0x05,
1148
- 0x02, 0x3b, 0x80, 0x6f, 0x56, 0x76, 0x56, 0x23, 0x87, 0x99, 0x0d, 0x26,
1149
- 0x62, 0xf6, 0xbf, 0xff, 0xc4, 0x00, 0x19, 0x11, 0x00, 0x02, 0x03, 0x01,
1150
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1151
- 0x00, 0x01, 0x02, 0x10, 0x11, 0x21, 0xff, 0xda, 0x00, 0x08, 0x01, 0x03,
1152
- 0x01, 0x01, 0x3f, 0x01, 0x51, 0xce, 0x8c, 0x75, 0xff, 0xc4, 0x00, 0x18,
1153
- 0x11, 0x00, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1154
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x61, 0x21, 0xff, 0xda,
1155
- 0x00, 0x08, 0x01, 0x02, 0x01, 0x01, 0x3f, 0x01, 0xa6, 0xd9, 0x2f, 0x84,
1156
- 0xe8, 0xf0, 0xff, 0xc4, 0x00, 0x1e, 0x10, 0x00, 0x02, 0x01, 0x03, 0x05,
1157
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1158
- 0x11, 0x21, 0x02, 0x12, 0x32, 0x10, 0x31, 0x71, 0x81, 0xa1, 0xff, 0xda,
1159
- 0x00, 0x08, 0x01, 0x01, 0x00, 0x06, 0x3f, 0x02, 0x4b, 0xb3, 0x28, 0x32,
1160
- 0xd2, 0xed, 0xf9, 0x1d, 0x3e, 0x13, 0x51, 0x73, 0x83, 0xff, 0xc4, 0x00,
1161
- 0x1c, 0x10, 0x01, 0x01, 0x01, 0x00, 0x02, 0x03, 0x01, 0x00, 0x00, 0x00,
1162
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x11, 0x00, 0x21, 0x51, 0x31,
1163
- 0x61, 0x81, 0xf0, 0xff, 0xda, 0x00, 0x08, 0x01, 0x01, 0x00, 0x01, 0x3f,
1164
- 0x21, 0x75, 0x6e, 0x31, 0x94, 0x28, 0xf9, 0x30, 0xdc, 0x27, 0xdb, 0xa9,
1165
- 0x01, 0xf3, 0xde, 0x02, 0xa0, 0xed, 0x1e, 0x34, 0x68, 0x23, 0xf9, 0xc6,
1166
- 0x48, 0x5d, 0x7a, 0x35, 0x02, 0xf5, 0x6f, 0xff, 0xda, 0x00, 0x0c, 0x03,
1167
- 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, 0x2e, 0x45, 0xff,
1168
- 0xc4, 0x00, 0x18, 0x11, 0x00, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
1169
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x11, 0x21,
1170
- 0x31, 0xff, 0xda, 0x00, 0x08, 0x01, 0x03, 0x01, 0x01, 0x3f, 0x10, 0x53,
1171
- 0x50, 0xba, 0x54, 0xc1, 0x67, 0x4f, 0xff, 0xc4, 0x00, 0x18, 0x11, 0x00,
1172
- 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1173
- 0x00, 0x00, 0x00, 0x01, 0x11, 0x21, 0x00, 0x10, 0xff, 0xda, 0x00, 0x08,
1174
- 0x01, 0x02, 0x01, 0x01, 0x3f, 0x10, 0x18, 0x81, 0x5c, 0x04, 0x1a, 0xca,
1175
- 0x91, 0xbf, 0xff, 0xc4, 0x00, 0x1f, 0x10, 0x01, 0x00, 0x02, 0x01, 0x04,
1176
- 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
1177
- 0x00, 0x11, 0x31, 0x41, 0x61, 0x71, 0x91, 0x21, 0x81, 0xd1, 0xb1, 0xff,
1178
- 0xda, 0x00, 0x08, 0x01, 0x01, 0x00, 0x01, 0x3f, 0x10, 0x1b, 0x30, 0xe9,
1179
- 0x58, 0xbe, 0x1a, 0xfd, 0x8a, 0xeb, 0x8b, 0x34, 0x74, 0x80, 0x4b, 0xb5,
1180
- 0xd5, 0xab, 0xcd, 0x46, 0x96, 0x2e, 0xec, 0xbd, 0xaa, 0x78, 0x47, 0x5c,
1181
- 0x47, 0xa7, 0x30, 0x49, 0xad, 0x88, 0x7c, 0x40, 0x74, 0x30, 0xff, 0x00,
1182
- 0x23, 0x1d, 0x03, 0x0b, 0xb7, 0xd4, 0xff, 0xd9};
1183
- static const size_t kTest3JpgLen = 704;
1184
-
1185
- // test 4 is J422 vertical - not supported
1186
- static const uint8_t kTest4Jpg[] = {
1187
- 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01,
1188
- 0x01, 0x01, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43,
1189
- 0x00, 0x10, 0x0b, 0x0c, 0x0e, 0x0c, 0x0a, 0x10, 0x0e, 0x0d, 0x0e, 0x12,
1190
- 0x11, 0x10, 0x13, 0x18, 0x28, 0x1a, 0x18, 0x16, 0x16, 0x18, 0x31, 0x23,
1191
- 0x25, 0x1d, 0x28, 0x3a, 0x33, 0x3d, 0x3c, 0x39, 0x33, 0x38, 0x37, 0x40,
1192
- 0x48, 0x5c, 0x4e, 0x40, 0x44, 0x57, 0x45, 0x37, 0x38, 0x50, 0x6d, 0x51,
1193
- 0x57, 0x5f, 0x62, 0x67, 0x68, 0x67, 0x3e, 0x4d, 0x71, 0x79, 0x70, 0x64,
1194
- 0x78, 0x5c, 0x65, 0x67, 0x63, 0xff, 0xdb, 0x00, 0x43, 0x01, 0x11, 0x12,
1195
- 0x12, 0x18, 0x15, 0x18, 0x2f, 0x1a, 0x1a, 0x2f, 0x63, 0x42, 0x38, 0x42,
1196
- 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
1197
- 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
1198
- 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
1199
- 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
1200
- 0x63, 0x63, 0xff, 0xc2, 0x00, 0x11, 0x08, 0x00, 0x10, 0x00, 0x20, 0x03,
1201
- 0x01, 0x12, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xc4, 0x00,
1202
- 0x18, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1203
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x05, 0x01, 0x02, 0x03, 0xff,
1204
- 0xc4, 0x00, 0x16, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
1205
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0xff,
1206
- 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x10, 0x03, 0x10, 0x00, 0x00,
1207
- 0x01, 0xd2, 0x98, 0xe9, 0x03, 0x0c, 0x00, 0x46, 0x21, 0xd9, 0xff, 0xc4,
1208
- 0x00, 0x1b, 0x10, 0x00, 0x03, 0x00, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00,
1209
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x11, 0x00, 0x03,
1210
- 0x10, 0x12, 0x13, 0xff, 0xda, 0x00, 0x08, 0x01, 0x01, 0x00, 0x01, 0x05,
1211
- 0x02, 0x3b, 0x80, 0x6f, 0x56, 0x76, 0x56, 0x23, 0x87, 0x99, 0x0d, 0x26,
1212
- 0x62, 0xf6, 0xbf, 0xff, 0xc4, 0x00, 0x17, 0x11, 0x01, 0x01, 0x01, 0x01,
1213
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1214
- 0x00, 0x11, 0x01, 0x21, 0xff, 0xda, 0x00, 0x08, 0x01, 0x03, 0x01, 0x01,
1215
- 0x3f, 0x01, 0x98, 0xb1, 0xbd, 0x47, 0xff, 0xc4, 0x00, 0x18, 0x11, 0x00,
1216
- 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1217
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x12, 0x11, 0x21, 0xff, 0xda, 0x00, 0x08,
1218
- 0x01, 0x02, 0x01, 0x01, 0x3f, 0x01, 0xb6, 0x35, 0xa2, 0xe1, 0x47, 0xff,
1219
- 0xc4, 0x00, 0x1e, 0x10, 0x00, 0x02, 0x01, 0x03, 0x05, 0x00, 0x00, 0x00,
1220
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x21, 0x02,
1221
- 0x12, 0x32, 0x10, 0x31, 0x71, 0x81, 0xa1, 0xff, 0xda, 0x00, 0x08, 0x01,
1222
- 0x01, 0x00, 0x06, 0x3f, 0x02, 0x4b, 0xb3, 0x28, 0x32, 0xd2, 0xed, 0xf9,
1223
- 0x1d, 0x3e, 0x13, 0x51, 0x73, 0x83, 0xff, 0xc4, 0x00, 0x1c, 0x10, 0x01,
1224
- 0x01, 0x01, 0x00, 0x02, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1225
- 0x00, 0x00, 0x00, 0x01, 0x11, 0x00, 0x21, 0x51, 0x31, 0x61, 0x81, 0xf0,
1226
- 0xff, 0xda, 0x00, 0x08, 0x01, 0x01, 0x00, 0x01, 0x3f, 0x21, 0x75, 0x6e,
1227
- 0x31, 0x94, 0x28, 0xf9, 0x30, 0xdc, 0x27, 0xdb, 0xa9, 0x01, 0xf3, 0xde,
1228
- 0x02, 0xa0, 0xed, 0x1e, 0x34, 0x68, 0x23, 0xf9, 0xc6, 0x48, 0x5d, 0x7a,
1229
- 0x35, 0x02, 0xf5, 0x6f, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02,
1230
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, 0x24, 0xaf, 0xff, 0xc4, 0x00, 0x19,
1231
- 0x11, 0x00, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1232
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x11, 0x51, 0x21, 0x31, 0xff,
1233
- 0xda, 0x00, 0x08, 0x01, 0x03, 0x01, 0x01, 0x3f, 0x10, 0x59, 0x11, 0xca,
1234
- 0x42, 0x60, 0x9f, 0x69, 0xff, 0xc4, 0x00, 0x19, 0x11, 0x00, 0x02, 0x03,
1235
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1236
- 0x00, 0x00, 0x01, 0x11, 0x21, 0x31, 0x61, 0xff, 0xda, 0x00, 0x08, 0x01,
1237
- 0x02, 0x01, 0x01, 0x3f, 0x10, 0xb0, 0xd7, 0x27, 0x51, 0xb6, 0x41, 0xff,
1238
- 0xc4, 0x00, 0x1f, 0x10, 0x01, 0x00, 0x02, 0x01, 0x04, 0x03, 0x01, 0x00,
1239
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x11, 0x31,
1240
- 0x41, 0x61, 0x71, 0x91, 0x21, 0x81, 0xd1, 0xb1, 0xff, 0xda, 0x00, 0x08,
1241
- 0x01, 0x01, 0x00, 0x01, 0x3f, 0x10, 0x1b, 0x30, 0xe9, 0x58, 0xbe, 0x1a,
1242
- 0xfd, 0x8a, 0xeb, 0x8b, 0x34, 0x74, 0x80, 0x4b, 0xb5, 0xd5, 0xab, 0xcd,
1243
- 0x46, 0x96, 0x2e, 0xec, 0xbd, 0xaa, 0x78, 0x47, 0x5c, 0x47, 0xa7, 0x30,
1244
- 0x49, 0xad, 0x88, 0x7c, 0x40, 0x74, 0x30, 0xff, 0x00, 0x23, 0x1d, 0x03,
1245
- 0x0b, 0xb7, 0xd4, 0xff, 0xd9};
1246
- static const size_t kTest4JpgLen = 701;
1247
-
1248
- TEST_F(LibYUVConvertTest, TestMJPGSize) {
1249
- int width = 0;
1250
- int height = 0;
1251
- int ret = MJPGSize(kTest2Jpg, kTest2JpgLen, &width, &height);
1252
- EXPECT_EQ(0, ret);
1253
-
1254
- printf("test jpeg size %d x %d\n", width, height);
1255
- }
1256
-
1257
- TEST_F(LibYUVConvertTest, TestMJPGToI420) {
1258
- int width = 0;
1259
- int height = 0;
1260
- int ret = MJPGSize(kTest2Jpg, kTest2JpgLen, &width, &height);
1261
- EXPECT_EQ(0, ret);
1262
-
1263
- int half_width = (width + 1) / 2;
1264
- int half_height = (height + 1) / 2;
1265
- int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
1266
- benchmark_height_ / (width * height);
1267
- if (benchmark_iterations < 1) {
1268
- benchmark_iterations = 1;
1269
- }
1270
-
1271
- align_buffer_page_end(dst_y, width * height);
1272
- align_buffer_page_end(dst_u, half_width * half_height);
1273
- align_buffer_page_end(dst_v, half_width * half_height);
1274
- for (int times = 0; times < benchmark_iterations; ++times) {
1275
- ret = MJPGToI420(kTest2Jpg, kTest2JpgLen, dst_y, width, dst_u, half_width,
1276
- dst_v, half_width, width, height, width, height);
1277
- }
1278
- // Expect sucesss
1279
- EXPECT_EQ(0, ret);
1280
-
1281
- // Test result matches known hash value.
1282
- uint32_t dst_y_hash = HashDjb2(dst_y, width * height, 5381);
1283
- uint32_t dst_u_hash = HashDjb2(dst_u, half_width * half_height, 5381);
1284
- uint32_t dst_v_hash = HashDjb2(dst_v, half_width * half_height, 5381);
1285
- EXPECT_EQ(dst_y_hash, 2682851208u);
1286
- EXPECT_EQ(dst_u_hash, 2501859930u);
1287
- EXPECT_EQ(dst_v_hash, 2126459123u);
1288
-
1289
- free_aligned_buffer_page_end(dst_y);
1290
- free_aligned_buffer_page_end(dst_u);
1291
- free_aligned_buffer_page_end(dst_v);
1292
- }
1293
-
1294
- TEST_F(LibYUVConvertTest, TestMJPGToI420_NV21) {
1295
- int width = 0;
1296
- int height = 0;
1297
- int ret = MJPGSize(kTest2Jpg, kTest2JpgLen, &width, &height);
1298
- EXPECT_EQ(0, ret);
1299
-
1300
- int half_width = (width + 1) / 2;
1301
- int half_height = (height + 1) / 2;
1302
- int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
1303
- benchmark_height_ / (width * height);
1304
- if (benchmark_iterations < 1) {
1305
- benchmark_iterations = 1;
1306
- }
1307
-
1308
- // Convert to NV21
1309
- align_buffer_page_end(dst_y, width * height);
1310
- align_buffer_page_end(dst_vu, half_width * half_height * 2);
1311
-
1312
- for (int times = 0; times < benchmark_iterations; ++times) {
1313
- ret = MJPGToNV21(kTest2Jpg, kTest2JpgLen, dst_y, width, dst_vu,
1314
- half_width * 2, width, height, width, height);
1315
- }
1316
- // Expect sucesss
1317
- EXPECT_EQ(0, ret);
1318
-
1319
- // Convert to I420
1320
- align_buffer_page_end(dst2_y, width * height);
1321
- align_buffer_page_end(dst2_u, half_width * half_height);
1322
- align_buffer_page_end(dst2_v, half_width * half_height);
1323
- for (int times = 0; times < benchmark_iterations; ++times) {
1324
- ret = MJPGToI420(kTest2Jpg, kTest2JpgLen, dst2_y, width, dst2_u, half_width,
1325
- dst2_v, half_width, width, height, width, height);
1326
- }
1327
- // Expect sucesss
1328
- EXPECT_EQ(0, ret);
1329
-
1330
- // Convert I420 to NV21
1331
- align_buffer_page_end(dst3_y, width * height);
1332
- align_buffer_page_end(dst3_vu, half_width * half_height * 2);
1333
-
1334
- I420ToNV21(dst2_y, width, dst2_u, half_width, dst2_v, half_width, dst3_y,
1335
- width, dst3_vu, half_width * 2, width, height);
1336
-
1337
- for (int i = 0; i < width * height; ++i) {
1338
- EXPECT_EQ(dst_y[i], dst3_y[i]);
1339
- }
1340
- for (int i = 0; i < half_width * half_height * 2; ++i) {
1341
- EXPECT_EQ(dst_vu[i], dst3_vu[i]);
1342
- EXPECT_EQ(dst_vu[i], dst3_vu[i]);
1343
- }
1344
-
1345
- free_aligned_buffer_page_end(dst3_y);
1346
- free_aligned_buffer_page_end(dst3_vu);
1347
-
1348
- free_aligned_buffer_page_end(dst2_y);
1349
- free_aligned_buffer_page_end(dst2_u);
1350
- free_aligned_buffer_page_end(dst2_v);
1351
-
1352
- free_aligned_buffer_page_end(dst_y);
1353
- free_aligned_buffer_page_end(dst_vu);
1354
- }
1355
-
1356
- TEST_F(LibYUVConvertTest, TestMJPGToI420_NV12) {
1357
- int width = 0;
1358
- int height = 0;
1359
- int ret = MJPGSize(kTest2Jpg, kTest2JpgLen, &width, &height);
1360
- EXPECT_EQ(0, ret);
1361
-
1362
- int half_width = (width + 1) / 2;
1363
- int half_height = (height + 1) / 2;
1364
- int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
1365
- benchmark_height_ / (width * height);
1366
- if (benchmark_iterations < 1) {
1367
- benchmark_iterations = 1;
1368
- }
1369
-
1370
- // Convert to NV12
1371
- align_buffer_page_end(dst_y, width * height);
1372
- align_buffer_page_end(dst_uv, half_width * half_height * 2);
1373
-
1374
- for (int times = 0; times < benchmark_iterations; ++times) {
1375
- ret = MJPGToNV12(kTest2Jpg, kTest2JpgLen, dst_y, width, dst_uv,
1376
- half_width * 2, width, height, width, height);
1377
- }
1378
- // Expect sucesss
1379
- EXPECT_EQ(0, ret);
1380
-
1381
- // Convert to I420
1382
- align_buffer_page_end(dst2_y, width * height);
1383
- align_buffer_page_end(dst2_u, half_width * half_height);
1384
- align_buffer_page_end(dst2_v, half_width * half_height);
1385
- for (int times = 0; times < benchmark_iterations; ++times) {
1386
- ret = MJPGToI420(kTest2Jpg, kTest2JpgLen, dst2_y, width, dst2_u, half_width,
1387
- dst2_v, half_width, width, height, width, height);
1388
- }
1389
- // Expect sucesss
1390
- EXPECT_EQ(0, ret);
1391
-
1392
- // Convert I420 to NV12
1393
- align_buffer_page_end(dst3_y, width * height);
1394
- align_buffer_page_end(dst3_uv, half_width * half_height * 2);
1395
-
1396
- I420ToNV12(dst2_y, width, dst2_u, half_width, dst2_v, half_width, dst3_y,
1397
- width, dst3_uv, half_width * 2, width, height);
1398
-
1399
- for (int i = 0; i < width * height; ++i) {
1400
- EXPECT_EQ(dst_y[i], dst3_y[i]);
1401
- }
1402
- for (int i = 0; i < half_width * half_height * 2; ++i) {
1403
- EXPECT_EQ(dst_uv[i], dst3_uv[i]);
1404
- EXPECT_EQ(dst_uv[i], dst3_uv[i]);
1405
- }
1406
-
1407
- free_aligned_buffer_page_end(dst3_y);
1408
- free_aligned_buffer_page_end(dst3_uv);
1409
-
1410
- free_aligned_buffer_page_end(dst2_y);
1411
- free_aligned_buffer_page_end(dst2_u);
1412
- free_aligned_buffer_page_end(dst2_v);
1413
-
1414
- free_aligned_buffer_page_end(dst_y);
1415
- free_aligned_buffer_page_end(dst_uv);
1416
- }
1417
-
1418
- TEST_F(LibYUVConvertTest, TestMJPGToNV21_420) {
1419
- int width = 0;
1420
- int height = 0;
1421
- int ret = MJPGSize(kTest2Jpg, kTest2JpgLen, &width, &height);
1422
- EXPECT_EQ(0, ret);
1423
-
1424
- int half_width = (width + 1) / 2;
1425
- int half_height = (height + 1) / 2;
1426
- int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
1427
- benchmark_height_ / (width * height);
1428
- if (benchmark_iterations < 1) {
1429
- benchmark_iterations = 1;
1430
- }
1431
-
1432
- align_buffer_page_end(dst_y, width * height);
1433
- align_buffer_page_end(dst_uv, half_width * half_height * 2);
1434
- for (int times = 0; times < benchmark_iterations; ++times) {
1435
- ret = MJPGToNV21(kTest2Jpg, kTest2JpgLen, dst_y, width, dst_uv,
1436
- half_width * 2, width, height, width, height);
1437
- }
1438
- // Expect sucesss
1439
- EXPECT_EQ(0, ret);
1440
-
1441
- // Test result matches known hash value.
1442
- uint32_t dst_y_hash = HashDjb2(dst_y, width * height, 5381);
1443
- uint32_t dst_uv_hash = HashDjb2(dst_uv, half_width * half_height * 2, 5381);
1444
- EXPECT_EQ(dst_y_hash, 2682851208u);
1445
- EXPECT_EQ(dst_uv_hash, 1069662856u);
1446
-
1447
- free_aligned_buffer_page_end(dst_y);
1448
- free_aligned_buffer_page_end(dst_uv);
1449
- }
1450
-
1451
- TEST_F(LibYUVConvertTest, TestMJPGToNV12_420) {
1452
- int width = 0;
1453
- int height = 0;
1454
- int ret = MJPGSize(kTest2Jpg, kTest2JpgLen, &width, &height);
1455
- EXPECT_EQ(0, ret);
1456
-
1457
- int half_width = (width + 1) / 2;
1458
- int half_height = (height + 1) / 2;
1459
- int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
1460
- benchmark_height_ / (width * height);
1461
- if (benchmark_iterations < 1) {
1462
- benchmark_iterations = 1;
1463
- }
1464
-
1465
- align_buffer_page_end(dst_y, width * height);
1466
- align_buffer_page_end(dst_uv, half_width * half_height * 2);
1467
- for (int times = 0; times < benchmark_iterations; ++times) {
1468
- ret = MJPGToNV12(kTest2Jpg, kTest2JpgLen, dst_y, width, dst_uv,
1469
- half_width * 2, width, height, width, height);
1470
- }
1471
- // Expect sucesss
1472
- EXPECT_EQ(0, ret);
1473
-
1474
- // Test result matches known hash value. Hashes are for VU so flip the plane.
1475
- uint32_t dst_y_hash = HashDjb2(dst_y, width * height, 5381);
1476
- align_buffer_page_end(dst_vu, half_width * half_height * 2);
1477
- SwapUVPlane(dst_uv, half_width * 2, dst_vu, half_width * 2, half_width,
1478
- half_height);
1479
- uint32_t dst_vu_hash = HashDjb2(dst_vu, half_width * half_height * 2, 5381);
1480
- EXPECT_EQ(dst_y_hash, 2682851208u);
1481
- EXPECT_EQ(dst_vu_hash, 1069662856u);
1482
-
1483
- free_aligned_buffer_page_end(dst_y);
1484
- free_aligned_buffer_page_end(dst_uv);
1485
- free_aligned_buffer_page_end(dst_vu);
1486
- }
1487
-
1488
- // TODO(fbarchard): Improve test to compare against I422, not checksum
1489
- TEST_F(LibYUVConvertTest, DISABLED_TestMJPGToNV21_422) {
1490
- int width = 0;
1491
- int height = 0;
1492
- int ret = MJPGSize(kTest3Jpg, kTest3JpgLen, &width, &height);
1493
- EXPECT_EQ(0, ret);
1494
-
1495
- int half_width = (width + 1) / 2;
1496
- int half_height = (height + 1) / 2;
1497
- int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
1498
- benchmark_height_ / (width * height);
1499
- if (benchmark_iterations < 1) {
1500
- benchmark_iterations = 1;
1501
- }
1502
-
1503
- align_buffer_page_end(dst_y, width * height);
1504
- align_buffer_page_end(dst_uv, half_width * half_height * 2);
1505
- for (int times = 0; times < benchmark_iterations; ++times) {
1506
- ret = MJPGToNV21(kTest3Jpg, kTest3JpgLen, dst_y, width, dst_uv,
1507
- half_width * 2, width, height, width, height);
1508
- }
1509
- // Expect sucesss
1510
- EXPECT_EQ(0, ret);
1511
-
1512
- // Test result matches known hash value.
1513
- uint32_t dst_y_hash = HashDjb2(dst_y, width * height, 5381);
1514
- uint32_t dst_uv_hash = HashDjb2(dst_uv, half_width * half_height * 2, 5381);
1515
- EXPECT_EQ(dst_y_hash, 2682851208u);
1516
- EXPECT_EQ(dst_uv_hash, 493520167u);
1517
-
1518
- free_aligned_buffer_page_end(dst_y);
1519
- free_aligned_buffer_page_end(dst_uv);
1520
- }
1521
-
1522
- TEST_F(LibYUVConvertTest, DISABLED_TestMJPGToNV12_422) {
1523
- int width = 0;
1524
- int height = 0;
1525
- int ret = MJPGSize(kTest3Jpg, kTest3JpgLen, &width, &height);
1526
- EXPECT_EQ(0, ret);
1527
-
1528
- int half_width = (width + 1) / 2;
1529
- int half_height = (height + 1) / 2;
1530
- int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
1531
- benchmark_height_ / (width * height);
1532
- if (benchmark_iterations < 1) {
1533
- benchmark_iterations = 1;
1534
- }
1535
-
1536
- align_buffer_page_end(dst_y, width * height);
1537
- align_buffer_page_end(dst_uv, half_width * half_height * 2);
1538
- for (int times = 0; times < benchmark_iterations; ++times) {
1539
- ret = MJPGToNV12(kTest3Jpg, kTest3JpgLen, dst_y, width, dst_uv,
1540
- half_width * 2, width, height, width, height);
1541
- }
1542
- // Expect sucesss
1543
- EXPECT_EQ(0, ret);
1544
-
1545
- // Test result matches known hash value. Hashes are for VU so flip the plane.
1546
- uint32_t dst_y_hash = HashDjb2(dst_y, width * height, 5381);
1547
- align_buffer_page_end(dst_vu, half_width * half_height * 2);
1548
- SwapUVPlane(dst_uv, half_width * 2, dst_vu, half_width * 2, half_width,
1549
- half_height);
1550
- uint32_t dst_vu_hash = HashDjb2(dst_vu, half_width * half_height * 2, 5381);
1551
- EXPECT_EQ(dst_y_hash, 2682851208u);
1552
- EXPECT_EQ(dst_vu_hash, 493520167u);
1553
-
1554
- free_aligned_buffer_page_end(dst_y);
1555
- free_aligned_buffer_page_end(dst_uv);
1556
- free_aligned_buffer_page_end(dst_vu);
1557
- }
1558
-
1559
- TEST_F(LibYUVConvertTest, TestMJPGToNV21_400) {
1560
- int width = 0;
1561
- int height = 0;
1562
- int ret = MJPGSize(kTest0Jpg, kTest0JpgLen, &width, &height);
1563
- EXPECT_EQ(0, ret);
1564
-
1565
- int half_width = (width + 1) / 2;
1566
- int half_height = (height + 1) / 2;
1567
- int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
1568
- benchmark_height_ / (width * height);
1569
- if (benchmark_iterations < 1) {
1570
- benchmark_iterations = 1;
1571
- }
1572
-
1573
- align_buffer_page_end(dst_y, width * height);
1574
- align_buffer_page_end(dst_uv, half_width * half_height * 2);
1575
- for (int times = 0; times < benchmark_iterations; ++times) {
1576
- ret = MJPGToNV21(kTest0Jpg, kTest0JpgLen, dst_y, width, dst_uv,
1577
- half_width * 2, width, height, width, height);
1578
- }
1579
- // Expect sucesss
1580
- EXPECT_EQ(0, ret);
1581
-
1582
- // Test result matches known hash value.
1583
- uint32_t dst_y_hash = HashDjb2(dst_y, width * height, 5381);
1584
- uint32_t dst_uv_hash = HashDjb2(dst_uv, half_width * half_height * 2, 5381);
1585
- EXPECT_EQ(dst_y_hash, 330644005u);
1586
- EXPECT_EQ(dst_uv_hash, 135214341u);
1587
-
1588
- free_aligned_buffer_page_end(dst_y);
1589
- free_aligned_buffer_page_end(dst_uv);
1590
- }
1591
-
1592
- TEST_F(LibYUVConvertTest, TestMJPGToNV12_400) {
1593
- int width = 0;
1594
- int height = 0;
1595
- int ret = MJPGSize(kTest0Jpg, kTest0JpgLen, &width, &height);
1596
- EXPECT_EQ(0, ret);
1597
-
1598
- int half_width = (width + 1) / 2;
1599
- int half_height = (height + 1) / 2;
1600
- int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
1601
- benchmark_height_ / (width * height);
1602
- if (benchmark_iterations < 1) {
1603
- benchmark_iterations = 1;
1604
- }
1605
-
1606
- align_buffer_page_end(dst_y, width * height);
1607
- align_buffer_page_end(dst_uv, half_width * half_height * 2);
1608
- for (int times = 0; times < benchmark_iterations; ++times) {
1609
- ret = MJPGToNV12(kTest0Jpg, kTest0JpgLen, dst_y, width, dst_uv,
1610
- half_width * 2, width, height, width, height);
1611
- }
1612
- // Expect sucesss
1613
- EXPECT_EQ(0, ret);
1614
-
1615
- // Test result matches known hash value. Hashes are for VU so flip the plane.
1616
- uint32_t dst_y_hash = HashDjb2(dst_y, width * height, 5381);
1617
- align_buffer_page_end(dst_vu, half_width * half_height * 2);
1618
- SwapUVPlane(dst_uv, half_width * 2, dst_vu, half_width * 2, half_width,
1619
- half_height);
1620
- uint32_t dst_vu_hash = HashDjb2(dst_vu, half_width * half_height * 2, 5381);
1621
- EXPECT_EQ(dst_y_hash, 330644005u);
1622
- EXPECT_EQ(dst_vu_hash, 135214341u);
1623
-
1624
- free_aligned_buffer_page_end(dst_y);
1625
- free_aligned_buffer_page_end(dst_uv);
1626
- free_aligned_buffer_page_end(dst_vu);
1627
- }
1628
-
1629
- TEST_F(LibYUVConvertTest, TestMJPGToNV21_444) {
1630
- int width = 0;
1631
- int height = 0;
1632
- int ret = MJPGSize(kTest1Jpg, kTest1JpgLen, &width, &height);
1633
- EXPECT_EQ(0, ret);
1634
-
1635
- int half_width = (width + 1) / 2;
1636
- int half_height = (height + 1) / 2;
1637
- int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
1638
- benchmark_height_ / (width * height);
1639
- if (benchmark_iterations < 1) {
1640
- benchmark_iterations = 1;
1641
- }
1642
-
1643
- align_buffer_page_end(dst_y, width * height);
1644
- align_buffer_page_end(dst_uv, half_width * half_height * 2);
1645
- for (int times = 0; times < benchmark_iterations; ++times) {
1646
- ret = MJPGToNV21(kTest1Jpg, kTest1JpgLen, dst_y, width, dst_uv,
1647
- half_width * 2, width, height, width, height);
1648
- }
1649
- // Expect sucesss
1650
- EXPECT_EQ(0, ret);
1651
-
1652
- // Test result matches known hash value.
1653
- uint32_t dst_y_hash = HashDjb2(dst_y, width * height, 5381);
1654
- uint32_t dst_uv_hash = HashDjb2(dst_uv, half_width * half_height * 2, 5381);
1655
- EXPECT_EQ(dst_y_hash, 2682851208u);
1656
- EXPECT_EQ(dst_uv_hash, 506143297u);
1657
-
1658
- free_aligned_buffer_page_end(dst_y);
1659
- free_aligned_buffer_page_end(dst_uv);
1660
- }
1661
-
1662
- TEST_F(LibYUVConvertTest, TestMJPGToNV12_444) {
1663
- int width = 0;
1664
- int height = 0;
1665
- int ret = MJPGSize(kTest1Jpg, kTest1JpgLen, &width, &height);
1666
- EXPECT_EQ(0, ret);
1667
-
1668
- int half_width = (width + 1) / 2;
1669
- int half_height = (height + 1) / 2;
1670
- int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
1671
- benchmark_height_ / (width * height);
1672
- if (benchmark_iterations < 1) {
1673
- benchmark_iterations = 1;
1674
- }
1675
-
1676
- align_buffer_page_end(dst_y, width * height);
1677
- align_buffer_page_end(dst_uv, half_width * half_height * 2);
1678
- for (int times = 0; times < benchmark_iterations; ++times) {
1679
- ret = MJPGToNV12(kTest1Jpg, kTest1JpgLen, dst_y, width, dst_uv,
1680
- half_width * 2, width, height, width, height);
1681
- }
1682
- // Expect sucesss
1683
- EXPECT_EQ(0, ret);
1684
-
1685
- // Test result matches known hash value. Hashes are for VU so flip the plane.
1686
- uint32_t dst_y_hash = HashDjb2(dst_y, width * height, 5381);
1687
- align_buffer_page_end(dst_vu, half_width * half_height * 2);
1688
- SwapUVPlane(dst_uv, half_width * 2, dst_vu, half_width * 2, half_width,
1689
- half_height);
1690
- uint32_t dst_vu_hash = HashDjb2(dst_vu, half_width * half_height * 2, 5381);
1691
- EXPECT_EQ(dst_y_hash, 2682851208u);
1692
- EXPECT_EQ(dst_vu_hash, 506143297u);
1693
-
1694
- free_aligned_buffer_page_end(dst_y);
1695
- free_aligned_buffer_page_end(dst_uv);
1696
- free_aligned_buffer_page_end(dst_vu);
1697
- }
1698
-
1699
- TEST_F(LibYUVConvertTest, TestMJPGToARGB) {
1700
- int width = 0;
1701
- int height = 0;
1702
- int ret = MJPGSize(kTest3Jpg, kTest3JpgLen, &width, &height);
1703
- EXPECT_EQ(0, ret);
1704
-
1705
- int benchmark_iterations = benchmark_iterations_ * benchmark_width_ *
1706
- benchmark_height_ / (width * height);
1707
- if (benchmark_iterations < 1) {
1708
- benchmark_iterations = 1;
1709
- }
1710
-
1711
- align_buffer_page_end(dst_argb, width * height * 4);
1712
- for (int times = 0; times < benchmark_iterations; ++times) {
1713
- ret = MJPGToARGB(kTest3Jpg, kTest3JpgLen, dst_argb, width * 4, width,
1714
- height, width, height);
1715
- }
1716
- // Expect sucesss
1717
- EXPECT_EQ(0, ret);
1718
-
1719
- // Test result matches known hash value.
1720
- uint32_t dst_argb_hash = HashDjb2(dst_argb, width * height, 5381);
1721
- #ifdef LIBYUV_UNLIMITED_DATA
1722
- EXPECT_EQ(dst_argb_hash, 3900633302u);
1723
- #else
1724
- EXPECT_EQ(dst_argb_hash, 2355976473u);
1725
- #endif
1726
-
1727
- free_aligned_buffer_page_end(dst_argb);
1728
- }
1729
-
1730
- static int ShowJPegInfo(const uint8_t* sample, size_t sample_size) {
1731
- MJpegDecoder mjpeg_decoder;
1732
- LIBYUV_BOOL ret = mjpeg_decoder.LoadFrame(sample, sample_size);
1733
-
1734
- int width = mjpeg_decoder.GetWidth();
1735
- int height = mjpeg_decoder.GetHeight();
1736
-
1737
- // YUV420
1738
- if (mjpeg_decoder.GetColorSpace() == MJpegDecoder::kColorSpaceYCbCr &&
1739
- mjpeg_decoder.GetNumComponents() == 3 &&
1740
- mjpeg_decoder.GetVertSampFactor(0) == 2 &&
1741
- mjpeg_decoder.GetHorizSampFactor(0) == 2 &&
1742
- mjpeg_decoder.GetVertSampFactor(1) == 1 &&
1743
- mjpeg_decoder.GetHorizSampFactor(1) == 1 &&
1744
- mjpeg_decoder.GetVertSampFactor(2) == 1 &&
1745
- mjpeg_decoder.GetHorizSampFactor(2) == 1) {
1746
- printf("JPeg is J420, %dx%d %d bytes\n", width, height,
1747
- static_cast<int>(sample_size));
1748
- // YUV422
1749
- } else if (mjpeg_decoder.GetColorSpace() == MJpegDecoder::kColorSpaceYCbCr &&
1750
- mjpeg_decoder.GetNumComponents() == 3 &&
1751
- mjpeg_decoder.GetVertSampFactor(0) == 1 &&
1752
- mjpeg_decoder.GetHorizSampFactor(0) == 2 &&
1753
- mjpeg_decoder.GetVertSampFactor(1) == 1 &&
1754
- mjpeg_decoder.GetHorizSampFactor(1) == 1 &&
1755
- mjpeg_decoder.GetVertSampFactor(2) == 1 &&
1756
- mjpeg_decoder.GetHorizSampFactor(2) == 1) {
1757
- printf("JPeg is J422, %dx%d %d bytes\n", width, height,
1758
- static_cast<int>(sample_size));
1759
- // YUV444
1760
- } else if (mjpeg_decoder.GetColorSpace() == MJpegDecoder::kColorSpaceYCbCr &&
1761
- mjpeg_decoder.GetNumComponents() == 3 &&
1762
- mjpeg_decoder.GetVertSampFactor(0) == 1 &&
1763
- mjpeg_decoder.GetHorizSampFactor(0) == 1 &&
1764
- mjpeg_decoder.GetVertSampFactor(1) == 1 &&
1765
- mjpeg_decoder.GetHorizSampFactor(1) == 1 &&
1766
- mjpeg_decoder.GetVertSampFactor(2) == 1 &&
1767
- mjpeg_decoder.GetHorizSampFactor(2) == 1) {
1768
- printf("JPeg is J444, %dx%d %d bytes\n", width, height,
1769
- static_cast<int>(sample_size));
1770
- // YUV400
1771
- } else if (mjpeg_decoder.GetColorSpace() ==
1772
- MJpegDecoder::kColorSpaceGrayscale &&
1773
- mjpeg_decoder.GetNumComponents() == 1 &&
1774
- mjpeg_decoder.GetVertSampFactor(0) == 1 &&
1775
- mjpeg_decoder.GetHorizSampFactor(0) == 1) {
1776
- printf("JPeg is J400, %dx%d %d bytes\n", width, height,
1777
- static_cast<int>(sample_size));
1778
- } else {
1779
- // Unknown colorspace.
1780
- printf("JPeg is Unknown colorspace.\n");
1781
- }
1782
- mjpeg_decoder.UnloadFrame();
1783
- return ret;
1784
- }
1785
-
1786
- TEST_F(LibYUVConvertTest, TestMJPGInfo) {
1787
- EXPECT_EQ(1, ShowJPegInfo(kTest0Jpg, kTest0JpgLen));
1788
- EXPECT_EQ(1, ShowJPegInfo(kTest1Jpg, kTest1JpgLen));
1789
- EXPECT_EQ(1, ShowJPegInfo(kTest2Jpg, kTest2JpgLen));
1790
- EXPECT_EQ(1, ShowJPegInfo(kTest3Jpg, kTest3JpgLen));
1791
- EXPECT_EQ(1, ShowJPegInfo(kTest4Jpg,
1792
- kTest4JpgLen)); // Valid but unsupported.
1793
- }
1794
- #endif // HAVE_JPEG
1795
-
1796
- TEST_F(LibYUVConvertTest, NV12Crop) {
1797
- const int SUBSAMP_X = 2;
1798
- const int SUBSAMP_Y = 2;
1799
- const int kWidth = benchmark_width_;
1800
- const int kHeight = benchmark_height_;
1801
- const int crop_y =
1802
- ((benchmark_height_ - (benchmark_height_ * 360 / 480)) / 2 + 1) & ~1;
1803
- const int kDestWidth = benchmark_width_;
1804
- const int kDestHeight = benchmark_height_ - crop_y * 2;
1805
- const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X);
1806
- const int sample_size =
1807
- kWidth * kHeight + kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y) * 2;
1808
- align_buffer_page_end(src_y, sample_size);
1809
- uint8_t* src_uv = src_y + kWidth * kHeight;
1810
-
1811
- align_buffer_page_end(dst_y, kDestWidth * kDestHeight);
1812
- align_buffer_page_end(dst_u, SUBSAMPLE(kDestWidth, SUBSAMP_X) *
1813
- SUBSAMPLE(kDestHeight, SUBSAMP_Y));
1814
- align_buffer_page_end(dst_v, SUBSAMPLE(kDestWidth, SUBSAMP_X) *
1815
- SUBSAMPLE(kDestHeight, SUBSAMP_Y));
1816
-
1817
- align_buffer_page_end(dst_y_2, kDestWidth * kDestHeight);
1818
- align_buffer_page_end(dst_u_2, SUBSAMPLE(kDestWidth, SUBSAMP_X) *
1819
- SUBSAMPLE(kDestHeight, SUBSAMP_Y));
1820
- align_buffer_page_end(dst_v_2, SUBSAMPLE(kDestWidth, SUBSAMP_X) *
1821
- SUBSAMPLE(kDestHeight, SUBSAMP_Y));
1822
-
1823
- for (int i = 0; i < kHeight * kWidth; ++i) {
1824
- src_y[i] = (fastrand() & 0xff);
1825
- }
1826
- for (int i = 0; i < (SUBSAMPLE(kHeight, SUBSAMP_Y) * kStrideUV) * 2; ++i) {
1827
- src_uv[i] = (fastrand() & 0xff);
1828
- }
1829
- memset(dst_y, 1, kDestWidth * kDestHeight);
1830
- memset(dst_u, 2,
1831
- SUBSAMPLE(kDestWidth, SUBSAMP_X) * SUBSAMPLE(kDestHeight, SUBSAMP_Y));
1832
- memset(dst_v, 3,
1833
- SUBSAMPLE(kDestWidth, SUBSAMP_X) * SUBSAMPLE(kDestHeight, SUBSAMP_Y));
1834
- memset(dst_y_2, 1, kDestWidth * kDestHeight);
1835
- memset(dst_u_2, 2,
1836
- SUBSAMPLE(kDestWidth, SUBSAMP_X) * SUBSAMPLE(kDestHeight, SUBSAMP_Y));
1837
- memset(dst_v_2, 3,
1838
- SUBSAMPLE(kDestWidth, SUBSAMP_X) * SUBSAMPLE(kDestHeight, SUBSAMP_Y));
1839
-
1840
- ConvertToI420(src_y, sample_size, dst_y_2, kDestWidth, dst_u_2,
1841
- SUBSAMPLE(kDestWidth, SUBSAMP_X), dst_v_2,
1842
- SUBSAMPLE(kDestWidth, SUBSAMP_X), 0, crop_y, kWidth, kHeight,
1843
- kDestWidth, kDestHeight, libyuv::kRotate0, libyuv::FOURCC_NV12);
1844
-
1845
- NV12ToI420(src_y + crop_y * kWidth, kWidth,
1846
- src_uv + (crop_y / 2) * kStrideUV * 2, kStrideUV * 2, dst_y,
1847
- kDestWidth, dst_u, SUBSAMPLE(kDestWidth, SUBSAMP_X), dst_v,
1848
- SUBSAMPLE(kDestWidth, SUBSAMP_X), kDestWidth, kDestHeight);
1849
-
1850
- for (int i = 0; i < kDestHeight; ++i) {
1851
- for (int j = 0; j < kDestWidth; ++j) {
1852
- EXPECT_EQ(dst_y[i * kWidth + j], dst_y_2[i * kWidth + j]);
1853
- }
1854
- }
1855
- for (int i = 0; i < SUBSAMPLE(kDestHeight, SUBSAMP_Y); ++i) {
1856
- for (int j = 0; j < SUBSAMPLE(kDestWidth, SUBSAMP_X); ++j) {
1857
- EXPECT_EQ(dst_u[i * SUBSAMPLE(kDestWidth, SUBSAMP_X) + j],
1858
- dst_u_2[i * SUBSAMPLE(kDestWidth, SUBSAMP_X) + j]);
1859
- }
1860
- }
1861
- for (int i = 0; i < SUBSAMPLE(kDestHeight, SUBSAMP_Y); ++i) {
1862
- for (int j = 0; j < SUBSAMPLE(kDestWidth, SUBSAMP_X); ++j) {
1863
- EXPECT_EQ(dst_v[i * SUBSAMPLE(kDestWidth, SUBSAMP_X) + j],
1864
- dst_v_2[i * SUBSAMPLE(kDestWidth, SUBSAMP_X) + j]);
1865
- }
1866
- }
1867
- free_aligned_buffer_page_end(dst_y);
1868
- free_aligned_buffer_page_end(dst_u);
1869
- free_aligned_buffer_page_end(dst_v);
1870
- free_aligned_buffer_page_end(dst_y_2);
1871
- free_aligned_buffer_page_end(dst_u_2);
1872
- free_aligned_buffer_page_end(dst_v_2);
1873
- free_aligned_buffer_page_end(src_y);
1874
- }
1875
-
1876
- TEST_F(LibYUVConvertTest, I420CropOddY) {
1877
- const int SUBSAMP_X = 2;
1878
- const int SUBSAMP_Y = 2;
1879
- const int kWidth = benchmark_width_;
1880
- const int kHeight = benchmark_height_;
1881
- const int crop_y = benchmark_height_ > 1 ? 1 : 0;
1882
- const int kDestWidth = benchmark_width_;
1883
- const int kDestHeight = benchmark_height_ - crop_y * 2;
1884
- const int kStrideU = SUBSAMPLE(kWidth, SUBSAMP_X);
1885
- const int kStrideV = SUBSAMPLE(kWidth, SUBSAMP_X);
1886
- const int sample_size = kWidth * kHeight +
1887
- kStrideU * SUBSAMPLE(kHeight, SUBSAMP_Y) +
1888
- kStrideV * SUBSAMPLE(kHeight, SUBSAMP_Y);
1889
- align_buffer_page_end(src_y, sample_size);
1890
- uint8_t* src_u = src_y + kWidth * kHeight;
1891
- uint8_t* src_v = src_u + kStrideU * SUBSAMPLE(kHeight, SUBSAMP_Y);
1892
-
1893
- align_buffer_page_end(dst_y, kDestWidth * kDestHeight);
1894
- align_buffer_page_end(dst_u, SUBSAMPLE(kDestWidth, SUBSAMP_X) *
1895
- SUBSAMPLE(kDestHeight, SUBSAMP_Y));
1896
- align_buffer_page_end(dst_v, SUBSAMPLE(kDestWidth, SUBSAMP_X) *
1897
- SUBSAMPLE(kDestHeight, SUBSAMP_Y));
1898
-
1899
- for (int i = 0; i < kHeight * kWidth; ++i) {
1900
- src_y[i] = (fastrand() & 0xff);
1901
- }
1902
- for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y) * kStrideU; ++i) {
1903
- src_u[i] = (fastrand() & 0xff);
1904
- }
1905
- for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y) * kStrideV; ++i) {
1906
- src_v[i] = (fastrand() & 0xff);
1907
- }
1908
- memset(dst_y, 1, kDestWidth * kDestHeight);
1909
- memset(dst_u, 2,
1910
- SUBSAMPLE(kDestWidth, SUBSAMP_X) * SUBSAMPLE(kDestHeight, SUBSAMP_Y));
1911
- memset(dst_v, 3,
1912
- SUBSAMPLE(kDestWidth, SUBSAMP_X) * SUBSAMPLE(kDestHeight, SUBSAMP_Y));
1913
-
1914
- MaskCpuFlags(benchmark_cpu_info_);
1915
- for (int i = 0; i < benchmark_iterations_; ++i) {
1916
- ConvertToI420(src_y, sample_size, dst_y, kDestWidth, dst_u,
1917
- SUBSAMPLE(kDestWidth, SUBSAMP_X), dst_v,
1918
- SUBSAMPLE(kDestWidth, SUBSAMP_X), 0, crop_y, kWidth, kHeight,
1919
- kDestWidth, kDestHeight, libyuv::kRotate0,
1920
- libyuv::FOURCC_I420);
1921
- }
1922
-
1923
- for (int i = 0; i < kDestHeight; ++i) {
1924
- for (int j = 0; j < kDestWidth; ++j) {
1925
- EXPECT_EQ(src_y[crop_y * kWidth + i * kWidth + j],
1926
- dst_y[i * kDestWidth + j]);
1927
- }
1928
- }
1929
- for (int i = 0; i < SUBSAMPLE(kDestHeight, SUBSAMP_Y); ++i) {
1930
- for (int j = 0; j < SUBSAMPLE(kDestWidth, SUBSAMP_X); ++j) {
1931
- EXPECT_EQ(src_u[(crop_y / 2 + i) * kStrideU + j],
1932
- dst_u[i * SUBSAMPLE(kDestWidth, SUBSAMP_X) + j]);
1933
- }
1934
- }
1935
- for (int i = 0; i < SUBSAMPLE(kDestHeight, SUBSAMP_Y); ++i) {
1936
- for (int j = 0; j < SUBSAMPLE(kDestWidth, SUBSAMP_X); ++j) {
1937
- EXPECT_EQ(src_v[(crop_y / 2 + i) * kStrideV + j],
1938
- dst_v[i * SUBSAMPLE(kDestWidth, SUBSAMP_X) + j]);
1939
- }
1940
- }
1941
-
1942
- free_aligned_buffer_page_end(dst_y);
1943
- free_aligned_buffer_page_end(dst_u);
1944
- free_aligned_buffer_page_end(dst_v);
1945
- free_aligned_buffer_page_end(src_y);
1946
- }
1947
-
1948
- #define TESTPTOB(NAME, UYVYTOI420, UYVYTONV12) \
1949
- TEST_F(LibYUVConvertTest, NAME) { \
1950
- const int kWidth = benchmark_width_; \
1951
- const int kHeight = benchmark_height_; \
1952
- \
1953
- align_buffer_page_end(orig_uyvy, 4 * SUBSAMPLE(kWidth, 2) * kHeight); \
1954
- align_buffer_page_end(orig_y, kWidth* kHeight); \
1955
- align_buffer_page_end(orig_u, \
1956
- SUBSAMPLE(kWidth, 2) * SUBSAMPLE(kHeight, 2)); \
1957
- align_buffer_page_end(orig_v, \
1958
- SUBSAMPLE(kWidth, 2) * SUBSAMPLE(kHeight, 2)); \
1959
- \
1960
- align_buffer_page_end(dst_y_orig, kWidth* kHeight); \
1961
- align_buffer_page_end(dst_uv_orig, \
1962
- 2 * SUBSAMPLE(kWidth, 2) * SUBSAMPLE(kHeight, 2)); \
1963
- \
1964
- align_buffer_page_end(dst_y, kWidth* kHeight); \
1965
- align_buffer_page_end(dst_uv, \
1966
- 2 * SUBSAMPLE(kWidth, 2) * SUBSAMPLE(kHeight, 2)); \
1967
- \
1968
- MemRandomize(orig_uyvy, 4 * SUBSAMPLE(kWidth, 2) * kHeight); \
1969
- \
1970
- /* Convert UYVY to NV12 in 2 steps for reference */ \
1971
- libyuv::UYVYTOI420(orig_uyvy, 4 * SUBSAMPLE(kWidth, 2), orig_y, kWidth, \
1972
- orig_u, SUBSAMPLE(kWidth, 2), orig_v, \
1973
- SUBSAMPLE(kWidth, 2), kWidth, kHeight); \
1974
- libyuv::I420ToNV12(orig_y, kWidth, orig_u, SUBSAMPLE(kWidth, 2), orig_v, \
1975
- SUBSAMPLE(kWidth, 2), dst_y_orig, kWidth, dst_uv_orig, \
1976
- 2 * SUBSAMPLE(kWidth, 2), kWidth, kHeight); \
1977
- \
1978
- /* Convert to NV12 */ \
1979
- for (int i = 0; i < benchmark_iterations_; ++i) { \
1980
- libyuv::UYVYTONV12(orig_uyvy, 4 * SUBSAMPLE(kWidth, 2), dst_y, kWidth, \
1981
- dst_uv, 2 * SUBSAMPLE(kWidth, 2), kWidth, kHeight); \
1982
- } \
1983
- \
1984
- for (int i = 0; i < kWidth * kHeight; ++i) { \
1985
- EXPECT_EQ(orig_y[i], dst_y[i]); \
1986
- } \
1987
- for (int i = 0; i < kWidth * kHeight; ++i) { \
1988
- EXPECT_EQ(dst_y_orig[i], dst_y[i]); \
1989
- } \
1990
- for (int i = 0; i < 2 * SUBSAMPLE(kWidth, 2) * SUBSAMPLE(kHeight, 2); \
1991
- ++i) { \
1992
- EXPECT_EQ(dst_uv_orig[i], dst_uv[i]); \
1993
- } \
1994
- \
1995
- free_aligned_buffer_page_end(orig_uyvy); \
1996
- free_aligned_buffer_page_end(orig_y); \
1997
- free_aligned_buffer_page_end(orig_u); \
1998
- free_aligned_buffer_page_end(orig_v); \
1999
- free_aligned_buffer_page_end(dst_y_orig); \
2000
- free_aligned_buffer_page_end(dst_uv_orig); \
2001
- free_aligned_buffer_page_end(dst_y); \
2002
- free_aligned_buffer_page_end(dst_uv); \
2003
- }
2004
-
2005
- TESTPTOB(TestYUY2ToNV12, YUY2ToI420, YUY2ToNV12)
2006
- TESTPTOB(TestUYVYToNV12, UYVYToI420, UYVYToNV12)
2007
-
2008
- TEST_F(LibYUVConvertTest, MM21ToYUY2) {
2009
- const int kWidth = (benchmark_width_ + 15) & (~15);
2010
- const int kHeight = (benchmark_height_ + 31) & (~31);
2011
-
2012
- align_buffer_page_end(orig_y, kWidth * kHeight);
2013
- align_buffer_page_end(orig_uv,
2014
- 2 * SUBSAMPLE(kWidth, 2) * SUBSAMPLE(kHeight, 2));
2015
-
2016
- align_buffer_page_end(tmp_y, kWidth * kHeight);
2017
- align_buffer_page_end(tmp_u, SUBSAMPLE(kWidth, 2) * SUBSAMPLE(kHeight, 2));
2018
- align_buffer_page_end(tmp_v, SUBSAMPLE(kWidth, 2) * SUBSAMPLE(kHeight, 2));
2019
-
2020
- align_buffer_page_end(dst_yuyv, 4 * SUBSAMPLE(kWidth, 2) * kHeight);
2021
- align_buffer_page_end(golden_yuyv, 4 * SUBSAMPLE(kWidth, 2) * kHeight);
2022
-
2023
- MemRandomize(orig_y, kWidth * kHeight);
2024
- MemRandomize(orig_uv, 2 * SUBSAMPLE(kWidth, 2) * SUBSAMPLE(kHeight, 2));
2025
-
2026
- /* Convert MM21 to YUY2 in 2 steps for reference */
2027
- libyuv::MM21ToI420(orig_y, kWidth, orig_uv, 2 * SUBSAMPLE(kWidth, 2), tmp_y,
2028
- kWidth, tmp_u, SUBSAMPLE(kWidth, 2), tmp_v,
2029
- SUBSAMPLE(kWidth, 2), kWidth, kHeight);
2030
- libyuv::I420ToYUY2(tmp_y, kWidth, tmp_u, SUBSAMPLE(kWidth, 2), tmp_v,
2031
- SUBSAMPLE(kWidth, 2), golden_yuyv,
2032
- 4 * SUBSAMPLE(kWidth, 2), kWidth, kHeight);
2033
-
2034
- /* Convert to NV12 */
2035
- for (int i = 0; i < benchmark_iterations_; ++i) {
2036
- libyuv::MM21ToYUY2(orig_y, kWidth, orig_uv, 2 * SUBSAMPLE(kWidth, 2),
2037
- dst_yuyv, 4 * SUBSAMPLE(kWidth, 2), kWidth, kHeight);
2038
- }
2039
-
2040
- for (int i = 0; i < 4 * SUBSAMPLE(kWidth, 2) * kHeight; ++i) {
2041
- EXPECT_EQ(dst_yuyv[i], golden_yuyv[i]);
2042
- }
2043
-
2044
- free_aligned_buffer_page_end(orig_y);
2045
- free_aligned_buffer_page_end(orig_uv);
2046
- free_aligned_buffer_page_end(tmp_y);
2047
- free_aligned_buffer_page_end(tmp_u);
2048
- free_aligned_buffer_page_end(tmp_v);
2049
- free_aligned_buffer_page_end(dst_yuyv);
2050
- free_aligned_buffer_page_end(golden_yuyv);
2051
- }
2052
-
2053
- // Test RGB24 to J420 is exact
2054
- #if defined(LIBYUV_BIT_EXACT)
2055
- TEST_F(LibYUVConvertTest, TestRGB24ToJ420) {
2056
- const int kSize = 256;
2057
- align_buffer_page_end(orig_rgb24, kSize * 3 * 2); // 2 rows of RGB24
2058
- align_buffer_page_end(dest_j420, kSize * 3 / 2 * 2);
2059
- int iterations256 = (benchmark_width_ * benchmark_height_ + (kSize * 2 - 1)) /
2060
- (kSize * 2) * benchmark_iterations_;
2061
-
2062
- for (int i = 0; i < kSize * 3 * 2; ++i) {
2063
- orig_rgb24[i] = i;
2064
- }
2065
-
2066
- for (int i = 0; i < iterations256; ++i) {
2067
- RGB24ToJ420(orig_rgb24, kSize * 3, dest_j420, kSize, // Y plane
2068
- dest_j420 + kSize * 2, kSize / 2, // U plane
2069
- dest_j420 + kSize * 5 / 2, kSize / 2, // V plane
2070
- kSize, 2);
2071
- }
2072
-
2073
- uint32_t checksum = HashDjb2(dest_j420, kSize * 3 / 2 * 2, 5381);
2074
- EXPECT_EQ(223551344u, checksum);
2075
-
2076
- free_aligned_buffer_page_end(orig_rgb24);
2077
- free_aligned_buffer_page_end(dest_j420);
2078
- }
2079
- #endif
2080
-
2081
- // Test RGB24 to I420 is exact
2082
- #if defined(LIBYUV_BIT_EXACT)
2083
- TEST_F(LibYUVConvertTest, TestRGB24ToI420) {
2084
- const int kSize = 256;
2085
- align_buffer_page_end(orig_rgb24, kSize * 3 * 2); // 2 rows of RGB24
2086
- align_buffer_page_end(dest_i420, kSize * 3 / 2 * 2);
2087
- int iterations256 = (benchmark_width_ * benchmark_height_ + (kSize * 2 - 1)) /
2088
- (kSize * 2) * benchmark_iterations_;
2089
-
2090
- for (int i = 0; i < kSize * 3 * 2; ++i) {
2091
- orig_rgb24[i] = i;
2092
- }
2093
-
2094
- for (int i = 0; i < iterations256; ++i) {
2095
- RGB24ToI420(orig_rgb24, kSize * 3, dest_i420, kSize, // Y plane
2096
- dest_i420 + kSize * 2, kSize / 2, // U plane
2097
- dest_i420 + kSize * 5 / 2, kSize / 2, // V plane
2098
- kSize, 2);
2099
- }
2100
-
2101
- uint32_t checksum = HashDjb2(dest_i420, kSize * 3 / 2 * 2, 5381);
2102
- EXPECT_EQ(4197774805u, checksum);
2103
-
2104
- free_aligned_buffer_page_end(orig_rgb24);
2105
- free_aligned_buffer_page_end(dest_i420);
2106
- }
2107
- #endif
2108
-
2109
- TEST_F(LibYUVConvertTest, TestJ420ToI420) {
2110
- const uint8_t src_y[12] = {0, 0, 128, 128, 255, 255,
2111
- 0, 0, 128, 128, 255, 255};
2112
- const uint8_t src_u[3] = {0, 128, 255};
2113
- const uint8_t src_v[3] = {0, 128, 255};
2114
- uint8_t dst_y[12];
2115
- uint8_t dst_u[3];
2116
- uint8_t dst_v[3];
2117
- ASSERT_EQ(J420ToI420(src_y, 6, src_u, 3, src_v, 3, dst_y, 6, dst_u, 3, dst_v,
2118
- 3, 6, 2),
2119
- 0);
2120
- EXPECT_EQ(dst_y[0], 16);
2121
- EXPECT_EQ(dst_y[2], 126);
2122
- EXPECT_EQ(dst_y[4], 235);
2123
- EXPECT_EQ(dst_u[0], 16);
2124
- EXPECT_EQ(dst_u[1], 128);
2125
- EXPECT_EQ(dst_u[2], 240);
2126
- EXPECT_EQ(dst_v[0], 16);
2127
- EXPECT_EQ(dst_v[1], 128);
2128
- EXPECT_EQ(dst_v[2], 240);
2129
- }
2130
-
2131
- #endif // !defined(LEAN_TESTS)
2132
-
2133
- } // namespace libyuv