media/libyuv/unit_test/unit_test.cc

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /*
michael@0 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license
michael@0 5 * that can be found in the LICENSE file in the root of the source
michael@0 6 * tree. An additional intellectual property rights grant can be found
michael@0 7 * in the file PATENTS. All contributing project authors may
michael@0 8 * be found in the AUTHORS file in the root of the source tree.
michael@0 9 */
michael@0 10
michael@0 11 #include "../unit_test/unit_test.h"
michael@0 12
michael@0 13 #include <stdlib.h> // For getenv()
michael@0 14
michael@0 15 #include <cstring>
michael@0 16
michael@0 17 // Change this to 1000 for benchmarking.
michael@0 18 // TODO(fbarchard): Add command line parsing to pass this as option.
michael@0 19 #define BENCHMARK_ITERATIONS 1
michael@0 20
michael@0 21 libyuvTest::libyuvTest() : rotate_max_w_(128), rotate_max_h_(128),
michael@0 22 benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128),
michael@0 23 benchmark_height_(72) {
michael@0 24 const char* repeat = getenv("LIBYUV_REPEAT");
michael@0 25 if (repeat) {
michael@0 26 benchmark_iterations_ = atoi(repeat); // NOLINT
michael@0 27 // For quicker unittests, default is 128 x 72. But when benchmarking,
michael@0 28 // default to 720p. Allow size to specify.
michael@0 29 if (benchmark_iterations_ > 1) {
michael@0 30 benchmark_width_ = 1280;
michael@0 31 benchmark_height_ = 720;
michael@0 32 }
michael@0 33 }
michael@0 34 const char* width = getenv("LIBYUV_WIDTH");
michael@0 35 if (width) {
michael@0 36 benchmark_width_ = atoi(width); // NOLINT
michael@0 37 }
michael@0 38 const char* height = getenv("LIBYUV_HEIGHT");
michael@0 39 if (height) {
michael@0 40 benchmark_height_ = atoi(height); // NOLINT
michael@0 41 }
michael@0 42 benchmark_pixels_div256_ = static_cast<int>((
michael@0 43 static_cast<double>(Abs(benchmark_width_)) *
michael@0 44 static_cast<double>(Abs(benchmark_height_)) *
michael@0 45 static_cast<double>(benchmark_iterations_) + 255.0) / 256.0);
michael@0 46 benchmark_pixels_div1280_ = static_cast<int>((
michael@0 47 static_cast<double>(Abs(benchmark_width_)) *
michael@0 48 static_cast<double>(Abs(benchmark_height_)) *
michael@0 49 static_cast<double>(benchmark_iterations_) + 1279.0) / 1280.0);
michael@0 50 }
michael@0 51
michael@0 52 int main(int argc, char** argv) {
michael@0 53 ::testing::InitGoogleTest(&argc, argv);
michael@0 54 return RUN_ALL_TESTS();
michael@0 55 }

mercurial