2
0

unit_test.cc 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  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. #include "../unit_test/unit_test.h"
  11. #include <stdlib.h> // For getenv()
  12. #include <cstring>
  13. #ifdef LIBYUV_USE_GFLAGS
  14. #include "gflags/gflags.h"
  15. #endif
  16. #ifdef LIBYUV_USE_BASE_FLAGS
  17. #include "base/commandlineflags.h"
  18. #endif
  19. #include "libyuv/cpu_id.h"
  20. unsigned int fastrand_seed = 0xfb;
  21. #ifdef LIBYUV_USE_GFLAGS
  22. DEFINE_int32(libyuv_width, 0, "width of test image.");
  23. DEFINE_int32(libyuv_height, 0, "height of test image.");
  24. DEFINE_int32(libyuv_repeat, 0, "number of times to repeat test.");
  25. DEFINE_int32(libyuv_flags, 0, "cpu flags for reference code. 1 = C, -1 = SIMD");
  26. DEFINE_int32(libyuv_cpu_info,
  27. 0,
  28. "cpu flags for benchmark code. 1 = C, -1 = SIMD");
  29. #else
  30. // Disable command line parameters if gflags disabled.
  31. static const int32_t FLAGS_libyuv_width = 0;
  32. static const int32_t FLAGS_libyuv_height = 0;
  33. static const int32_t FLAGS_libyuv_repeat = 0;
  34. static const int32_t FLAGS_libyuv_flags = 0;
  35. static const int32_t FLAGS_libyuv_cpu_info = 0;
  36. #endif
  37. // Test environment variable for disabling CPU features. Any non-zero value
  38. // to disable. Zero ignored to make it easy to set the variable on/off.
  39. #if !defined(__native_client__) && !defined(_M_ARM)
  40. static LIBYUV_BOOL TestEnv(const char* name) {
  41. const char* var = getenv(name);
  42. if (var) {
  43. if (var[0] != '0') {
  44. return LIBYUV_TRUE;
  45. }
  46. }
  47. return LIBYUV_FALSE;
  48. }
  49. #else // nacl does not support getenv().
  50. static LIBYUV_BOOL TestEnv(const char*) {
  51. return LIBYUV_FALSE;
  52. }
  53. #endif
  54. int TestCpuEnv(int cpu_info) {
  55. #if defined(__arm__) || defined(__aarch64__)
  56. if (TestEnv("LIBYUV_DISABLE_NEON")) {
  57. cpu_info &= ~libyuv::kCpuHasNEON;
  58. }
  59. #endif
  60. #if defined(__mips__) && defined(__linux__)
  61. if (TestEnv("LIBYUV_DISABLE_MSA")) {
  62. cpu_info &= ~libyuv::kCpuHasMSA;
  63. }
  64. if (TestEnv("LIBYUV_DISABLE_MMI")) {
  65. cpu_info &= ~libyuv::kCpuHasMMI;
  66. }
  67. #endif
  68. #if !defined(__pnacl__) && !defined(__CLR_VER) && \
  69. (defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || \
  70. defined(_M_IX86))
  71. if (TestEnv("LIBYUV_DISABLE_X86")) {
  72. cpu_info &= ~libyuv::kCpuHasX86;
  73. }
  74. if (TestEnv("LIBYUV_DISABLE_SSE2")) {
  75. cpu_info &= ~libyuv::kCpuHasSSE2;
  76. }
  77. if (TestEnv("LIBYUV_DISABLE_SSSE3")) {
  78. cpu_info &= ~libyuv::kCpuHasSSSE3;
  79. }
  80. if (TestEnv("LIBYUV_DISABLE_SSE41")) {
  81. cpu_info &= ~libyuv::kCpuHasSSE41;
  82. }
  83. if (TestEnv("LIBYUV_DISABLE_SSE42")) {
  84. cpu_info &= ~libyuv::kCpuHasSSE42;
  85. }
  86. if (TestEnv("LIBYUV_DISABLE_AVX")) {
  87. cpu_info &= ~libyuv::kCpuHasAVX;
  88. }
  89. if (TestEnv("LIBYUV_DISABLE_AVX2")) {
  90. cpu_info &= ~libyuv::kCpuHasAVX2;
  91. }
  92. if (TestEnv("LIBYUV_DISABLE_ERMS")) {
  93. cpu_info &= ~libyuv::kCpuHasERMS;
  94. }
  95. if (TestEnv("LIBYUV_DISABLE_FMA3")) {
  96. cpu_info &= ~libyuv::kCpuHasFMA3;
  97. }
  98. if (TestEnv("LIBYUV_DISABLE_F16C")) {
  99. cpu_info &= ~libyuv::kCpuHasF16C;
  100. }
  101. if (TestEnv("LIBYUV_DISABLE_AVX512BW")) {
  102. cpu_info &= ~libyuv::kCpuHasAVX512BW;
  103. }
  104. if (TestEnv("LIBYUV_DISABLE_AVX512VL")) {
  105. cpu_info &= ~libyuv::kCpuHasAVX512VL;
  106. }
  107. if (TestEnv("LIBYUV_DISABLE_AVX512VBMI")) {
  108. cpu_info &= ~libyuv::kCpuHasAVX512VBMI;
  109. }
  110. if (TestEnv("LIBYUV_DISABLE_AVX512VBMI2")) {
  111. cpu_info &= ~libyuv::kCpuHasAVX512VBMI2;
  112. }
  113. if (TestEnv("LIBYUV_DISABLE_AVX512VBITALG")) {
  114. cpu_info &= ~libyuv::kCpuHasAVX512VBITALG;
  115. }
  116. if (TestEnv("LIBYUV_DISABLE_AVX512VPOPCNTDQ")) {
  117. cpu_info &= ~libyuv::kCpuHasAVX512VPOPCNTDQ;
  118. }
  119. if (TestEnv("LIBYUV_DISABLE_GFNI")) {
  120. cpu_info &= ~libyuv::kCpuHasGFNI;
  121. }
  122. #endif
  123. if (TestEnv("LIBYUV_DISABLE_ASM")) {
  124. cpu_info = libyuv::kCpuInitialized;
  125. }
  126. return cpu_info;
  127. }
  128. // For quicker unittests, default is 128 x 72. But when benchmarking,
  129. // default to 720p. Allow size to specify.
  130. // Set flags to -1 for benchmarking to avoid slower C code.
  131. LibYUVConvertTest::LibYUVConvertTest()
  132. : benchmark_iterations_(1),
  133. benchmark_width_(128),
  134. benchmark_height_(72),
  135. disable_cpu_flags_(1),
  136. benchmark_cpu_info_(-1) {
  137. const char* repeat = getenv("LIBYUV_REPEAT");
  138. if (repeat) {
  139. benchmark_iterations_ = atoi(repeat); // NOLINT
  140. }
  141. if (FLAGS_libyuv_repeat) {
  142. benchmark_iterations_ = FLAGS_libyuv_repeat;
  143. }
  144. if (benchmark_iterations_ > 1) {
  145. benchmark_width_ = 1280;
  146. benchmark_height_ = 720;
  147. }
  148. const char* width = getenv("LIBYUV_WIDTH");
  149. if (width) {
  150. benchmark_width_ = atoi(width); // NOLINT
  151. }
  152. if (FLAGS_libyuv_width) {
  153. benchmark_width_ = FLAGS_libyuv_width;
  154. }
  155. const char* height = getenv("LIBYUV_HEIGHT");
  156. if (height) {
  157. benchmark_height_ = atoi(height); // NOLINT
  158. }
  159. if (FLAGS_libyuv_height) {
  160. benchmark_height_ = FLAGS_libyuv_height;
  161. }
  162. const char* cpu_flags = getenv("LIBYUV_FLAGS");
  163. if (cpu_flags) {
  164. disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
  165. }
  166. if (FLAGS_libyuv_flags) {
  167. disable_cpu_flags_ = FLAGS_libyuv_flags;
  168. }
  169. const char* cpu_info = getenv("LIBYUV_CPU_INFO");
  170. if (cpu_info) {
  171. benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT
  172. }
  173. if (FLAGS_libyuv_cpu_info) {
  174. benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
  175. }
  176. disable_cpu_flags_ = TestCpuEnv(disable_cpu_flags_);
  177. benchmark_cpu_info_ = TestCpuEnv(benchmark_cpu_info_);
  178. libyuv::MaskCpuFlags(benchmark_cpu_info_);
  179. benchmark_pixels_div1280_ =
  180. static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
  181. static_cast<double>(Abs(benchmark_height_)) *
  182. static_cast<double>(benchmark_iterations_) +
  183. 1279.0) /
  184. 1280.0);
  185. }
  186. LibYUVColorTest::LibYUVColorTest()
  187. : benchmark_iterations_(1),
  188. benchmark_width_(128),
  189. benchmark_height_(72),
  190. disable_cpu_flags_(1),
  191. benchmark_cpu_info_(-1) {
  192. const char* repeat = getenv("LIBYUV_REPEAT");
  193. if (repeat) {
  194. benchmark_iterations_ = atoi(repeat); // NOLINT
  195. }
  196. if (FLAGS_libyuv_repeat) {
  197. benchmark_iterations_ = FLAGS_libyuv_repeat;
  198. }
  199. if (benchmark_iterations_ > 1) {
  200. benchmark_width_ = 1280;
  201. benchmark_height_ = 720;
  202. }
  203. const char* width = getenv("LIBYUV_WIDTH");
  204. if (width) {
  205. benchmark_width_ = atoi(width); // NOLINT
  206. }
  207. if (FLAGS_libyuv_width) {
  208. benchmark_width_ = FLAGS_libyuv_width;
  209. }
  210. const char* height = getenv("LIBYUV_HEIGHT");
  211. if (height) {
  212. benchmark_height_ = atoi(height); // NOLINT
  213. }
  214. if (FLAGS_libyuv_height) {
  215. benchmark_height_ = FLAGS_libyuv_height;
  216. }
  217. const char* cpu_flags = getenv("LIBYUV_FLAGS");
  218. if (cpu_flags) {
  219. disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
  220. }
  221. if (FLAGS_libyuv_flags) {
  222. disable_cpu_flags_ = FLAGS_libyuv_flags;
  223. }
  224. const char* cpu_info = getenv("LIBYUV_CPU_INFO");
  225. if (cpu_info) {
  226. benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT
  227. }
  228. if (FLAGS_libyuv_cpu_info) {
  229. benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
  230. }
  231. disable_cpu_flags_ = TestCpuEnv(disable_cpu_flags_);
  232. benchmark_cpu_info_ = TestCpuEnv(benchmark_cpu_info_);
  233. libyuv::MaskCpuFlags(benchmark_cpu_info_);
  234. benchmark_pixels_div1280_ =
  235. static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
  236. static_cast<double>(Abs(benchmark_height_)) *
  237. static_cast<double>(benchmark_iterations_) +
  238. 1279.0) /
  239. 1280.0);
  240. }
  241. LibYUVScaleTest::LibYUVScaleTest()
  242. : benchmark_iterations_(1),
  243. benchmark_width_(128),
  244. benchmark_height_(72),
  245. disable_cpu_flags_(1),
  246. benchmark_cpu_info_(-1) {
  247. const char* repeat = getenv("LIBYUV_REPEAT");
  248. if (repeat) {
  249. benchmark_iterations_ = atoi(repeat); // NOLINT
  250. }
  251. if (FLAGS_libyuv_repeat) {
  252. benchmark_iterations_ = FLAGS_libyuv_repeat;
  253. }
  254. if (benchmark_iterations_ > 1) {
  255. benchmark_width_ = 1280;
  256. benchmark_height_ = 720;
  257. }
  258. const char* width = getenv("LIBYUV_WIDTH");
  259. if (width) {
  260. benchmark_width_ = atoi(width); // NOLINT
  261. }
  262. if (FLAGS_libyuv_width) {
  263. benchmark_width_ = FLAGS_libyuv_width;
  264. }
  265. const char* height = getenv("LIBYUV_HEIGHT");
  266. if (height) {
  267. benchmark_height_ = atoi(height); // NOLINT
  268. }
  269. if (FLAGS_libyuv_height) {
  270. benchmark_height_ = FLAGS_libyuv_height;
  271. }
  272. const char* cpu_flags = getenv("LIBYUV_FLAGS");
  273. if (cpu_flags) {
  274. disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
  275. }
  276. if (FLAGS_libyuv_flags) {
  277. disable_cpu_flags_ = FLAGS_libyuv_flags;
  278. }
  279. const char* cpu_info = getenv("LIBYUV_CPU_INFO");
  280. if (cpu_info) {
  281. benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT
  282. }
  283. if (FLAGS_libyuv_cpu_info) {
  284. benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
  285. }
  286. disable_cpu_flags_ = TestCpuEnv(disable_cpu_flags_);
  287. benchmark_cpu_info_ = TestCpuEnv(benchmark_cpu_info_);
  288. libyuv::MaskCpuFlags(benchmark_cpu_info_);
  289. benchmark_pixels_div1280_ =
  290. static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
  291. static_cast<double>(Abs(benchmark_height_)) *
  292. static_cast<double>(benchmark_iterations_) +
  293. 1279.0) /
  294. 1280.0);
  295. }
  296. LibYUVRotateTest::LibYUVRotateTest()
  297. : benchmark_iterations_(1),
  298. benchmark_width_(128),
  299. benchmark_height_(72),
  300. disable_cpu_flags_(1),
  301. benchmark_cpu_info_(-1) {
  302. const char* repeat = getenv("LIBYUV_REPEAT");
  303. if (repeat) {
  304. benchmark_iterations_ = atoi(repeat); // NOLINT
  305. }
  306. if (FLAGS_libyuv_repeat) {
  307. benchmark_iterations_ = FLAGS_libyuv_repeat;
  308. }
  309. if (benchmark_iterations_ > 1) {
  310. benchmark_width_ = 1280;
  311. benchmark_height_ = 720;
  312. }
  313. const char* width = getenv("LIBYUV_WIDTH");
  314. if (width) {
  315. benchmark_width_ = atoi(width); // NOLINT
  316. }
  317. if (FLAGS_libyuv_width) {
  318. benchmark_width_ = FLAGS_libyuv_width;
  319. }
  320. const char* height = getenv("LIBYUV_HEIGHT");
  321. if (height) {
  322. benchmark_height_ = atoi(height); // NOLINT
  323. }
  324. if (FLAGS_libyuv_height) {
  325. benchmark_height_ = FLAGS_libyuv_height;
  326. }
  327. const char* cpu_flags = getenv("LIBYUV_FLAGS");
  328. if (cpu_flags) {
  329. disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
  330. }
  331. if (FLAGS_libyuv_flags) {
  332. disable_cpu_flags_ = FLAGS_libyuv_flags;
  333. }
  334. const char* cpu_info = getenv("LIBYUV_CPU_INFO");
  335. if (cpu_info) {
  336. benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT
  337. }
  338. if (FLAGS_libyuv_cpu_info) {
  339. benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
  340. }
  341. disable_cpu_flags_ = TestCpuEnv(disable_cpu_flags_);
  342. benchmark_cpu_info_ = TestCpuEnv(benchmark_cpu_info_);
  343. libyuv::MaskCpuFlags(benchmark_cpu_info_);
  344. benchmark_pixels_div1280_ =
  345. static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
  346. static_cast<double>(Abs(benchmark_height_)) *
  347. static_cast<double>(benchmark_iterations_) +
  348. 1279.0) /
  349. 1280.0);
  350. }
  351. LibYUVPlanarTest::LibYUVPlanarTest()
  352. : benchmark_iterations_(1),
  353. benchmark_width_(128),
  354. benchmark_height_(72),
  355. disable_cpu_flags_(1),
  356. benchmark_cpu_info_(-1) {
  357. const char* repeat = getenv("LIBYUV_REPEAT");
  358. if (repeat) {
  359. benchmark_iterations_ = atoi(repeat); // NOLINT
  360. }
  361. if (FLAGS_libyuv_repeat) {
  362. benchmark_iterations_ = FLAGS_libyuv_repeat;
  363. }
  364. if (benchmark_iterations_ > 1) {
  365. benchmark_width_ = 1280;
  366. benchmark_height_ = 720;
  367. }
  368. const char* width = getenv("LIBYUV_WIDTH");
  369. if (width) {
  370. benchmark_width_ = atoi(width); // NOLINT
  371. }
  372. if (FLAGS_libyuv_width) {
  373. benchmark_width_ = FLAGS_libyuv_width;
  374. }
  375. const char* height = getenv("LIBYUV_HEIGHT");
  376. if (height) {
  377. benchmark_height_ = atoi(height); // NOLINT
  378. }
  379. if (FLAGS_libyuv_height) {
  380. benchmark_height_ = FLAGS_libyuv_height;
  381. }
  382. const char* cpu_flags = getenv("LIBYUV_FLAGS");
  383. if (cpu_flags) {
  384. disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
  385. }
  386. if (FLAGS_libyuv_flags) {
  387. disable_cpu_flags_ = FLAGS_libyuv_flags;
  388. }
  389. const char* cpu_info = getenv("LIBYUV_CPU_INFO");
  390. if (cpu_info) {
  391. benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT
  392. }
  393. if (FLAGS_libyuv_cpu_info) {
  394. benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
  395. }
  396. disable_cpu_flags_ = TestCpuEnv(disable_cpu_flags_);
  397. benchmark_cpu_info_ = TestCpuEnv(benchmark_cpu_info_);
  398. libyuv::MaskCpuFlags(benchmark_cpu_info_);
  399. benchmark_pixels_div1280_ =
  400. static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
  401. static_cast<double>(Abs(benchmark_height_)) *
  402. static_cast<double>(benchmark_iterations_) +
  403. 1279.0) /
  404. 1280.0);
  405. }
  406. LibYUVBaseTest::LibYUVBaseTest()
  407. : benchmark_iterations_(1),
  408. benchmark_width_(128),
  409. benchmark_height_(72),
  410. disable_cpu_flags_(1),
  411. benchmark_cpu_info_(-1) {
  412. const char* repeat = getenv("LIBYUV_REPEAT");
  413. if (repeat) {
  414. benchmark_iterations_ = atoi(repeat); // NOLINT
  415. }
  416. if (FLAGS_libyuv_repeat) {
  417. benchmark_iterations_ = FLAGS_libyuv_repeat;
  418. }
  419. if (benchmark_iterations_ > 1) {
  420. benchmark_width_ = 1280;
  421. benchmark_height_ = 720;
  422. }
  423. const char* width = getenv("LIBYUV_WIDTH");
  424. if (width) {
  425. benchmark_width_ = atoi(width); // NOLINT
  426. }
  427. if (FLAGS_libyuv_width) {
  428. benchmark_width_ = FLAGS_libyuv_width;
  429. }
  430. const char* height = getenv("LIBYUV_HEIGHT");
  431. if (height) {
  432. benchmark_height_ = atoi(height); // NOLINT
  433. }
  434. if (FLAGS_libyuv_height) {
  435. benchmark_height_ = FLAGS_libyuv_height;
  436. }
  437. const char* cpu_flags = getenv("LIBYUV_FLAGS");
  438. if (cpu_flags) {
  439. disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
  440. }
  441. if (FLAGS_libyuv_flags) {
  442. disable_cpu_flags_ = FLAGS_libyuv_flags;
  443. }
  444. const char* cpu_info = getenv("LIBYUV_CPU_INFO");
  445. if (cpu_info) {
  446. benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT
  447. }
  448. if (FLAGS_libyuv_cpu_info) {
  449. benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
  450. }
  451. disable_cpu_flags_ = TestCpuEnv(disable_cpu_flags_);
  452. benchmark_cpu_info_ = TestCpuEnv(benchmark_cpu_info_);
  453. libyuv::MaskCpuFlags(benchmark_cpu_info_);
  454. benchmark_pixels_div1280_ =
  455. static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
  456. static_cast<double>(Abs(benchmark_height_)) *
  457. static_cast<double>(benchmark_iterations_) +
  458. 1279.0) /
  459. 1280.0);
  460. }
  461. LibYUVCompareTest::LibYUVCompareTest()
  462. : benchmark_iterations_(1),
  463. benchmark_width_(128),
  464. benchmark_height_(72),
  465. disable_cpu_flags_(1),
  466. benchmark_cpu_info_(-1) {
  467. const char* repeat = getenv("LIBYUV_REPEAT");
  468. if (repeat) {
  469. benchmark_iterations_ = atoi(repeat); // NOLINT
  470. }
  471. if (FLAGS_libyuv_repeat) {
  472. benchmark_iterations_ = FLAGS_libyuv_repeat;
  473. }
  474. if (benchmark_iterations_ > 1) {
  475. benchmark_width_ = 1280;
  476. benchmark_height_ = 720;
  477. }
  478. const char* width = getenv("LIBYUV_WIDTH");
  479. if (width) {
  480. benchmark_width_ = atoi(width); // NOLINT
  481. }
  482. if (FLAGS_libyuv_width) {
  483. benchmark_width_ = FLAGS_libyuv_width;
  484. }
  485. const char* height = getenv("LIBYUV_HEIGHT");
  486. if (height) {
  487. benchmark_height_ = atoi(height); // NOLINT
  488. }
  489. if (FLAGS_libyuv_height) {
  490. benchmark_height_ = FLAGS_libyuv_height;
  491. }
  492. const char* cpu_flags = getenv("LIBYUV_FLAGS");
  493. if (cpu_flags) {
  494. disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
  495. }
  496. if (FLAGS_libyuv_flags) {
  497. disable_cpu_flags_ = FLAGS_libyuv_flags;
  498. }
  499. const char* cpu_info = getenv("LIBYUV_CPU_INFO");
  500. if (cpu_info) {
  501. benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT
  502. }
  503. if (FLAGS_libyuv_cpu_info) {
  504. benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
  505. }
  506. disable_cpu_flags_ = TestCpuEnv(disable_cpu_flags_);
  507. benchmark_cpu_info_ = TestCpuEnv(benchmark_cpu_info_);
  508. libyuv::MaskCpuFlags(benchmark_cpu_info_);
  509. benchmark_pixels_div1280_ =
  510. static_cast<int>((static_cast<double>(Abs(benchmark_width_)) *
  511. static_cast<double>(Abs(benchmark_height_)) *
  512. static_cast<double>(benchmark_iterations_) +
  513. 1279.0) /
  514. 1280.0);
  515. }
  516. int main(int argc, char** argv) {
  517. ::testing::InitGoogleTest(&argc, argv);
  518. #ifdef LIBYUV_USE_GFLAGS
  519. // AllowCommandLineParsing allows us to ignore flags passed on to us by
  520. // Chromium build bots without having to explicitly disable them.
  521. google::AllowCommandLineReparsing();
  522. google::ParseCommandLineFlags(&argc, &argv, true);
  523. #endif
  524. return RUN_ALL_TESTS();
  525. }