From c673f426de5fd73ee9214678fa5356328cb1fbcb Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Tue, 6 Nov 2012 18:46:51 +0000 Subject: [PATCH] ARGBToI444 for Neon BUG=none TEST=libyuvTest.ARGBToI444_Opt Review URL: https://webrtc-codereview.appspot.com/932013 git-svn-id: http://libyuv.googlecode.com/svn/trunk@475 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/row.h | 3 +++ include/libyuv/version.h | 2 +- source/convert_from_argb.cc | 5 ++++- source/row_neon.cc | 40 +++++++++++++++++++++++++++++++++++++ 5 files changed, 49 insertions(+), 3 deletions(-) diff --git a/README.chromium b/README.chromium index ca229d9e7..1b5f77c11 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 474 +Version: 475 License: BSD License File: LICENSE diff --git a/include/libyuv/row.h b/include/libyuv/row.h index b84a1aece..6438dd155 100644 --- a/include/libyuv/row.h +++ b/include/libyuv/row.h @@ -193,6 +193,7 @@ extern "C" { #define HAS_I444TOARGBROW_NEON #define HAS_I411TOARGBROW_NEON #define HAS_ARGBTOYROW_NEON +#define HAS_ARGBTOUV444ROW_NEON #define HAS_BGRATOYROW_NEON #define HAS_ABGRTOYROW_NEON #define HAS_RGBATOYROW_NEON @@ -342,6 +343,8 @@ void RGBAToYRow_Unaligned_SSSE3(const uint8* src_rgba, uint8* dst_y, int pix); void RGB24ToYRow_Unaligned_SSSE3(const uint8* src_rgb24, uint8* dst_y, int pix); void RAWToYRow_Unaligned_SSSE3(const uint8* src_raw, uint8* dst_y, int pix); void ARGBToYRow_NEON(const uint8* src_argb, uint8* dst_y, int pix); +void ARGBToUV444Row_NEON(const uint8* src_argb, uint8* dst_u, uint8* dst_v, + int pix); void BGRAToYRow_NEON(const uint8* src_bgra, uint8* dst_y, int pix); void ABGRToYRow_NEON(const uint8* src_abgr, uint8* dst_y, int pix); void RGBAToYRow_NEON(const uint8* src_rgba, uint8* dst_y, int pix); diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 0d62992d5..2c02782bc 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 474 +#define LIBYUV_VERSION 475 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/source/convert_from_argb.cc b/source/convert_from_argb.cc index 9dedde006..270d6e6ea 100644 --- a/source/convert_from_argb.cc +++ b/source/convert_from_argb.cc @@ -38,6 +38,8 @@ int ARGBToI444(const uint8* src_argb, int src_stride_argb, } void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int pix) = ARGBToYRow_C; + void (*ARGBToUV444Row)(const uint8* src_argb, uint8* dst_u, uint8* dst_v, + int pix) = ARGBToUV444Row_C; #if defined(HAS_ARGBTOYROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && width >= 16) { ARGBToYRow = ARGBToYRow_Any_SSSE3; @@ -54,12 +56,13 @@ int ARGBToI444(const uint8* src_argb, int src_stride_argb, ARGBToYRow = ARGBToYRow_Any_NEON; if (IS_ALIGNED(width, 8)) { ARGBToYRow = ARGBToYRow_NEON; + ARGBToUV444Row = ARGBToUV444Row_NEON; } } #endif for (int y = 0; y < height; ++y) { - ARGBToUV444Row_C(src_argb, dst_u, dst_v, width); + ARGBToUV444Row(src_argb, dst_u, dst_v, width); ARGBToYRow(src_argb, dst_y, width); src_argb += src_stride_argb; dst_y += dst_stride_y; diff --git a/source/row_neon.cc b/source/row_neon.cc index 39f122766..d49ae1550 100644 --- a/source/row_neon.cc +++ b/source/row_neon.cc @@ -1572,6 +1572,46 @@ void ARGBToYRow_NEON(const uint8* src_argb, uint8* dst_y, int pix) { } #endif // HAS_ARGBTOYROW_NEON +#ifdef HAS_ARGBTOYROW_NEON +void ARGBToUV444Row_NEON(const uint8* src_argb, uint8* dst_u, uint8* dst_v, + int pix) { + asm volatile ( + "vmov.u8 d24, #112 / 2 \n" // UB / VR coefficient + "vmov.u8 d25, #74 / 2 \n" // UG -coefficient + "vmov.u8 d26, #38 / 2 \n" // UR -coefficient + "vmov.u8 d27, #18 / 2 \n" // VB -coefficient + "vmov.u8 d28, #94 / 2 \n" // VG -coefficient + "vmov.u16 q15, #0x8080 / 2 \n" // 128 + ".p2align 2 \n" + "1: \n" + "vld4.8 {d0, d1, d2, d3}, [%0]! \n" // load 8 ARGB pixels. + "subs %3, %3, #8 \n" // 8 processed per loop. + "vmull.u8 q2, d0, d24 \n" // B + "vmlsl.u8 q2, d1, d25 \n" // G + "vmlsl.u8 q2, d2, d26 \n" // R + "vadd.u16 q2, q2, q15 \n" // +128 -> unsigned + + "vmull.u8 q3, d2, d24 \n" // R + "vmlsl.u8 q3, d1, d28 \n" // G + "vmlsl.u8 q3, d0, d27 \n" // B + "vadd.u16 q3, q3, q15 \n" // +128 -> unsigned + + "vqshrn.u16 d0, q2, #7 \n" // 16 bit to 8 bit U + "vqshrn.u16 d1, q3, #7 \n" // 16 bit to 8 bit V + + "vst1.8 {d0}, [%1]! \n" // store 8 pixels U. + "vst1.8 {d1}, [%2]! \n" // store 8 pixels U. + "bgt 1b \n" + : "+r"(src_argb), // %0 + "+r"(dst_u), // %1 + "+r"(dst_v), // %2 + "+r"(pix) // %3 + : + : "memory", "cc", "q0", "q1", "q2", "q3", "q4" + ); +} +#endif // HAS_ARGBTOYROW_NEON + #ifdef HAS_RGB565TOYROW_NEON void RGB565ToYRow_NEON(const uint8* src_rgb565, uint8* dst_y, int pix) { asm volatile (