Commit ef60ab0d authored by fbarchard@google.com's avatar fbarchard@google.com

Quantize for Neon

BUG=167
TEST=./libyuv_unittest --gtest_filter=*Quantize
Review URL: https://webrtc-codereview.appspot.com/972010

git-svn-id: http://libyuv.googlecode.com/svn/trunk@508 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent f3a41183
Name: libyuv
URL: http://code.google.com/p/libyuv/
Version: 507
Version: 508
License: BSD
License File: LICENSE
......
......@@ -222,6 +222,7 @@ extern "C" {
#define HAS_ARGBINTERPOLATEROW_NEON
#define HAS_ARGBBLENDROW_NEON
#define HAS_ARGBATTENUATEROW_NEON
#define HAS_ARGBQUANTIZEROW_NEON
#endif
// The following are available on Mips platforms
......@@ -1231,6 +1232,8 @@ void ARGBQuantizeRow_C(uint8* dst_argb, int scale, int interval_size,
int interval_offset, int width);
void ARGBQuantizeRow_SSE2(uint8* dst_argb, int scale, int interval_size,
int interval_offset, int width);
void ARGBQuantizeRow_NEON(uint8* dst_argb, int scale, int interval_size,
int interval_offset, int width);
// Used for blur.
void CumulativeSumToAverageRow_SSE2(const int32* topleft, const int32* botleft,
......
......@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 507
#define LIBYUV_VERSION 508
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
......@@ -984,6 +984,10 @@ int ARGBQuantize(uint8* dst_argb, int dst_stride_argb,
IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) {
ARGBQuantizeRow = ARGBQuantizeRow_SSE2;
}
#elif defined(HAS_ARGBQUANTIZEROW_NEON)
if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 8)) {
ARGBQuantizeRow = ARGBQuantizeRow_NEON;
}
#endif
uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4;
for (int y = 0; y < height; ++y) {
......
......@@ -2473,6 +2473,47 @@ void ARGBAttenuateRow_NEON(const uint8* src_argb, uint8* dst_argb, int width) {
}
#endif
// Quantize 8 ARGB pixels (32 bytes).
// dst = (dst * scale >> 16) * interval_size + interval_offset;
void ARGBQuantizeRow_NEON(uint8* dst_argb, int scale, int interval_size,
int interval_offset, int width) {
asm volatile (
"vdup.u16 q8, %2 \n"
"vshr.u16 q8, q8, #1 \n" // scale >>= 1
"vdup.u16 q9, %3 \n" // interval multiply.
"vdup.u16 q10, %4 \n" // interval add
// 8 pixel loop.
".p2align 2 \n"
"1: \n"
"vld4.8 {d0, d2, d4, d6}, [%0] \n" // load 8 pixels of ARGB.
"subs %1, %1, #8 \n" // 8 processed per loop.
"vmovl.u8 q0, d0 \n" // b (0 .. 255)
"vmovl.u8 q1, d2 \n"
"vmovl.u8 q2, d4 \n"
"vqdmulh.s16 q0, q0, q8 \n" // b * scale
"vqdmulh.s16 q1, q1, q8 \n" // g
"vqdmulh.s16 q2, q2, q8 \n" // r
"vmul.u16 q0, q0, q9 \n" // b * interval_size
"vmul.u16 q1, q1, q9 \n" // g
"vmul.u16 q2, q2, q9 \n" // r
"vadd.u16 q0, q0, q10 \n" // b + interval_offset
"vadd.u16 q1, q1, q10 \n" // g
"vadd.u16 q2, q2, q10 \n" // r
"vqmovn.u16 d0, q0 \n"
"vqmovn.u16 d2, q1 \n"
"vqmovn.u16 d4, q2 \n"
"vst4.8 {d0, d2, d4, d6}, [%0]! \n" // store 8 pixels of ARGB.
"bgt 1b \n"
: "+r"(dst_argb), // %0
"+r"(width) // %1
: "r"(scale), // %2
"r"(interval_size), // %3
"r"(interval_offset) // %4
: "cc", "memory", "q0", "q1", "q2", "q3", "q8", "q9", "q10"
);
}
#endif // __ARM_NEON__
#ifdef __cplusplus
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment