Speed up rounding to byte test

R=harryjin@google.com
BUG=libyuv:492

Review URL: https://codereview.chromium.org/1367403007 .
This commit is contained in:
Frank Barchard 2015-10-02 15:27:13 -07:00
parent 3eefeaeb69
commit f4c1ac10f0
3 changed files with 11 additions and 13 deletions

View File

@ -1,6 +1,6 @@
Name: libyuv Name: libyuv
URL: http://code.google.com/p/libyuv/ URL: http://code.google.com/p/libyuv/
Version: 1497 Version: 1499
License: BSD License: BSD
License File: LICENSE License File: LICENSE

View File

@ -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 1497 #define LIBYUV_VERSION 1499
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT

View File

@ -223,13 +223,13 @@ static void YJToRGB(int y, int* r, int* g, int* b) {
} }
// Pick a method for clamping. // Pick a method for clamping.
#define CLAMPMETHOD_IF 1 // #define CLAMPMETHOD_IF 1
// #define CLAMPMETHOD_TABLE 1 // #define CLAMPMETHOD_TABLE 1
// #define CLAMPMETHOD_TERNARY 1 #define CLAMPMETHOD_TERNARY 1
// #define CLAMPMETHOD_MASK 1 // #define CLAMPMETHOD_MASK 1
// Pick a method for rounding. // Pick a method for rounding.
#define ROUND(f) static_cast<int>(f + 0.5) #define ROUND(f) static_cast<int>(f + 0.5f)
// #define ROUND(f) lrintf(f) // #define ROUND(f) lrintf(f)
// #define ROUND(f) static_cast<int>(round(f)) // #define ROUND(f) static_cast<int>(round(f))
// #define ROUND(f) _mm_cvt_ss2si(_mm_load_ss(&f)) // #define ROUND(f) _mm_cvt_ss2si(_mm_load_ss(&f))
@ -314,17 +314,15 @@ static int RoundToByte(float f) {
TEST_F(libyuvTest, TestRoundToByte) { TEST_F(libyuvTest, TestRoundToByte) {
int allb = 0; int allb = 0;
int count = benchmark_width_ * benchmark_height_;
for (int i = 0; i < benchmark_iterations_; ++i) { for (int i = 0; i < benchmark_iterations_; ++i) {
for (int u2 = 0; u2 < 256; ++u2) { float f = (fastrand() & 255) * 3.14f - 260.f;
for (int v2 = 0; v2 < 256; ++v2) { for (int j = 0; j < count; ++j) {
for (int y2 = 0; y2 < 256; ++y2) { int b = RoundToByte(f);
int y = RANDOM256(y2); f += 0.91f;
int b = RoundToByte(y * 810.33 - 257);
allb |= b; allb |= b;
} }
} }
}
}
EXPECT_GE(allb, 0); EXPECT_GE(allb, 0);
EXPECT_LE(allb, 255); EXPECT_LE(allb, 255);
} }