Commit 61ffd847 authored by fbarchard@google.com's avatar fbarchard@google.com

Add tests for ARGBRect and SetPlane. Remove comment to test Neon shuffle and Setrows for Neon.

BUG=387
TESTED=libyuvTest.ARGBRect_Opt and libyuvTest.SetPlane_Opt
R=harryjin@google.com

Review URL: https://webrtc-codereview.appspot.com/35589004

git-svn-id: http://libyuv.googlecode.com/svn/trunk@1217 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent 966233e5
Name: libyuv
URL: http://code.google.com/p/libyuv/
Version: 1216
Version: 1217
License: BSD
License File: LICENSE
......
......@@ -331,7 +331,6 @@ extern "C" {
#define HAS_SOBELXYROW_NEON
#define HAS_SOBELYROW_NEON
#define HAS_ARGBCOLORMATRIXROW_NEON
// TODO(fbarchard): Test the following 3 work on 32 bit arm.
#define HAS_ARGBSETROWS_NEON
#define HAS_ARGBSHUFFLEROW_NEON
#endif
......@@ -800,15 +799,15 @@ void ARGBCopyYToAlphaRow_C(const uint8* src_y, uint8* dst_argb, int width);
void ARGBCopyYToAlphaRow_SSE2(const uint8* src_y, uint8* dst_argb, int width);
void ARGBCopyYToAlphaRow_AVX2(const uint8* src_y, uint8* dst_argb, int width);
void SetRow_C(uint8* dst, uint32 v32, int count);
void SetRow_X86(uint8* dst, uint32 v32, int count);
void SetRow_NEON(uint8* dst, uint32 v32, int count);
void ARGBSetRows_C(uint8* dst, uint32 v32, int width, int dst_stride,
int height);
void ARGBSetRows_X86(uint8* dst, uint32 v32, int width,
int dst_stride, int height);
void SetRow_NEON(uint8* dst, uint32 v32, int count);
void ARGBSetRows_NEON(uint8* dst, uint32 v32, int width,
int dst_stride, int height);
void SetRow_C(uint8* dst, uint32 v32, int count);
void ARGBSetRows_C(uint8* dst, uint32 v32, int width, int dst_stride,
int height);
// ARGBShufflers for BGRAToARGB etc.
void ARGBShuffleRow_C(const uint8* src_argb, uint8* dst_argb,
......
......@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 1216
#define LIBYUV_VERSION 1217
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
......@@ -2105,4 +2105,87 @@ TEST_F(libyuvTest, TestARGBCopyYToAlpha) {
free_aligned_buffer_64(orig_pixels);
}
static int TestARGBRect(int width, int height, int benchmark_iterations,
int invert, int off, int bpp) {
if (width < 1) {
width = 1;
}
const int kStride = (width * bpp + 15) & ~15;
const int kSize = kStride * height;
const uint32 v32 = random() & (bpp == 4 ? 0xffffffff : 0xff);
align_buffer_64(dst_argb_c, kSize + off);
align_buffer_64(dst_argb_opt, kSize + off);
MemRandomize(dst_argb_c + off, kSize);
memcpy(dst_argb_opt + off, dst_argb_c + off, kSize);
MaskCpuFlags(0);
if (bpp == 4) {
ARGBRect(dst_argb_c + off, kStride, 0, 0, width, invert * height, v32);
} else {
SetPlane(dst_argb_c + off, kStride, width, invert * height, v32);
}
MaskCpuFlags(-1);
for (int i = 0; i < benchmark_iterations; ++i) {
if (bpp == 4) {
ARGBRect(dst_argb_opt + off, kStride, 0, 0, width, invert * height, v32);
} else {
SetPlane(dst_argb_opt + off, kStride, width, invert * height, v32);
}
}
int max_diff = 0;
for (int i = 0; i < kStride * height; ++i) {
int abs_diff =
abs(static_cast<int>(dst_argb_c[i + off]) -
static_cast<int>(dst_argb_opt[i + off]));
if (abs_diff > max_diff) {
max_diff = abs_diff;
}
}
free_aligned_buffer_64(dst_argb_c);
free_aligned_buffer_64(dst_argb_opt);
return max_diff;
}
// TODO(fbarchard): Add invert support and test.
TEST_F(libyuvTest, ARGBRect_Any) {
int max_diff = TestARGBRect(benchmark_width_ - 1, benchmark_height_,
benchmark_iterations_, +1, 0, 4);
EXPECT_EQ(0, max_diff);
}
TEST_F(libyuvTest, ARGBRect_Unaligned) {
int max_diff = TestARGBRect(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 1, 4);
EXPECT_EQ(0, max_diff);
}
TEST_F(libyuvTest, ARGBRect_Opt) {
int max_diff = TestARGBRect(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 0, 4);
EXPECT_EQ(0, max_diff);
}
TEST_F(libyuvTest, SetPlane_Any) {
int max_diff = TestARGBRect(benchmark_width_ - 1, benchmark_height_,
benchmark_iterations_, +1, 0, 1);
EXPECT_EQ(0, max_diff);
}
TEST_F(libyuvTest, SetPlane_Unaligned) {
int max_diff = TestARGBRect(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 1, 1);
EXPECT_EQ(0, max_diff);
}
TEST_F(libyuvTest, SetPlane_Opt) {
int max_diff = TestARGBRect(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 0, 1);
EXPECT_EQ(0, max_diff);
}
} // namespace libyuv
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