diff --git a/README.chromium b/README.chromium index 4f28a759f..796af58aa 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 1250 +Version: 1251 License: BSD License File: LICENSE diff --git a/include/libyuv/row.h b/include/libyuv/row.h index b83e89389..e4c1e7711 100644 --- a/include/libyuv/row.h +++ b/include/libyuv/row.h @@ -121,8 +121,7 @@ extern "C" { #define HAS_UYVYTOUV422ROW_SSE2 #define HAS_UYVYTOUVROW_SSE2 #define HAS_UYVYTOYROW_SSE2 -// Fix YToARGB. bug=392 -// #define HAS_YTOARGBROW_SSE2 +#define HAS_YTOARGBROW_SSE2 #define HAS_YUY2TOARGBROW_SSSE3 #define HAS_YUY2TOUV422ROW_SSE2 #define HAS_YUY2TOUVROW_SSE2 diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 845901726..c1f9b6bb6 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 1250 +#define LIBYUV_VERSION 1251 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/source/row_common.cc b/source/row_common.cc index 0204298d1..61e0e6ca1 100644 --- a/source/row_common.cc +++ b/source/row_common.cc @@ -961,19 +961,20 @@ void I400ToARGBRow_C(const uint8* src_y, uint8* dst_argb, int width) { } // YUV to RGB conversion constants. +// Y contribution to R,G,B. Scale and bias. #define YG 19071 /* round(1.164 * 64 * 256) */ #define YGB 1197 /* 1.164 * 64 * 16 - adjusted for even error distribution */ + +// U and V contributions to R,G,B. #define UB -128 /* -min(128, round(2.018 * 64)) */ -#define UBB -16385 /* approx -round(2.018 * 64 * 128) */ #define UG 25 /* -round(-0.391 * 64) */ -#define UGB 3200 /* -round(-0.391 * 64) * 128 */ #define VG 52 /* -round(-0.813 * 64) */ -#define VGB 6656 /* -round(-0.813 * 64) * 128 */ #define VR -102 /* -round(1.596 * 64) */ -#define VRB -13056 /* -round(1.596 * 64) * 128 */ -#define BB (UBB - YGB) -#define BG (UGB + VGB - YGB) -#define BR ( VRB - YGB) + +// Bias values to subtract 16 from Y and 128 from U and V. +#define BB (UB * 128 - YGB) +#define BG (UG * 128 + VG * 128 - YGB) +#define BR ( VR * 128 - YGB) // C reference code that mimics the YUV assembly. static __inline void YuvPixel(uint8 y, uint8 u, uint8 v, @@ -983,16 +984,21 @@ static __inline void YuvPixel(uint8 y, uint8 u, uint8 v, *g = Clamp((int32)(BG - (v * VG + u * UG) + y1) >> 6); *r = Clamp((int32)(BR - (v * VR ) + y1) >> 6); } + +// C reference code that mimics the YUV assembly. +static __inline void YPixel(uint8 y, uint8* b, uint8* g, uint8* r) { + uint32 y1 = (uint32)(y * 0x0101 * YG) >> 16; + *b = Clamp((int32)(-YGB + y1) >> 6); + *g = Clamp((int32)(-YGB + y1) >> 6); + *r = Clamp((int32)(-YGB + y1) >> 6); +} + #undef YG #undef YGB #undef UB -#undef UBB #undef UG -#undef UGB #undef VG -#undef VGB #undef VR -#undef VRB #undef BB #undef BG #undef BR @@ -1558,18 +1564,15 @@ void I422ToRGBARow_C(const uint8* src_y, void YToARGBRow_C(const uint8* src_y, uint8* rgb_buf, int width) { int x; for (x = 0; x < width - 1; x += 2) { - YuvPixel(src_y[0], 128, 128, - rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); + YPixel(src_y[0], rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); rgb_buf[3] = 255; - YuvPixel(src_y[1], 128, 128, - rgb_buf + 4, rgb_buf + 5, rgb_buf + 6); + YPixel(src_y[1], rgb_buf + 4, rgb_buf + 5, rgb_buf + 6); rgb_buf[7] = 255; src_y += 2; rgb_buf += 8; // Advance 2 pixels. } if (width & 1) { - YuvPixel(src_y[0], 128, 128, - rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); + YPixel(src_y[0], rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); rgb_buf[3] = 255; } } diff --git a/source/row_posix.cc b/source/row_posix.cc index 0c0de1860..6f30dbbfb 100644 --- a/source/row_posix.cc +++ b/source/row_posix.cc @@ -1,3 +1,4 @@ +// VERSION 1 /* * Copyright 2011 The LibYuv Project Authors. All rights reserved. * @@ -1520,19 +1521,20 @@ void RGBAToUVRow_SSSE3(const uint8* src_rgba0, int src_stride_rgba, #ifdef HAS_I422TOARGBROW_SSSE3 // YUV to RGB conversion constants. +// Y contribution to R,G,B. Scale and bias. #define YG 19071 /* round(1.164 * 64 * 256) */ #define YGB 1197 /* 1.164 * 64 * 16 - adjusted for even error distribution */ + +// U and V contributions to R,G,B. #define UB -128 /* -min(128, round(2.018 * 64)) */ -#define UBB -16385 /* approx -round(2.018 * 64 * 128) */ #define UG 25 /* -round(-0.391 * 64) */ -#define UGB 3200 /* -round(-0.391 * 64) * 128 */ #define VG 52 /* -round(-0.813 * 64) */ -#define VGB 6656 /* -round(-0.813 * 64) * 128 */ #define VR -102 /* -round(1.596 * 64) */ -#define VRB -13056 /* -round(1.596 * 64) * 128 */ -#define BB (UBB - YGB) -#define BG (UGB + VGB - YGB) -#define BR ( VRB - YGB) + +// Bias values to subtract 16 from Y and 128 from U and V. +#define BB (UB * 128 - YGB) +#define BG (UG * 128 + VG * 128 - YGB) +#define BR ( VR * 128 - YGB) struct { vec8 kUVToB; // 0 @@ -2083,11 +2085,11 @@ struct { "vpmaddubsw " MEMACCESS2(32, [kYuvConstants]) ",%%ymm0,%%ymm1 \n" \ "vpmaddubsw " MEMACCESS([kYuvConstants]) ",%%ymm0,%%ymm0 \n" \ "vmovdqu " MEMACCESS2(160, [kYuvConstants]) ",%%ymm3 \n" \ - "vpsubw %%ymm3,%%ymm2,%%ymm2 \n" \ + "vpsubw %%ymm2,%%ymm3,%%ymm2 \n" \ "vmovdqu " MEMACCESS2(128, [kYuvConstants]) ",%%ymm2 \n" \ - "vpsubw %%ymm2,%%ymm1,%%ymm1 \n" \ + "vpsubw %%ymm1,%%ymm2,%%ymm1 \n" \ "vmovdqu " MEMACCESS2(96, [kYuvConstants]) ",%%ymm1 \n" \ - "vpsubw %%ymm1,%%ymm0,%%ymm0 \n" \ + "vpsubw %%ymm0,%%ymm1,%%ymm0 \n" \ "vmovdqu " MEMACCESS([y_buf]) ",%%xmm3 \n" \ "lea " MEMLEA(0x10, [y_buf]) ",%[y_buf] \n" \ "vpermq $0xd8,%%ymm3,%%ymm3 \n" \ diff --git a/source/row_win.cc b/source/row_win.cc index 4f9025165..c7abc001f 100644 --- a/source/row_win.cc +++ b/source/row_win.cc @@ -25,19 +25,20 @@ extern "C" { (defined(_M_IX86) || defined(_M_X64)) // YUV to RGB conversion constants. +// Y contribution to R,G,B. Scale and bias. #define YG 19071 /* round(1.164 * 64 * 256) */ #define YGB 1197 /* 1.164 * 64 * 16 - adjusted for even error distribution */ + +// U and V contributions to R,G,B. #define UB -128 /* -min(128, round(2.018 * 64)) */ -#define UBB -16385 /* approx -round(2.018 * 64 * 128) */ #define UG 25 /* -round(-0.391 * 64) */ -#define UGB 3200 /* -round(-0.391 * 64) * 128 */ #define VG 52 /* -round(-0.813 * 64) */ -#define VGB 6656 /* -round(-0.813 * 64) * 128 */ #define VR -102 /* -round(1.596 * 64) */ -#define VRB -13056 /* -round(1.596 * 64) * 128 */ -#define BB (UBB - YGB) -#define BG (UGB + VGB - YGB) -#define BR ( VRB - YGB) + +// Bias values to subtract 16 from Y and 128 from U and V. +#define BB (UB * 128 - YGB) +#define BG (UG * 128 + VG * 128 - YGB) +#define BR ( VR * 128 - YGB) static const vec8 kUVToB = { UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0