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 "../unit_test/unit_test.h"
12
13#include <stdlib.h>  // For getenv()
14
15#include <cstring>
16
17// Change this to 1000 for benchmarking.
18// TODO(fbarchard): Add command line parsing to pass this as option.
19#define BENCHMARK_ITERATIONS 1
20
21libyuvTest::libyuvTest() : rotate_max_w_(128), rotate_max_h_(128),
22    benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128),
23    benchmark_height_(72) {
24    const char* repeat = getenv("LIBYUV_REPEAT");
25    if (repeat) {
26      benchmark_iterations_ = atoi(repeat);  // NOLINT
27      // For quicker unittests, default is 128 x 72.  But when benchmarking,
28      // default to 720p.  Allow size to specify.
29      if (benchmark_iterations_ > 1) {
30        benchmark_width_ = 1280;
31        benchmark_height_ = 720;
32      }
33    }
34    const char* width = getenv("LIBYUV_WIDTH");
35    if (width) {
36      benchmark_width_ = atoi(width);  // NOLINT
37    }
38    const char* height = getenv("LIBYUV_HEIGHT");
39    if (height) {
40      benchmark_height_ = atoi(height);  // NOLINT
41    }
42    benchmark_pixels_div256_ = static_cast<int>((
43        static_cast<double>(Abs(benchmark_width_)) *
44        static_cast<double>(Abs(benchmark_height_)) *
45        static_cast<double>(benchmark_iterations_)  + 255.0) / 256.0);
46    benchmark_pixels_div1280_ = static_cast<int>((
47        static_cast<double>(Abs(benchmark_width_)) *
48        static_cast<double>(Abs(benchmark_height_)) *
49        static_cast<double>(benchmark_iterations_)  + 1279.0) / 1280.0);
50}
51
52int main(int argc, char** argv) {
53  ::testing::InitGoogleTest(&argc, argv);
54  return RUN_ALL_TESTS();
55}
56