diff --git a/README.chromium b/README.chromium index ca263b20c..f020f8f79 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 1324 +Version: 1325 License: BSD License File: LICENSE diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 698aab5a9..aa6383167 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 1324 +#define LIBYUV_VERSION 1325 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/unit_test/color_test.cc b/unit_test/color_test.cc index 4f7c27fb6..04a22a331 100644 --- a/unit_test/color_test.cc +++ b/unit_test/color_test.cc @@ -185,10 +185,19 @@ static void YToRGB(int y, int* r, int* g, int* b) { // Pick a method for clamping. #define CLAMPMETHOD_IF 1 +//#define CLAMPMETHOD_TABLE 1 +//#define CLAMPMETHOD_TERNARY 1 +//#define CLAMPMETHOD_MASK 1 + +// Pick a method for rounding. +#define ROUND(f) static_cast(f + 0.5) +//#define ROUND(f) lrintf(f) +//#define ROUND(f) static_cast(round(f)) +//#define ROUND(f) _mm_cvt_ss2si(_mm_load_ss(&f)) #if defined(CLAMPMETHOD_IF) -static int RoundToByte(double f) { - int i = static_cast(f + 0.5); +static int RoundToByte(float f) { + int i = ROUND(f); if (i < 0) { i = 0; } @@ -246,28 +255,22 @@ static const unsigned char clamptable[811] = { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }; -static int RoundToByte(double f) { - return clamptable[static_cast(f + 0.5) + 276]; +static int RoundToByte(float f) { + return clamptable[ROUND(f) + 276]; } #elif defined(CLAMPMETHOD_TERNARY) static int RoundToByte(float f) { - int i = static_cast(f + 0.5); + int i = ROUND(f); return (i < 0) ? 0 : ((i > 255) ? 255 : i); } #elif defined(CLAMPMETHOD_MASK) static int RoundToByte(float f) { - int i = static_cast(f + 0.5); + int i = ROUND(f); i = ((-(i) >> 31) & (i)); // clamp to 0. return (((255 - (i)) >> 31) | (i)) & 255; // clamp to 255. } #endif -static void YUVToRGBReference(int y, int u, int v, int* r, int* g, int* b) { - *r = RoundToByte((y - 16) * 1.164 + (v - 128) * 1.596); - *g = RoundToByte((y - 16) * 1.164 + (u - 128) * -0.391 + (v - 128) * -0.813); - *b = RoundToByte((y - 16) * 1.164 + (u - 128) * 2.018); -} - #define RANDOM256(s) ((s & 1) ? ((s >> 1) ^ 0xb8) : (s >> 1)) TEST_F(libyuvTest, TestRoundToByte) { @@ -287,6 +290,12 @@ TEST_F(libyuvTest, TestRoundToByte) { EXPECT_LE(allb, 255); } +static void YUVToRGBReference(int y, int u, int v, int* r, int* g, int* b) { + *r = RoundToByte((y - 16) * 1.164 + (v - 128) * 1.596); + *g = RoundToByte((y - 16) * 1.164 + (u - 128) * -0.391 + (v - 128) * -0.813); + *b = RoundToByte((y - 16) * 1.164 + (u - 128) * 2.018); +} + TEST_F(libyuvTest, TestYUV) { int r0, g0, b0, r1, g1, b1;