aboutsummaryrefslogtreecommitdiff
path: root/files/source
diff options
context:
space:
mode:
authorFrank Barchard <fbarchard@google.com>2017-04-18 11:28:09 -0700
committerFrank Barchard <fbarchard@google.com>2017-04-18 11:28:09 -0700
commitb33a82ffd059f362574ae038458e8dee26ac5a4a (patch)
tree4231a1eec8b9833c69cf6c906f03be758edd4bd3 /files/source
parentcead1e07666bcc5914f8927712c2f89b9b789f9b (diff)
downloadlibyuv-b33a82ffd059f362574ae038458e8dee26ac5a4a.tar.gz
libyuv roll to r1652 for new I422ToRGB565 function
Bug: none Test: I422ToRGB565 unittest Change-Id: I8b4418badf725d3ecb6735effcb782976b27979b
Diffstat (limited to 'files/source')
-rw-r--r--files/source/convert_from.cc69
-rw-r--r--files/source/rotate_win.cc11
-rw-r--r--files/source/row_any.cc55
3 files changed, 102 insertions, 33 deletions
diff --git a/files/source/convert_from.cc b/files/source/convert_from.cc
index ab5afc06..d623731d 100644
--- a/files/source/convert_from.cc
+++ b/files/source/convert_from.cc
@@ -890,6 +890,75 @@ int I420ToRGB565(const uint8* src_y,
return 0;
}
+// Convert I422 to RGB565.
+LIBYUV_API
+int I422ToRGB565(const uint8* src_y,
+ int src_stride_y,
+ const uint8* src_u,
+ int src_stride_u,
+ const uint8* src_v,
+ int src_stride_v,
+ uint8* dst_rgb565,
+ int dst_stride_rgb565,
+ int width,
+ int height) {
+ int y;
+ void (*I422ToRGB565Row)(const uint8* y_buf, const uint8* u_buf,
+ const uint8* v_buf, uint8* rgb_buf,
+ const struct YuvConstants* yuvconstants, int width) =
+ I422ToRGB565Row_C;
+ if (!src_y || !src_u || !src_v || !dst_rgb565 || width <= 0 || height == 0) {
+ return -1;
+ }
+ // Negative height means invert the image.
+ if (height < 0) {
+ height = -height;
+ dst_rgb565 = dst_rgb565 + (height - 1) * dst_stride_rgb565;
+ dst_stride_rgb565 = -dst_stride_rgb565;
+ }
+#if defined(HAS_I422TORGB565ROW_SSSE3)
+ if (TestCpuFlag(kCpuHasSSSE3)) {
+ I422ToRGB565Row = I422ToRGB565Row_Any_SSSE3;
+ if (IS_ALIGNED(width, 8)) {
+ I422ToRGB565Row = I422ToRGB565Row_SSSE3;
+ }
+ }
+#endif
+#if defined(HAS_I422TORGB565ROW_AVX2)
+ if (TestCpuFlag(kCpuHasAVX2)) {
+ I422ToRGB565Row = I422ToRGB565Row_Any_AVX2;
+ if (IS_ALIGNED(width, 16)) {
+ I422ToRGB565Row = I422ToRGB565Row_AVX2;
+ }
+ }
+#endif
+#if defined(HAS_I422TORGB565ROW_NEON)
+ if (TestCpuFlag(kCpuHasNEON)) {
+ I422ToRGB565Row = I422ToRGB565Row_Any_NEON;
+ if (IS_ALIGNED(width, 8)) {
+ I422ToRGB565Row = I422ToRGB565Row_NEON;
+ }
+ }
+#endif
+#if defined(HAS_I422TORGB565ROW_MSA)
+ if (TestCpuFlag(kCpuHasMSA)) {
+ I422ToRGB565Row = I422ToRGB565Row_Any_MSA;
+ if (IS_ALIGNED(width, 8)) {
+ I422ToRGB565Row = I422ToRGB565Row_MSA;
+ }
+ }
+#endif
+
+ for (y = 0; y < height; ++y) {
+ I422ToRGB565Row(src_y, src_u, src_v, dst_rgb565, &kYuvI601Constants, width);
+ dst_rgb565 += dst_stride_rgb565;
+ src_y += src_stride_y;
+ src_u += src_stride_u;
+ src_v += src_stride_v;
+ }
+ return 0;
+}
+
// Ordered 8x8 dither for 888 to 565. Values from 0 to 7.
static const uint8 kDither565_4x4[16] = {
0, 4, 1, 5, 6, 2, 7, 3, 1, 5, 0, 4, 7, 3, 6, 2,
diff --git a/files/source/rotate_win.cc b/files/source/rotate_win.cc
index 044048d3..93a5c28a 100644
--- a/files/source/rotate_win.cc
+++ b/files/source/rotate_win.cc
@@ -137,9 +137,9 @@ __declspec(naked) void TransposeUVWx8_SSE2(const uint8* src,
mov ecx, [ecx + 16 + 28] // w
align 4
- convertloop:
- // Read in the data from the source pointer.
- // First round of bit swap.
+ // Read in the data from the source pointer.
+ // First round of bit swap.
+ convertloop:
movdqu xmm0, [eax]
movdqu xmm1, [eax + edi]
lea eax, [eax + 2 * edi]
@@ -166,7 +166,7 @@ __declspec(naked) void TransposeUVWx8_SSE2(const uint8* src,
lea eax, [eax + 2 * edi]
movdqu [esp], xmm5 // backup xmm5
neg edi
- movdqa xmm5, xmm6 // use xmm5 as temp register.
+ movdqa xmm5, xmm6 // use xmm5 as temp register.
punpcklbw xmm6, xmm7
punpckhbw xmm5, xmm7
movdqa xmm7, xmm5
@@ -187,10 +187,11 @@ __declspec(naked) void TransposeUVWx8_SSE2(const uint8* src,
movdqa xmm6, xmm5
movdqu xmm5, [esp] // restore xmm5
movdqu [esp], xmm6 // backup xmm6
- movdqa xmm6, xmm5 // use xmm6 as temp register.
+ movdqa xmm6, xmm5 // use xmm6 as temp register.
punpcklwd xmm5, xmm7
punpckhwd xmm6, xmm7
movdqa xmm7, xmm6
+
// Third round of bit swap.
// Write to the destination pointer.
movdqa xmm6, xmm0
diff --git a/files/source/row_any.cc b/files/source/row_any.cc
index af5d1fbc..1092a9c0 100644
--- a/files/source/row_any.cc
+++ b/files/source/row_any.cc
@@ -158,13 +158,13 @@ ANY31C(I422ToRGBARow_Any_AVX2, I422ToRGBARow_AVX2, 1, 0, 4, 15)
ANY31C(I444ToARGBRow_Any_AVX2, I444ToARGBRow_AVX2, 0, 0, 4, 15)
#endif
#ifdef HAS_I422TOARGB4444ROW_AVX2
-ANY31C(I422ToARGB4444Row_Any_AVX2, I422ToARGB4444Row_AVX2, 1, 0, 2, 7)
+ANY31C(I422ToARGB4444Row_Any_AVX2, I422ToARGB4444Row_AVX2, 1, 0, 2, 15)
#endif
#ifdef HAS_I422TOARGB1555ROW_AVX2
-ANY31C(I422ToARGB1555Row_Any_AVX2, I422ToARGB1555Row_AVX2, 1, 0, 2, 7)
+ANY31C(I422ToARGB1555Row_Any_AVX2, I422ToARGB1555Row_AVX2, 1, 0, 2, 15)
#endif
#ifdef HAS_I422TORGB565ROW_AVX2
-ANY31C(I422ToRGB565Row_Any_AVX2, I422ToRGB565Row_AVX2, 1, 0, 2, 7)
+ANY31C(I422ToRGB565Row_Any_AVX2, I422ToRGB565Row_AVX2, 1, 0, 2, 15)
#endif
#ifdef HAS_I422TOARGBROW_NEON
ANY31C(I444ToARGBRow_Any_NEON, I444ToARGBRow_NEON, 0, 0, 4, 7)
@@ -654,18 +654,18 @@ ANY11B(ARGBCopyYToAlphaRow_Any_SSE2, ARGBCopyYToAlphaRow_SSE2, 0, 1, 4, 7)
#undef ANY11B
// Any 1 to 1 with parameter.
-#define ANY11P(NAMEANY, ANY_SIMD, T, SBPP, BPP, MASK) \
- void NAMEANY(const uint8* src_ptr, uint8* dst_ptr, T shuffler, int width) { \
- SIMD_ALIGNED(uint8 temp[64 * 2]); \
- memset(temp, 0, 64); /* for msan */ \
- int r = width & MASK; \
- int n = width & ~MASK; \
- if (n > 0) { \
- ANY_SIMD(src_ptr, dst_ptr, shuffler, n); \
- } \
- memcpy(temp, src_ptr + n * SBPP, r * SBPP); \
- ANY_SIMD(temp, temp + 64, shuffler, MASK + 1); \
- memcpy(dst_ptr + n * BPP, temp + 64, r * BPP); \
+#define ANY11P(NAMEANY, ANY_SIMD, T, SBPP, BPP, MASK) \
+ void NAMEANY(const uint8* src_ptr, uint8* dst_ptr, T param, int width) { \
+ SIMD_ALIGNED(uint8 temp[64 * 2]); \
+ memset(temp, 0, 64); /* for msan */ \
+ int r = width & MASK; \
+ int n = width & ~MASK; \
+ if (n > 0) { \
+ ANY_SIMD(src_ptr, dst_ptr, param, n); \
+ } \
+ memcpy(temp, src_ptr + n * SBPP, r * SBPP); \
+ ANY_SIMD(temp, temp + 64, param, MASK + 1); \
+ memcpy(dst_ptr + n * BPP, temp + 64, r * BPP); \
}
#if defined(HAS_ARGBTORGB565DITHERROW_SSE2)
@@ -718,19 +718,18 @@ ANY11P(ARGBShuffleRow_Any_MSA, ARGBShuffleRow_MSA, const uint8*, 4, 4, 7)
#undef ANY11P
// Any 1 to 1 with parameter and shorts. BPP measures in shorts.
-#define ANY11P16(NAMEANY, ANY_SIMD, T, SBPP, BPP, MASK) \
- void NAMEANY(const uint16* src_ptr, uint16* dst_ptr, T shuffler, \
- int width) { \
- SIMD_ALIGNED(uint16 temp[16 * 2]); \
- memset(temp, 0, 32); /* for msan */ \
- int r = width & MASK; \
- int n = width & ~MASK; \
- if (n > 0) { \
- ANY_SIMD(src_ptr, dst_ptr, shuffler, n); \
- } \
- memcpy(temp, src_ptr + n, r * SBPP); \
- ANY_SIMD(temp, temp + 16, shuffler, MASK + 1); \
- memcpy(dst_ptr + n, temp + 16, r * BPP); \
+#define ANY11P16(NAMEANY, ANY_SIMD, T, SBPP, BPP, MASK) \
+ void NAMEANY(const uint16* src_ptr, uint16* dst_ptr, T param, int width) { \
+ SIMD_ALIGNED(uint16 temp[16 * 2]); \
+ memset(temp, 0, 32); /* for msan */ \
+ int r = width & MASK; \
+ int n = width & ~MASK; \
+ if (n > 0) { \
+ ANY_SIMD(src_ptr, dst_ptr, param, n); \
+ } \
+ memcpy(temp, src_ptr + n, r * SBPP); \
+ ANY_SIMD(temp, temp + 16, param, MASK + 1); \
+ memcpy(dst_ptr + n, temp + 16, r * BPP); \
}
#ifdef HAS_HALFFLOATROW_SSE2