unit_test.cc 1.95 KB
Newer Older
frkoenig@google.com's avatar
frkoenig@google.com committed
1
/*
2
 *  Copyright 2011 The LibYuv Project Authors. All rights reserved.
frkoenig@google.com's avatar
frkoenig@google.com committed
3 4 5 6
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
7
 *  in the file PATENTS. All contributing project authors may
frkoenig@google.com's avatar
frkoenig@google.com committed
8 9 10
 *  be found in the AUTHORS file in the root of the source tree.
 */

11
#include "../unit_test/unit_test.h"
12

13 14
#include <stdlib.h>  // For getenv()

15 16
#include <cstring>

17 18 19 20
// Change this to 1000 for benchmarking.
// TODO(fbarchard): Add command line parsing to pass this as option.
#define BENCHMARK_ITERATIONS 1

21
libyuvTest::libyuvTest() : rotate_max_w_(128), rotate_max_h_(128),
22 23
    benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128),
    benchmark_height_(72) {
24 25
    const char* repeat = getenv("LIBYUV_REPEAT");
    if (repeat) {
26
      benchmark_iterations_ = atoi(repeat);  // NOLINT
27 28 29 30 31 32
      // For quicker unittests, default is 128 x 72.  But when benchmarking,
      // default to 720p.  Allow size to specify.
      if (benchmark_iterations_ > 1) {
        benchmark_width_ = 1280;
        benchmark_height_ = 720;
      }
33
    }
34 35 36 37 38 39 40 41
    const char* width = getenv("LIBYUV_WIDTH");
    if (width) {
      benchmark_width_ = atoi(width);  // NOLINT
    }
    const char* height = getenv("LIBYUV_HEIGHT");
    if (height) {
      benchmark_height_ = atoi(height);  // NOLINT
    }
42 43 44 45
    benchmark_pixels_div256_ = static_cast<int>((
        static_cast<double>(Abs(benchmark_width_)) *
        static_cast<double>(Abs(benchmark_height_)) *
        static_cast<double>(benchmark_iterations_)  + 255.0) / 256.0);
46 47 48 49
    benchmark_pixels_div1280_ = static_cast<int>((
        static_cast<double>(Abs(benchmark_width_)) *
        static_cast<double>(Abs(benchmark_height_)) *
        static_cast<double>(benchmark_iterations_)  + 1279.0) / 1280.0);
frkoenig@google.com's avatar
frkoenig@google.com committed
50 51 52 53 54
}

int main(int argc, char** argv) {
  ::testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
mikhal@webrtc.org's avatar
mikhal@webrtc.org committed
55
}