1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libyuv/unit_test/unit_test.cc Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 1.4 +/* 1.5 + * Copyright 2011 The LibYuv Project Authors. All rights reserved. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license 1.8 + * that can be found in the LICENSE file in the root of the source 1.9 + * tree. An additional intellectual property rights grant can be found 1.10 + * in the file PATENTS. All contributing project authors may 1.11 + * be found in the AUTHORS file in the root of the source tree. 1.12 + */ 1.13 + 1.14 +#include "../unit_test/unit_test.h" 1.15 + 1.16 +#include <stdlib.h> // For getenv() 1.17 + 1.18 +#include <cstring> 1.19 + 1.20 +// Change this to 1000 for benchmarking. 1.21 +// TODO(fbarchard): Add command line parsing to pass this as option. 1.22 +#define BENCHMARK_ITERATIONS 1 1.23 + 1.24 +libyuvTest::libyuvTest() : rotate_max_w_(128), rotate_max_h_(128), 1.25 + benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128), 1.26 + benchmark_height_(72) { 1.27 + const char* repeat = getenv("LIBYUV_REPEAT"); 1.28 + if (repeat) { 1.29 + benchmark_iterations_ = atoi(repeat); // NOLINT 1.30 + // For quicker unittests, default is 128 x 72. But when benchmarking, 1.31 + // default to 720p. Allow size to specify. 1.32 + if (benchmark_iterations_ > 1) { 1.33 + benchmark_width_ = 1280; 1.34 + benchmark_height_ = 720; 1.35 + } 1.36 + } 1.37 + const char* width = getenv("LIBYUV_WIDTH"); 1.38 + if (width) { 1.39 + benchmark_width_ = atoi(width); // NOLINT 1.40 + } 1.41 + const char* height = getenv("LIBYUV_HEIGHT"); 1.42 + if (height) { 1.43 + benchmark_height_ = atoi(height); // NOLINT 1.44 + } 1.45 + benchmark_pixels_div256_ = static_cast<int>(( 1.46 + static_cast<double>(Abs(benchmark_width_)) * 1.47 + static_cast<double>(Abs(benchmark_height_)) * 1.48 + static_cast<double>(benchmark_iterations_) + 255.0) / 256.0); 1.49 + benchmark_pixels_div1280_ = static_cast<int>(( 1.50 + static_cast<double>(Abs(benchmark_width_)) * 1.51 + static_cast<double>(Abs(benchmark_height_)) * 1.52 + static_cast<double>(benchmark_iterations_) + 1279.0) / 1280.0); 1.53 +} 1.54 + 1.55 +int main(int argc, char** argv) { 1.56 + ::testing::InitGoogleTest(&argc, argv); 1.57 + return RUN_ALL_TESTS(); 1.58 +}