From d3728d92220d86fe76837c9002d2e2c8a7caab21 Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Thu, 25 Oct 2012 17:12:41 +0000 Subject: [PATCH] unittest simplify loop counter BUG=none TEST=planar unittests Review URL: https://webrtc-codereview.appspot.com/935006 git-svn-id: http://libyuv.googlecode.com/svn/trunk@443 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- Android.mk | 2 +- README.chromium | 2 +- include/libyuv/version.h | 2 +- unit_test/convert_test.cc | 2 +- unit_test/planar_test.cc | 52 +++++++++------------------------------ unit_test/unit_test.cc | 2 ++ unit_test/unit_test.h | 1 + 7 files changed, 19 insertions(+), 44 deletions(-) diff --git a/Android.mk b/Android.mk index 56b2439ce..00d029a1e 100644 --- a/Android.mk +++ b/Android.mk @@ -27,7 +27,7 @@ LOCAL_SRC_FILES := \ source/video_common.cc \ # TODO(fbarchard): Enable mjpeg encoder. -# source/mjpeg_decoder.cc +# source/mjpeg_decoder.cc ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) LOCAL_CFLAGS += -DLIBYUV_NEON diff --git a/README.chromium b/README.chromium index bf118aa13..72734456d 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 442 +Version: 443 License: BSD License File: LICENSE diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 6d0cd8a44..df9a3e297 100644 --- a/include/libyuv/version.h +++ b/include/libyuv/version.h @@ -11,6 +11,6 @@ #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #define INCLUDE_LIBYUV_VERSION_H_ -#define LIBYUV_VERSION 442 +#define LIBYUV_VERSION 443 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/unit_test/convert_test.cc b/unit_test/convert_test.cc index 0d7089ea8..e58d1201d 100644 --- a/unit_test/convert_test.cc +++ b/unit_test/convert_test.cc @@ -756,7 +756,7 @@ TESTATOBRANDOM(ARGB, 4, 4, RGB565, 2, 2, 0) TESTATOBRANDOM(ARGB, 4, 4, ARGB1555, 2, 2, 0) TESTATOBRANDOM(ARGB, 4, 4, ARGB4444, 2, 2, 0) TESTATOBRANDOM(ARGB, 4, 4, I400, 1, 1, 2) -// TODO(fbarchard, 0): Implement YUY2 +// TODO(fbarchard): Implement YUY2 // TESTATOBRANDOM(ARGB, 4, 4, YUY2, 4, 2, 0) // TESTATOBRANDOM(ARGB, 4, 4, UYVY, 4, 2, 0) TESTATOBRANDOM(BGRA, 4, 4, ARGB, 4, 4, 0) diff --git a/unit_test/planar_test.cc b/unit_test/planar_test.cc index 37f47809d..a13fcbabf 100644 --- a/unit_test/planar_test.cc +++ b/unit_test/planar_test.cc @@ -80,9 +80,7 @@ TEST_F(libyuvTest, TestAttenuate) { } ARGBAttenuate(&orig_pixels[0][0], 0, &atten_pixels[0][0], 0, 256, 1); ARGBUnattenuate(&atten_pixels[0][0], 0, &unatten_pixels[0][0], 0, 256, 1); - const int count = benchmark_iterations_ * - benchmark_width_ * benchmark_height_ / 256; - for (int i = 0; i < count; ++i) { + for (int i = 0; i < benchmark_pixels_div256_; ++i) { ARGBAttenuate(&unatten_pixels[0][0], 0, &atten2_pixels[0][0], 0, 256, 1); } for (int i = 0; i < 256; ++i) { @@ -181,9 +179,7 @@ TEST_F(libyuvTest, TestARGBGray) { orig_pixels[i][2] = i / 3; orig_pixels[i][3] = i; } - const int count = benchmark_iterations_ * - benchmark_width_ * benchmark_height_ / 256; - for (int i = 0; i < count; ++i) { + for (int i = 0; i < benchmark_pixels_div256_; ++i) { ARGBGray(&orig_pixels[0][0], 0, 0, 0, 256, 1); } } @@ -237,10 +233,7 @@ TEST_F(libyuvTest, TestARGBGrayTo) { orig_pixels[i][2] = i / 3; orig_pixels[i][3] = i; } - - const int count = benchmark_iterations_ * - benchmark_width_ * benchmark_height_ / 256; - for (int i = 0; i < count; ++i) { + for (int i = 0; i < benchmark_pixels_div256_; ++i) { ARGBGrayTo(&orig_pixels[0][0], 0, &gray_pixels[0][0], 0, 256, 1); } } @@ -293,10 +286,7 @@ TEST_F(libyuvTest, TestARGBSepia) { orig_pixels[i][2] = i / 3; orig_pixels[i][3] = i; } - - const int count = benchmark_iterations_ * - benchmark_width_ * benchmark_height_ / 256; - for (int i = 0; i < count; ++i) { + for (int i = 0; i < benchmark_pixels_div256_; ++i) { ARGBSepia(&orig_pixels[0][0], 0, 0, 0, 256, 1); } } @@ -356,10 +346,7 @@ TEST_F(libyuvTest, TestARGBColorMatrix) { orig_pixels[i][2] = i / 3; orig_pixels[i][3] = i; } - - const int count = benchmark_iterations_ * - benchmark_width_ * benchmark_height_ / 256; - for (int i = 0; i < count; ++i) { + for (int i = 0; i < benchmark_pixels_div256_; ++i) { ARGBColorMatrix(&orig_pixels[0][0], 0, &kARGBToSepia[0], 0, 0, 256, 1); } } @@ -417,10 +404,7 @@ TEST_F(libyuvTest, TestARGBColorTable) { orig_pixels[i][2] = i / 3; orig_pixels[i][3] = i; } - - const int count = benchmark_iterations_ * - benchmark_width_ * benchmark_height_ / 256; - for (int i = 0; i < count; ++i) { + for (int i = 0; i < benchmark_pixels_div256_; ++i) { ARGBColorTable(&orig_pixels[0][0], 0, &kARGBTable[0], 0, 0, 256, 1); } } @@ -443,9 +427,7 @@ TEST_F(libyuvTest, TestARGBQuantize) { EXPECT_EQ(i / 3 / 8 * 8 + 8 / 2, orig_pixels[i][2]); EXPECT_EQ(i, orig_pixels[i][3]); } - const int count = benchmark_iterations_ * - benchmark_width_ * benchmark_height_ / 256; - for (int i = 0; i < count; ++i) { + for (int i = 0; i < benchmark_pixels_div256_; ++i) { ARGBQuantize(&orig_pixels[0][0], 0, (65536 + (8 / 2)) / 8, 8, 8 / 2, 0, 0, 256, 1); } @@ -469,9 +451,7 @@ TEST_F(libyuvTest, TestARGBMirror) { EXPECT_EQ(i / 3, dst_pixels[255 - i][2]); EXPECT_EQ(i / 4, dst_pixels[255 - i][3]); } - const int count = benchmark_iterations_ * - benchmark_width_ * benchmark_height_ / 256; - for (int i = 0; i < count; ++i) { + for (int i = 0; i < benchmark_pixels_div256_; ++i) { ARGBMirror(&orig_pixels[0][0], 0, &dst_pixels[0][0], 0, 256, 1); } } @@ -520,9 +500,7 @@ TEST_F(libyuvTest, TestShade) { EXPECT_EQ(20u, shade_pixels[0][2]); EXPECT_EQ(40u, shade_pixels[0][3]); - const int count = benchmark_iterations_ * - benchmark_width_ * benchmark_height_ / 256; - for (int i = 0; i < count; ++i) { + for (int i = 0; i < benchmark_pixels_div256_; ++i) { ARGBShade(&orig_pixels[0][0], 0, &shade_pixels[0][0], 0, 256, 1, 0x80808080); } @@ -601,9 +579,7 @@ TEST_F(libyuvTest, TestInterpolate) { EXPECT_EQ(16u, interpolate_pixels[0][2]); EXPECT_EQ(32u, interpolate_pixels[0][3]); - const int count = benchmark_iterations_ * - benchmark_width_ * benchmark_height_ / 256; - for (int i = 0; i < count; ++i) { + for (int i = 0; i < benchmark_pixels_div256_; ++i) { ARGBInterpolate(&orig_pixels_0[0][0], 0, &orig_pixels_1[0][0], 0, &interpolate_pixels[0][0], 0, 256, 1, 128); } @@ -639,17 +615,13 @@ TEST_F(libyuvTest, TestAffine) { #if defined(HAS_ARGBAFFINEROW_SSE2) int has_sse2 = TestCpuFlag(kCpuHasSSE2); if (has_sse2) { - const int count = benchmark_iterations_ * - benchmark_width_ * benchmark_height_ / 256; - for (int i = 0; i < count; ++i) { + for (int i = 0; i < benchmark_pixels_div256_; ++i) { ARGBAffineRow_SSE2(&orig_pixels_0[0][0], 0, &interpolate_pixels_Opt[0][0], uv_step, 256); } } else { #endif - const int count = benchmark_iterations_ * - benchmark_width_ * benchmark_height_ / 256; - for (int i = 0; i < count; ++i) { + for (int i = 0; i < benchmark_pixels_div256_; ++i) { ARGBAffineRow_C(&orig_pixels_0[0][0], 0, &interpolate_pixels_C[0][0], uv_step, 256); } diff --git a/unit_test/unit_test.cc b/unit_test/unit_test.cc index b0b06e3ff..62700f3ab 100644 --- a/unit_test/unit_test.cc +++ b/unit_test/unit_test.cc @@ -39,6 +39,8 @@ libyuvTest::libyuvTest() : rotate_max_w_(128), rotate_max_h_(128), if (height) { benchmark_height_ = atoi(height); // NOLINT } + benchmark_pixels_div256_ = (benchmark_iterations_ * benchmark_width_ * + benchmark_height_ + 255) / 256; } int main(int argc, char** argv) { diff --git a/unit_test/unit_test.h b/unit_test/unit_test.h index b81623bca..fdcb0d273 100644 --- a/unit_test/unit_test.h +++ b/unit_test/unit_test.h @@ -69,6 +69,7 @@ class libyuvTest : public ::testing::Test { int benchmark_iterations_; // Default 1. Use 1000 for benchmarking. int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA. int benchmark_height_; // Default 720. Use 360 for benchmarking VGA. + int benchmark_pixels_div256_; // Total pixels to benchmark / 256. }; #endif // UNIT_TEST_UNIT_TEST_H_