From 693e0217c850fa35d75674579c94dcb79cab78ba Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Mon, 2 Mar 2015 23:46:09 +0000 Subject: [PATCH] ARGBToRGB565 C version use unsigned dither matrix pattern to bump pixels to next brighter value. BUG=407 TESTED=unittest passes R=harryjin@google.com Review URL: https://webrtc-codereview.appspot.com/43539004 git-svn-id: http://libyuv.googlecode.com/svn/trunk@1306 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/version.h | 2 +- source/row_common.cc | 24 ++++++++++++------------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.chromium b/README.chromium index f582843e5..e16953bea 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 1305 +Version: 1306 License: BSD License File: LICENSE diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 9236a7fa1..2c996980c 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 1305 +#define LIBYUV_VERSION 1306 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/source/row_common.cc b/source/row_common.cc index e0e2bf426..cd881351c 100644 --- a/source/row_common.cc +++ b/source/row_common.cc @@ -203,24 +203,24 @@ void ARGBToRGB565DitherRow_C(const uint8* src_argb, uint8* dst_rgb, const uint8* dither8x8, int width) { int x; for (x = 0; x < width - 1; x += 2) { - int dither0 = dither8x8[x & 7] - 128; - int dither1 = dither8x8[(x & 7) + 1] - 128; - uint8 b0 = Clamp(src_argb[0] + dither0) >> 3; - uint8 g0 = Clamp(src_argb[1] + dither0) >> 2; - uint8 r0 = Clamp(src_argb[2] + dither0) >> 3; - uint8 b1 = Clamp(src_argb[4] + dither1) >> 3; - uint8 g1 = Clamp(src_argb[5] + dither1) >> 2; - uint8 r1 = Clamp(src_argb[6] + dither1) >> 3; + int dither0 = dither8x8[x & 7]; + int dither1 = dither8x8[(x + 1) & 7]; + uint8 b0 = clamp255(src_argb[0] + dither0) >> 3; + uint8 g0 = clamp255(src_argb[1] + dither0) >> 2; + uint8 r0 = clamp255(src_argb[2] + dither0) >> 3; + uint8 b1 = clamp255(src_argb[4] + dither1) >> 3; + uint8 g1 = clamp255(src_argb[5] + dither1) >> 2; + uint8 r1 = clamp255(src_argb[6] + dither1) >> 3; WRITEWORD(dst_rgb, b0 | (g0 << 5) | (r0 << 11) | (b1 << 16) | (g1 << 21) | (r1 << 27)); dst_rgb += 4; src_argb += 8; } if (width & 1) { - int dither0 = dither8x8[(width - 1) & 7] - 128; - uint8 b0 = Clamp(src_argb[0] + dither0) >> 3; - uint8 g0 = Clamp(src_argb[1] + dither0) >> 2; - uint8 r0 = Clamp(src_argb[2] + dither0) >> 3; + int dither0 = dither8x8[(width - 1) & 7]; + uint8 b0 = clamp255(src_argb[0] + dither0) >> 3; + uint8 g0 = clamp255(src_argb[1] + dither0) >> 2; + uint8 r0 = clamp255(src_argb[2] + dither0) >> 3; *(uint16*)(dst_rgb) = b0 | (g0 << 5) | (r0 << 11); } }