From ceee491c24cc649ebb61c77326794d4e8674366e Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Wed, 9 Jan 2013 05:30:08 +0000 Subject: [PATCH] move READWORD and WRITEWORD into row_common along with row functions that use them BUG=171 TEST=still builds Review URL: https://webrtc-codereview.appspot.com/1021008 git-svn-id: http://libyuv.googlecode.com/svn/trunk@528 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/row.h | 21 ++----------- include/libyuv/version.h | 2 +- source/convert.cc | 29 ----------------- source/convert_from.cc | 20 ------------ source/row_common.cc | 68 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 73 insertions(+), 69 deletions(-) diff --git a/README.chromium b/README.chromium index ab8a83040..2c3c131f5 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 527 +Version: 528 License: BSD License File: LICENSE diff --git a/include/libyuv/row.h b/include/libyuv/row.h index 0b96c74c8..b9a0abcbc 100644 --- a/include/libyuv/row.h +++ b/include/libyuv/row.h @@ -22,24 +22,6 @@ extern "C" { #define kMaxStride (2880 * 4) #define IS_ALIGNED(p, a) (!((uintptr_t)(p) & ((a) - 1))) -#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 - #if defined(__CLR_VER) || defined(COVERAGE_ENABLED) || \ defined(TARGET_IPHONE_SIMULATOR) #define YUV_DISABLE_ASM @@ -1297,6 +1279,9 @@ void ARGBInterpolateRow_NEON(uint8* dst_argb, const uint8* src_argb, ptrdiff_t src_stride_argb, int dst_width, int source_y_fraction); +void UYVYToV210Row_C(const uint8* src_uyvy, uint8* dst_v210, int width); +void V210ToUYVYRow_C(const uint8* src_v210, uint8* dst_uyvy, int width); + #ifdef __cplusplus } // extern "C" } // namespace libyuv diff --git a/include/libyuv/version.h b/include/libyuv/version.h index a3227f480..ca0d0c01f 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 527 +#define LIBYUV_VERSION 528 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/source/convert.cc b/source/convert.cc index d40f90b1b..ff7445d10 100644 --- a/source/convert.cc +++ b/source/convert.cc @@ -692,35 +692,6 @@ int UYVYToI420(const uint8* src_uyvy, int src_stride_uyvy, return 0; } -// 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) { - for (int x = 0; x < width; x += 6) { - uint32 w = READWORD(src_v210 + 0); - dst_uyvy[0] = (w >> 2) & 0xff; - dst_uyvy[1] = (w >> 12) & 0xff; - dst_uyvy[2] = (w >> 22) & 0xff; - - w = READWORD(src_v210 + 4); - dst_uyvy[3] = (w >> 2) & 0xff; - dst_uyvy[4] = (w >> 12) & 0xff; - dst_uyvy[5] = (w >> 22) & 0xff; - - w = READWORD(src_v210 + 8); - dst_uyvy[6] = (w >> 2) & 0xff; - dst_uyvy[7] = (w >> 12) & 0xff; - dst_uyvy[8] = (w >> 22) & 0xff; - - w = READWORD(src_v210 + 12); - dst_uyvy[9] = (w >> 2) & 0xff; - dst_uyvy[10] = (w >> 12) & 0xff; - dst_uyvy[11] = (w >> 22) & 0xff; - - src_v210 += 16; - dst_uyvy += 12; - } -} - // Convert V210 to I420. // V210 is 10 bit version of UYVY. 16 bytes to store 6 pixels. // Width is multiple of 48 pixels = 128 bytes. diff --git a/source/convert_from.cc b/source/convert_from.cc index fba0513cc..33c9fed63 100644 --- a/source/convert_from.cc +++ b/source/convert_from.cc @@ -210,26 +210,6 @@ int I400Copy(const uint8* src_y, int src_stride_y, return 0; } -#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) { - WRITEWORD(dst_v210 + 0, (EIGHTTOTEN(src_uyvy[0])) | - (EIGHTTOTEN(src_uyvy[1]) << 10) | - (EIGHTTOTEN(src_uyvy[2]) << 20)); - WRITEWORD(dst_v210 + 4, (EIGHTTOTEN(src_uyvy[3])) | - (EIGHTTOTEN(src_uyvy[4]) << 10) | - (EIGHTTOTEN(src_uyvy[5]) << 20)); - WRITEWORD(dst_v210 + 8, (EIGHTTOTEN(src_uyvy[6])) | - (EIGHTTOTEN(src_uyvy[7]) << 10) | - (EIGHTTOTEN(src_uyvy[8]) << 20)); - WRITEWORD(dst_v210 + 12, (EIGHTTOTEN(src_uyvy[9])) | - (EIGHTTOTEN(src_uyvy[10]) << 10) | - (EIGHTTOTEN(src_uyvy[11]) << 20)); - src_uyvy += 12; - dst_v210 += 16; - } -} - LIBYUV_API int I422ToYUY2(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, diff --git a/source/row_common.cc b/source/row_common.cc index 0a30281a0..19e2e112b 100644 --- a/source/row_common.cc +++ b/source/row_common.cc @@ -19,6 +19,45 @@ namespace libyuv { extern "C" { #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 + +#define EIGHTTOTEN(x) (x << 2 | x >> 6) +void UYVYToV210Row_C(const uint8* src_uyvy, uint8* dst_v210, int width) { + for (int x = 0; x < width; x += 6) { + WRITEWORD(dst_v210 + 0, (EIGHTTOTEN(src_uyvy[0])) | + (EIGHTTOTEN(src_uyvy[1]) << 10) | + (EIGHTTOTEN(src_uyvy[2]) << 20)); + WRITEWORD(dst_v210 + 4, (EIGHTTOTEN(src_uyvy[3])) | + (EIGHTTOTEN(src_uyvy[4]) << 10) | + (EIGHTTOTEN(src_uyvy[5]) << 20)); + WRITEWORD(dst_v210 + 8, (EIGHTTOTEN(src_uyvy[6])) | + (EIGHTTOTEN(src_uyvy[7]) << 10) | + (EIGHTTOTEN(src_uyvy[8]) << 20)); + WRITEWORD(dst_v210 + 12, (EIGHTTOTEN(src_uyvy[9])) | + (EIGHTTOTEN(src_uyvy[10]) << 10) | + (EIGHTTOTEN(src_uyvy[11]) << 20)); + src_uyvy += 12; + dst_v210 += 16; + } +} +#undef EIGHTTOTEN + void BGRAToARGBRow_C(const uint8* src_bgra, uint8* dst_argb, int width) { for (int x = 0; x < width; ++x) { // To support in-place conversion. @@ -1750,6 +1789,35 @@ void UYVYToARGBRow_Unaligned_SSSE3(const uint8* src_uyvy, #endif // defined(_M_IX86) || defined(__x86_64__) || defined(__i386__) #endif // !defined(YUV_DISABLE_ASM) +// Must be multiple of 6 pixels. Will over convert to handle remainder. +// https://developer.apple.com/quicktime/icefloe/dispatch019.html#v210 +void V210ToUYVYRow_C(const uint8* src_v210, uint8* dst_uyvy, int width) { + for (int x = 0; x < width; x += 6) { + uint32 w = READWORD(src_v210 + 0); + dst_uyvy[0] = (w >> 2) & 0xff; + dst_uyvy[1] = (w >> 12) & 0xff; + dst_uyvy[2] = (w >> 22) & 0xff; + + w = READWORD(src_v210 + 4); + dst_uyvy[3] = (w >> 2) & 0xff; + dst_uyvy[4] = (w >> 12) & 0xff; + dst_uyvy[5] = (w >> 22) & 0xff; + + w = READWORD(src_v210 + 8); + dst_uyvy[6] = (w >> 2) & 0xff; + dst_uyvy[7] = (w >> 12) & 0xff; + dst_uyvy[8] = (w >> 22) & 0xff; + + w = READWORD(src_v210 + 12); + dst_uyvy[9] = (w >> 2) & 0xff; + dst_uyvy[10] = (w >> 12) & 0xff; + dst_uyvy[11] = (w >> 22) & 0xff; + + src_v210 += 16; + dst_uyvy += 12; + } +} + #ifdef __cplusplus } // extern "C" } // namespace libyuv