From db7a7f61ff2446598a74e51d37c8e90aa25201d5 Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Wed, 19 Nov 2014 20:03:37 +0000 Subject: [PATCH] Port ARGBMirror AVX2 code to gcc/NaCL. BUG=269 TESTED=try bots R=harryjin@google.com Review URL: https://webrtc-codereview.appspot.com/24329004 git-svn-id: http://libyuv.googlecode.com/svn/trunk@1173 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/row.h | 2 +- include/libyuv/version.h | 2 +- source/row_posix.cc | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/README.chromium b/README.chromium index 5f8f18156..353524298 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 1171 +Version: 1172 License: BSD License File: LICENSE diff --git a/include/libyuv/row.h b/include/libyuv/row.h index 329321949..b2059a619 100644 --- a/include/libyuv/row.h +++ b/include/libyuv/row.h @@ -200,6 +200,7 @@ extern "C" { #define HAS_SPLITUVROW_AVX2 #define HAS_MERGEUVROW_AVX2 #define HAS_MIRRORROW_AVX2 +#define HAS_ARGBMIRRORROW_AVX2 // Effects: #define HAS_ARGBADDROW_AVX2 @@ -212,7 +213,6 @@ extern "C" { // The following are require VS2012. // TODO(fbarchard): Port to gcc. #if !defined(LIBYUV_DISABLE_X86) && defined(VISUALC_HAS_AVX2) -#define HAS_ARGBMIRRORROW_AVX2 #define HAS_ARGBTOUVROW_AVX2 #define HAS_ARGBTOYJROW_AVX2 #define HAS_ARGBTOYROW_AVX2 diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 231357f35..fff315202 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 1171 +#define LIBYUV_VERSION 1172 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/source/row_posix.cc b/source/row_posix.cc index 40ac4a0a9..924566936 100644 --- a/source/row_posix.cc +++ b/source/row_posix.cc @@ -2339,6 +2339,38 @@ void ARGBMirrorRow_SSSE3(const uint8* src, uint8* dst, int width) { } #endif // HAS_ARGBMIRRORROW_SSSE3 +#ifdef HAS_ARGBMIRRORROW_AVX2 +// Shuffle table for reversing the bytes. +static const ulvec32 kARGBShuffleMirror_AVX2 = { + 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u +}; +void ARGBMirrorRow_AVX2(const uint8* src, uint8* dst, int width) { + intptr_t temp_width = (intptr_t)(width); + asm volatile ( + "vmovdqa %3,%%ymm5 \n" + LABELALIGN + "1: \n" + VMEMOPREG(vpermd,-0x20,0,2,4,ymm5,ymm0) // vpermd -0x20(%0,%2,4),ymm5,ymm0 + "sub $0x20,%2 \n" + "vmovdqu %%ymm0," MEMACCESS(1) " \n" + "lea " MEMLEA(0x20,1) ",%1 \n" + "jg 1b \n" + "vzeroupper \n" + : "+r"(src), // %0 + "+r"(dst), // %1 + "+r"(temp_width) // %2 + : "m"(kARGBShuffleMirror_AVX2) // %3 + : "memory", "cc" +#if defined(__native_client__) && defined(__x86_64__) + , "r14" +#endif +#if defined(__SSE2__) + , "xmm0", "xmm5" +#endif + ); +} +#endif // HAS_ARGBMIRRORROW_AVX2 + #ifdef HAS_SPLITUVROW_AVX2 void SplitUVRow_AVX2(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int pix) { asm volatile (