Commit 94312b69 authored by Frank Barchard's avatar Frank Barchard

add gflags support files from webrtc

files needed for command line support with gtest.
These files are copied directly from webrtc.

TBR=kjellander@chromium.org
BUG=libyuv:507

Review URL: https://codereview.chromium.org/1414483002 .
parent 8dcec019
Name: libyuv Name: libyuv
URL: http://code.google.com/p/libyuv/ URL: http://code.google.com/p/libyuv/
Version: 1513 Version: 1514
License: BSD License: BSD
License File: LICENSE License File: LICENSE
......
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 1513 #define LIBYUV_VERSION 1514
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
...@@ -18,6 +18,15 @@ ...@@ -18,6 +18,15 @@
'dependencies': [ 'dependencies': [
'libyuv.gyp:libyuv', 'libyuv.gyp:libyuv',
'testing/gtest.gyp:gtest', 'testing/gtest.gyp:gtest',
'third_party/gflags/gflags.gyp:gflags',
],
'direct_dependent_settings': {
'defines': [
'GTEST_RELATIVE_PATH',
],
},
'export_dependent_settings': [
'<(DEPTH)/testing/gtest.gyp:gtest',
], ],
'defines': [ 'defines': [
# Enable the following 3 macros to turn off assembly for specified CPU. # Enable the following 3 macros to turn off assembly for specified CPU.
......
...@@ -14,37 +14,59 @@ ...@@ -14,37 +14,59 @@
#include <cstring> #include <cstring>
#include "gflags/gflags.h"
#include "testing/gtest/include/gtest/gtest.h"
// Change this to 1000 for benchmarking. // Change this to 1000 for benchmarking.
// TODO(fbarchard): Add command line parsing to pass this as option. // TODO(fbarchard): Add command line parsing to pass this as option.
#define BENCHMARK_ITERATIONS 1 #define BENCHMARK_ITERATIONS 1
int fastrand_seed = 0xfb; int fastrand_seed = 0xfb;
DEFINE_int32(libyuv_width, 0, "width of test image.");
DEFINE_int32(libyuv_height, 0, "height of test image.");
DEFINE_int32(libyuv_repeat, 0, "number of times to repeat test.");
DEFINE_int32(libyuv_flags, 0, "cpu flags for reference code. 0 = C -1 = asm");
// For quicker unittests, default is 128 x 72. But when benchmarking,
// default to 720p. Allow size to specify.
// Set flags to -1 for benchmarking to avoid slower C code.
LibYUVConvertTest::LibYUVConvertTest() : LibYUVConvertTest::LibYUVConvertTest() :
benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128), benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128),
benchmark_height_(72), disable_cpu_flags_(0) { benchmark_height_(72), disable_cpu_flags_(0) {
const char* repeat = getenv("LIBYUV_REPEAT"); const char* repeat = getenv("LIBYUV_REPEAT");
if (repeat) { if (repeat) {
benchmark_iterations_ = atoi(repeat); // NOLINT benchmark_iterations_ = atoi(repeat); // NOLINT
// For quicker unittests, default is 128 x 72. But when benchmarking, }
// default to 720p. Allow size to specify. if (FLAGS_libyuv_repeat) {
benchmark_iterations_ = FLAGS_libyuv_repeat;
}
if (benchmark_iterations_ > 1) { if (benchmark_iterations_ > 1) {
benchmark_width_ = 1280; benchmark_width_ = 1280;
benchmark_height_ = 720; benchmark_height_ = 720;
} }
}
const char* width = getenv("LIBYUV_WIDTH"); const char* width = getenv("LIBYUV_WIDTH");
if (width) { if (width) {
benchmark_width_ = atoi(width); // NOLINT benchmark_width_ = atoi(width); // NOLINT
} }
if (FLAGS_libyuv_width) {
benchmark_width_ = FLAGS_libyuv_width;
}
const char* height = getenv("LIBYUV_HEIGHT"); const char* height = getenv("LIBYUV_HEIGHT");
if (height) { if (height) {
benchmark_height_ = atoi(height); // NOLINT benchmark_height_ = atoi(height); // NOLINT
} }
if (FLAGS_libyuv_height) {
benchmark_height_ = FLAGS_libyuv_height;
}
const char* cpu_flags = getenv("LIBYUV_FLAGS"); const char* cpu_flags = getenv("LIBYUV_FLAGS");
if (cpu_flags) { if (cpu_flags) {
disable_cpu_flags_ = atoi(cpu_flags); // NOLINT disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
} }
if (FLAGS_libyuv_flags) {
disable_cpu_flags_ = FLAGS_libyuv_flags;
}
benchmark_pixels_div256_ = static_cast<int>(( benchmark_pixels_div256_ = static_cast<int>((
static_cast<double>(Abs(benchmark_width_)) * static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) * static_cast<double>(Abs(benchmark_height_)) *
...@@ -61,25 +83,35 @@ LibYUVColorTest::LibYUVColorTest() : ...@@ -61,25 +83,35 @@ LibYUVColorTest::LibYUVColorTest() :
const char* repeat = getenv("LIBYUV_REPEAT"); const char* repeat = getenv("LIBYUV_REPEAT");
if (repeat) { if (repeat) {
benchmark_iterations_ = atoi(repeat); // NOLINT benchmark_iterations_ = atoi(repeat); // NOLINT
// For quicker unittests, default is 128 x 72. But when benchmarking, }
// default to 720p. Allow size to specify. if (FLAGS_libyuv_repeat) {
benchmark_iterations_ = FLAGS_libyuv_repeat;
}
if (benchmark_iterations_ > 1) { if (benchmark_iterations_ > 1) {
benchmark_width_ = 1280; benchmark_width_ = 1280;
benchmark_height_ = 720; benchmark_height_ = 720;
} }
}
const char* width = getenv("LIBYUV_WIDTH"); const char* width = getenv("LIBYUV_WIDTH");
if (width) { if (width) {
benchmark_width_ = atoi(width); // NOLINT benchmark_width_ = atoi(width); // NOLINT
} }
if (FLAGS_libyuv_width) {
benchmark_width_ = FLAGS_libyuv_width;
}
const char* height = getenv("LIBYUV_HEIGHT"); const char* height = getenv("LIBYUV_HEIGHT");
if (height) { if (height) {
benchmark_height_ = atoi(height); // NOLINT benchmark_height_ = atoi(height); // NOLINT
} }
if (FLAGS_libyuv_height) {
benchmark_height_ = FLAGS_libyuv_height;
}
const char* cpu_flags = getenv("LIBYUV_FLAGS"); const char* cpu_flags = getenv("LIBYUV_FLAGS");
if (cpu_flags) { if (cpu_flags) {
disable_cpu_flags_ = atoi(cpu_flags); // NOLINT disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
} }
if (FLAGS_libyuv_flags) {
disable_cpu_flags_ = FLAGS_libyuv_flags;
}
benchmark_pixels_div256_ = static_cast<int>(( benchmark_pixels_div256_ = static_cast<int>((
static_cast<double>(Abs(benchmark_width_)) * static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) * static_cast<double>(Abs(benchmark_height_)) *
...@@ -96,25 +128,35 @@ LibYUVScaleTest::LibYUVScaleTest() : ...@@ -96,25 +128,35 @@ LibYUVScaleTest::LibYUVScaleTest() :
const char* repeat = getenv("LIBYUV_REPEAT"); const char* repeat = getenv("LIBYUV_REPEAT");
if (repeat) { if (repeat) {
benchmark_iterations_ = atoi(repeat); // NOLINT benchmark_iterations_ = atoi(repeat); // NOLINT
// For quicker unittests, default is 128 x 72. But when benchmarking, }
// default to 720p. Allow size to specify. if (FLAGS_libyuv_repeat) {
benchmark_iterations_ = FLAGS_libyuv_repeat;
}
if (benchmark_iterations_ > 1) { if (benchmark_iterations_ > 1) {
benchmark_width_ = 1280; benchmark_width_ = 1280;
benchmark_height_ = 720; benchmark_height_ = 720;
} }
}
const char* width = getenv("LIBYUV_WIDTH"); const char* width = getenv("LIBYUV_WIDTH");
if (width) { if (width) {
benchmark_width_ = atoi(width); // NOLINT benchmark_width_ = atoi(width); // NOLINT
} }
if (FLAGS_libyuv_width) {
benchmark_width_ = FLAGS_libyuv_width;
}
const char* height = getenv("LIBYUV_HEIGHT"); const char* height = getenv("LIBYUV_HEIGHT");
if (height) { if (height) {
benchmark_height_ = atoi(height); // NOLINT benchmark_height_ = atoi(height); // NOLINT
} }
if (FLAGS_libyuv_height) {
benchmark_height_ = FLAGS_libyuv_height;
}
const char* cpu_flags = getenv("LIBYUV_FLAGS"); const char* cpu_flags = getenv("LIBYUV_FLAGS");
if (cpu_flags) { if (cpu_flags) {
disable_cpu_flags_ = atoi(cpu_flags); // NOLINT disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
} }
if (FLAGS_libyuv_flags) {
disable_cpu_flags_ = FLAGS_libyuv_flags;
}
benchmark_pixels_div256_ = static_cast<int>(( benchmark_pixels_div256_ = static_cast<int>((
static_cast<double>(Abs(benchmark_width_)) * static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) * static_cast<double>(Abs(benchmark_height_)) *
...@@ -131,25 +173,35 @@ LibYUVRotateTest::LibYUVRotateTest() : ...@@ -131,25 +173,35 @@ LibYUVRotateTest::LibYUVRotateTest() :
const char* repeat = getenv("LIBYUV_REPEAT"); const char* repeat = getenv("LIBYUV_REPEAT");
if (repeat) { if (repeat) {
benchmark_iterations_ = atoi(repeat); // NOLINT benchmark_iterations_ = atoi(repeat); // NOLINT
// For quicker unittests, default is 128 x 72. But when benchmarking, }
// default to 720p. Allow size to specify. if (FLAGS_libyuv_repeat) {
benchmark_iterations_ = FLAGS_libyuv_repeat;
}
if (benchmark_iterations_ > 1) { if (benchmark_iterations_ > 1) {
benchmark_width_ = 1280; benchmark_width_ = 1280;
benchmark_height_ = 720; benchmark_height_ = 720;
} }
}
const char* width = getenv("LIBYUV_WIDTH"); const char* width = getenv("LIBYUV_WIDTH");
if (width) { if (width) {
benchmark_width_ = atoi(width); // NOLINT benchmark_width_ = atoi(width); // NOLINT
} }
if (FLAGS_libyuv_width) {
benchmark_width_ = FLAGS_libyuv_width;
}
const char* height = getenv("LIBYUV_HEIGHT"); const char* height = getenv("LIBYUV_HEIGHT");
if (height) { if (height) {
benchmark_height_ = atoi(height); // NOLINT benchmark_height_ = atoi(height); // NOLINT
} }
if (FLAGS_libyuv_height) {
benchmark_height_ = FLAGS_libyuv_height;
}
const char* cpu_flags = getenv("LIBYUV_FLAGS"); const char* cpu_flags = getenv("LIBYUV_FLAGS");
if (cpu_flags) { if (cpu_flags) {
disable_cpu_flags_ = atoi(cpu_flags); // NOLINT disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
} }
if (FLAGS_libyuv_flags) {
disable_cpu_flags_ = FLAGS_libyuv_flags;
}
benchmark_pixels_div256_ = static_cast<int>(( benchmark_pixels_div256_ = static_cast<int>((
static_cast<double>(Abs(benchmark_width_)) * static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) * static_cast<double>(Abs(benchmark_height_)) *
...@@ -166,25 +218,35 @@ LibYUVPlanarTest::LibYUVPlanarTest() : ...@@ -166,25 +218,35 @@ LibYUVPlanarTest::LibYUVPlanarTest() :
const char* repeat = getenv("LIBYUV_REPEAT"); const char* repeat = getenv("LIBYUV_REPEAT");
if (repeat) { if (repeat) {
benchmark_iterations_ = atoi(repeat); // NOLINT benchmark_iterations_ = atoi(repeat); // NOLINT
// For quicker unittests, default is 128 x 72. But when benchmarking, }
// default to 720p. Allow size to specify. if (FLAGS_libyuv_repeat) {
benchmark_iterations_ = FLAGS_libyuv_repeat;
}
if (benchmark_iterations_ > 1) { if (benchmark_iterations_ > 1) {
benchmark_width_ = 1280; benchmark_width_ = 1280;
benchmark_height_ = 720; benchmark_height_ = 720;
} }
}
const char* width = getenv("LIBYUV_WIDTH"); const char* width = getenv("LIBYUV_WIDTH");
if (width) { if (width) {
benchmark_width_ = atoi(width); // NOLINT benchmark_width_ = atoi(width); // NOLINT
} }
if (FLAGS_libyuv_width) {
benchmark_width_ = FLAGS_libyuv_width;
}
const char* height = getenv("LIBYUV_HEIGHT"); const char* height = getenv("LIBYUV_HEIGHT");
if (height) { if (height) {
benchmark_height_ = atoi(height); // NOLINT benchmark_height_ = atoi(height); // NOLINT
} }
if (FLAGS_libyuv_height) {
benchmark_height_ = FLAGS_libyuv_height;
}
const char* cpu_flags = getenv("LIBYUV_FLAGS"); const char* cpu_flags = getenv("LIBYUV_FLAGS");
if (cpu_flags) { if (cpu_flags) {
disable_cpu_flags_ = atoi(cpu_flags); // NOLINT disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
} }
if (FLAGS_libyuv_flags) {
disable_cpu_flags_ = FLAGS_libyuv_flags;
}
benchmark_pixels_div256_ = static_cast<int>(( benchmark_pixels_div256_ = static_cast<int>((
static_cast<double>(Abs(benchmark_width_)) * static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) * static_cast<double>(Abs(benchmark_height_)) *
...@@ -201,25 +263,35 @@ LibYUVBaseTest::LibYUVBaseTest() : ...@@ -201,25 +263,35 @@ LibYUVBaseTest::LibYUVBaseTest() :
const char* repeat = getenv("LIBYUV_REPEAT"); const char* repeat = getenv("LIBYUV_REPEAT");
if (repeat) { if (repeat) {
benchmark_iterations_ = atoi(repeat); // NOLINT benchmark_iterations_ = atoi(repeat); // NOLINT
// For quicker unittests, default is 128 x 72. But when benchmarking, }
// default to 720p. Allow size to specify. if (FLAGS_libyuv_repeat) {
benchmark_iterations_ = FLAGS_libyuv_repeat;
}
if (benchmark_iterations_ > 1) { if (benchmark_iterations_ > 1) {
benchmark_width_ = 1280; benchmark_width_ = 1280;
benchmark_height_ = 720; benchmark_height_ = 720;
} }
}
const char* width = getenv("LIBYUV_WIDTH"); const char* width = getenv("LIBYUV_WIDTH");
if (width) { if (width) {
benchmark_width_ = atoi(width); // NOLINT benchmark_width_ = atoi(width); // NOLINT
} }
if (FLAGS_libyuv_width) {
benchmark_width_ = FLAGS_libyuv_width;
}
const char* height = getenv("LIBYUV_HEIGHT"); const char* height = getenv("LIBYUV_HEIGHT");
if (height) { if (height) {
benchmark_height_ = atoi(height); // NOLINT benchmark_height_ = atoi(height); // NOLINT
} }
if (FLAGS_libyuv_height) {
benchmark_height_ = FLAGS_libyuv_height;
}
const char* cpu_flags = getenv("LIBYUV_FLAGS"); const char* cpu_flags = getenv("LIBYUV_FLAGS");
if (cpu_flags) { if (cpu_flags) {
disable_cpu_flags_ = atoi(cpu_flags); // NOLINT disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
} }
if (FLAGS_libyuv_flags) {
disable_cpu_flags_ = FLAGS_libyuv_flags;
}
benchmark_pixels_div256_ = static_cast<int>(( benchmark_pixels_div256_ = static_cast<int>((
static_cast<double>(Abs(benchmark_width_)) * static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) * static_cast<double>(Abs(benchmark_height_)) *
...@@ -232,5 +304,6 @@ LibYUVBaseTest::LibYUVBaseTest() : ...@@ -232,5 +304,6 @@ LibYUVBaseTest::LibYUVBaseTest() :
int main(int argc, char** argv) { int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
google::ParseCommandLineFlags(&argc, &argv, true);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment