From 3ae19cb83416af2d0fbcb3e23db2fffcd54e027b Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Mon, 7 Jan 2013 06:50:53 +0000 Subject: [PATCH] Make 565 use big endian consistent read/write word for s390. BUG=171 TESTED=unittests on x86 not impacted. Review URL: https://webrtc-codereview.appspot.com/1022006 git-svn-id: http://libyuv.googlecode.com/svn/trunk@524 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/basic_types.h | 26 ++++++++++++++++++++++++++ include/libyuv/version.h | 2 +- source/convert.cc | 19 ------------------- source/convert_from.cc | 19 ------------------- source/row_common.cc | 5 ++--- 6 files changed, 30 insertions(+), 43 deletions(-) diff --git a/README.chromium b/README.chromium index 116572585..c90241c19 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 522 +Version: 524 License: BSD License File: LICENSE diff --git a/include/libyuv/basic_types.h b/include/libyuv/basic_types.h index 19a24ef8f..cf6cc3389 100644 --- a/include/libyuv/basic_types.h +++ b/include/libyuv/basic_types.h @@ -96,4 +96,30 @@ typedef signed char int8; #endif // __GNUC__ #endif // LIBYUV_API +// Visual C x86 or GCC little endian. +#if defined(__x86_64__) || defined(_M_X64) || \ + defined(__i386__) || defined(_M_IX86) || \ + defined(__arm__) || defined(_M_ARM) || \ + (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) +#define LIBYUV_LITTLE_ENDIAN +#endif + +#ifdef LIBYUV_LITTLE_ENDIAN +#define READWORD(p) (*reinterpret_cast(p)) +#define WRITEWORD(p, v) *reinterpret_cast(p) = v +#else +static inline uint32 READWORD(const uint8* p) { + return static_cast(p[0]) | + (static_cast(p[1]) << 8) | + (static_cast(p[2]) << 16) | + (static_cast(p[3]) << 24); +} +static inline void WRITEWORD(uint8* p, uint32 v) { + p[0] = (uint8)(v & 255); + p[1] = (uint8)((v >> 8) & 255); + p[2] = (uint8)((v >> 16) & 255); + p[3] = (uint8)((v >> 24) & 255); +} +#endif + #endif // INCLUDE_LIBYUV_BASIC_TYPES_H_ NOLINT diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 9b4f6c672..8f5b253d2 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 522 +#define LIBYUV_VERSION 524 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/source/convert.cc b/source/convert.cc index 866a6644d..d40f90b1b 100644 --- a/source/convert.cc +++ b/source/convert.cc @@ -692,25 +692,6 @@ int UYVYToI420(const uint8* src_uyvy, int src_stride_uyvy, return 0; } -// Visual C x86 or GCC little endian. -#if defined(__x86_64__) || defined(_M_X64) || \ - defined(__i386__) || defined(_M_IX86) || \ - defined(__arm__) || defined(_M_ARM) || \ - (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) -#define LIBYUV_LITTLE_ENDIAN -#endif - -#ifdef LIBYUV_LITTLE_ENDIAN -#define READWORD(p) (*reinterpret_cast(p)) -#else -static inline uint32 READWORD(const uint8* p) { - return static_cast(p[0]) | - (static_cast(p[1]) << 8) | - (static_cast(p[2]) << 16) | - (static_cast(p[3]) << 24); -} -#endif - // Must be multiple of 6 pixels. Will over convert to handle remainder. // https://developer.apple.com/quicktime/icefloe/dispatch019.html#v210 static void V210ToUYVYRow_C(const uint8* src_v210, uint8* dst_uyvy, int width) { diff --git a/source/convert_from.cc b/source/convert_from.cc index d89e606de..fba0513cc 100644 --- a/source/convert_from.cc +++ b/source/convert_from.cc @@ -210,25 +210,6 @@ int I400Copy(const uint8* src_y, int src_stride_y, return 0; } -// Visual C x86 or GCC little endian. -#if defined(__x86_64__) || defined(_M_X64) || \ - defined(__i386__) || defined(_M_IX86) || \ - defined(__arm__) || defined(_M_ARM) || \ - (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) -#define LIBYUV_LITTLE_ENDIAN -#endif - -#ifdef LIBYUV_LITTLE_ENDIAN -#define WRITEWORD(p, v) *reinterpret_cast(p) = v -#else -static inline void WRITEWORD(uint8* p, uint32 v) { - p[0] = (uint8)(v & 255); - p[1] = (uint8)((v >> 8) & 255); - p[2] = (uint8)((v >> 16) & 255); - p[3] = (uint8)((v >> 24) & 255); -} -#endif - #define EIGHTTOTEN(x) (x << 2 | x >> 6) static void UYVYToV210Row_C(const uint8* src_uyvy, uint8* dst_v210, int width) { for (int x = 0; x < width; x += 6) { diff --git a/source/row_common.cc b/source/row_common.cc index fb769aa31..0a30281a0 100644 --- a/source/row_common.cc +++ b/source/row_common.cc @@ -182,7 +182,6 @@ void ARGBToRAWRow_C(const uint8* src_argb, uint8* dst_rgb, int width) { } } -// TODO(fbarchard): support big endian CPU void ARGBToRGB565Row_C(const uint8* src_argb, uint8* dst_rgb, int width) { for (int x = 0; x < width - 1; x += 2) { uint8 b0 = src_argb[0] >> 3; @@ -191,8 +190,8 @@ void ARGBToRGB565Row_C(const uint8* src_argb, uint8* dst_rgb, int width) { uint8 b1 = src_argb[4] >> 3; uint8 g1 = src_argb[5] >> 2; uint8 r1 = src_argb[6] >> 3; - *reinterpret_cast(dst_rgb) = b0 | (g0 << 5) | (r0 << 11) | - (b1 << 16) | (g1 << 21) | (r1 << 27); + WRITEWORD(dst_rgb, b0 | (g0 << 5) | (r0 << 11) | + (b1 << 16) | (g1 << 21) | (r1 << 27)); dst_rgb += 4; src_argb += 8; }