From f5a7b2b48aae65a0527b587f93aefc9590999d2f Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Wed, 11 Mar 2015 00:08:56 +0000 Subject: [PATCH] I411ToARGB AVX2 version BUG=403 TESTED=I411ToARGB unittest R=harryjin@google.com Review URL: https://webrtc-codereview.appspot.com/42689004 git-svn-id: http://libyuv.googlecode.com/svn/trunk@1321 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/row.h | 11 ++++++++++ include/libyuv/version.h | 2 +- source/convert_argb.cc | 8 +++++++ source/row_any.cc | 3 +++ source/row_win.cc | 47 +++++++++++++++++++++++++++++++++++++++- 6 files changed, 70 insertions(+), 3 deletions(-) diff --git a/README.chromium b/README.chromium index e5bb1d0ef..9b1a417c1 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 1320 +Version: 1321 License: BSD License File: LICENSE diff --git a/include/libyuv/row.h b/include/libyuv/row.h index cbd0200ef..be8cf6177 100644 --- a/include/libyuv/row.h +++ b/include/libyuv/row.h @@ -199,6 +199,7 @@ extern "C" { #define HAS_I422TOARGB1555ROW_AVX2 #define HAS_I422TOARGB4444ROW_AVX2 #define HAS_I444TOARGBROW_AVX2 +#define HAS_I411TOARGBROW_AVX2 // TODO(fbarchard): Port to Neon #define HAS_ARGBTORGB565DITHERROW_SSE2 #define HAS_ARGBTORGB565DITHERROW_AVX2 @@ -1061,6 +1062,11 @@ void I411ToARGBRow_SSSE3(const uint8* src_y, const uint8* src_v, uint8* dst_argb, int width); +void I411ToARGBRow_AVX2(const uint8* src_y, + const uint8* src_u, + const uint8* src_v, + uint8* dst_argb, + int width); void NV12ToARGBRow_SSSE3(const uint8* src_y, const uint8* src_uv, uint8* dst_argb, @@ -1205,6 +1211,11 @@ void I411ToARGBRow_Any_SSSE3(const uint8* src_y, const uint8* src_v, uint8* dst_argb, int width); +void I411ToARGBRow_Any_AVX2(const uint8* src_y, + const uint8* src_u, + const uint8* src_v, + uint8* dst_argb, + int width); void NV12ToARGBRow_Any_SSSE3(const uint8* src_y, const uint8* src_uv, uint8* dst_argb, diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 44dfe37f1..3557bc6a9 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 1320 +#define LIBYUV_VERSION 1321 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/source/convert_argb.cc b/source/convert_argb.cc index beb6543ca..5ce2fd590 100644 --- a/source/convert_argb.cc +++ b/source/convert_argb.cc @@ -230,6 +230,14 @@ int I411ToARGB(const uint8* src_y, int src_stride_y, } } #endif +#if defined(HAS_I411TOARGBROW_AVX2) + if (TestCpuFlag(kCpuHasAVX2)) { + I411ToARGBRow = I411ToARGBRow_Any_AVX2; + if (IS_ALIGNED(width, 16)) { + I411ToARGBRow = I411ToARGBRow_AVX2; + } + } +#endif #if defined(HAS_I411TOARGBROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { I411ToARGBRow = I411ToARGBRow_Any_NEON; diff --git a/source/row_any.cc b/source/row_any.cc index 84d8d0632..216c995bc 100644 --- a/source/row_any.cc +++ b/source/row_any.cc @@ -76,6 +76,9 @@ YANY(I422ToABGRRow_Any_AVX2, I422ToABGRRow_AVX2, I422ToABGRRow_C, 1, 4, 15) #ifdef HAS_I444TOARGBROW_AVX2 YANY(I444ToARGBRow_Any_AVX2, I444ToARGBRow_AVX2, I444ToARGBRow_C, 0, 4, 15) #endif +#ifdef HAS_I411TOARGBROW_AVX2 +YANY(I411ToARGBRow_Any_AVX2, I411ToARGBRow_AVX2, I411ToARGBRow_C, 2, 4, 15) +#endif #ifdef HAS_I422TOARGB4444ROW_AVX2 YANY(I422ToARGB4444Row_Any_AVX2, I422ToARGB4444Row_AVX2, I422ToARGB4444Row_C, 1, 2, 7) diff --git a/source/row_win.cc b/source/row_win.cc index 93ee58240..a98728d34 100644 --- a/source/row_win.cc +++ b/source/row_win.cc @@ -1698,6 +1698,17 @@ void RGBAToUVRow_SSSE3(const uint8* src_argb0, int src_stride_argb, __asm vpunpcklwd ymm0, ymm0, ymm0 /* UVUV (upsample) */ \ } +// Read 4 UV from 411, upsample to 16 UV. +#define READYUV411_AVX2 __asm { \ + __asm vmovd xmm0, dword ptr [esi] /* U */ /* NOLINT */ \ + __asm vmovd xmm1, dword ptr [esi + edi] /* V */ /* NOLINT */ \ + __asm lea esi, [esi + 4] \ + __asm vpunpcklbw ymm0, ymm0, ymm1 /* UV */ \ + __asm vpunpcklwd ymm0, ymm0, ymm0 /* UVUV (upsample) */ \ + __asm vpermq ymm0, ymm0, 0xd8 \ + __asm vpunpckldq ymm0, ymm0, ymm0 /* UVUVUVUV (upsample) */ \ + } + // Read 8 UV from NV12, upsample to 16 UV. #define READNV12_AVX2 __asm { \ __asm vmovdqu xmm0, [esi] /* UV */ \ @@ -1821,7 +1832,41 @@ void I444ToARGBRow_AVX2(const uint8* y_buf, } #endif // HAS_I444TOARGBROW_AVX2 +#ifdef HAS_I411TOARGBROW_AVX2 +// 16 pixels +// 4 UV values upsampled to 16 UV, mixed with 16 Y producing 16 ARGB (64 bytes). +__declspec(naked) __declspec(align(16)) +void I411ToARGBRow_AVX2(const uint8* y_buf, + const uint8* u_buf, + const uint8* v_buf, + uint8* dst_argb, + int width) { + __asm { + push esi + push edi + mov eax, [esp + 8 + 4] // Y + mov esi, [esp + 8 + 8] // U + mov edi, [esp + 8 + 12] // V + mov edx, [esp + 8 + 16] // argb + mov ecx, [esp + 8 + 20] // width + sub edi, esi + vpcmpeqb ymm5, ymm5, ymm5 // generate 0xffffffffffffffff for alpha + convertloop: + READYUV411_AVX2 + YUVTORGB_AVX2(kYuvConstants) + STOREARGB_AVX2 + + sub ecx, 16 + jg convertloop + + pop edi + pop esi + vzeroupper + ret + } +} +#endif // HAS_I411TOARGBROW_AVX2 #ifdef HAS_NV12TOARGBROW_AVX2 // 16 pixels. @@ -2050,7 +2095,7 @@ void I422ToABGRRow_AVX2(const uint8* y_buf, __asm lea esi, [esi + 2] \ __asm punpcklbw xmm0, xmm1 /* UV */ \ __asm punpcklwd xmm0, xmm0 /* UVUV (upsample) */ \ - __asm punpckldq xmm0, xmm0 /* UVUV (upsample) */ \ + __asm punpckldq xmm0, xmm0 /* UVUVUVUV (upsample) */ \ } // Read 4 UV from NV12, upsample to 8 UV.