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

All cpu flags to be set so that instead of comparing C code, compare assembler…

All cpu flags to be set so that instead of comparing C code, compare assembler to assembler, for benchmarking purposes.
BUG=none
TESTED=libyuv_unittest.exe
R=bcornell@google.com

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

git-svn-id: http://libyuv.googlecode.com/svn/trunk@1346 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent 4f46a3e0
Name: libyuv Name: libyuv
URL: http://code.google.com/p/libyuv/ URL: http://code.google.com/p/libyuv/
Version: 1341 Version: 1346
License: BSD License: BSD
License File: LICENSE License File: LICENSE
......
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 1341 #define LIBYUV_VERSION 1346
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
...@@ -93,7 +93,7 @@ TEST_F(libyuvTest, TESTNAME) { \ ...@@ -93,7 +93,7 @@ TEST_F(libyuvTest, TESTNAME) { \
temp_v, (benchmark_width_ + 1) / 2, \ temp_v, (benchmark_width_ + 1) / 2, \
benchmark_width_, benchmark_height_); \ benchmark_width_, benchmark_height_); \
\ \
MaskCpuFlags(0); \ MaskCpuFlags(disable_cpu_flags_); \
YUVTOARGB(temp_y, benchmark_width_, \ YUVTOARGB(temp_y, benchmark_width_, \
temp_u, (benchmark_width_ + 1) / 2, \ temp_u, (benchmark_width_ + 1) / 2, \
temp_v, (benchmark_width_ + 1) / 2, \ temp_v, (benchmark_width_ + 1) / 2, \
......
...@@ -263,7 +263,7 @@ TEST_F(libyuvTest, SumSquareError) { ...@@ -263,7 +263,7 @@ TEST_F(libyuvTest, SumSquareError) {
src_b[i] = (random() & 0xff); src_b[i] = (random() & 0xff);
} }
MaskCpuFlags(0); MaskCpuFlags(disable_cpu_flags_);
uint64 c_err = ComputeSumSquareError(src_a, src_b, kMaxWidth); uint64 c_err = ComputeSumSquareError(src_a, src_b, kMaxWidth);
MaskCpuFlags(-1); MaskCpuFlags(-1);
...@@ -385,7 +385,7 @@ TEST_F(libyuvTest, Psnr) { ...@@ -385,7 +385,7 @@ TEST_F(libyuvTest, Psnr) {
} }
} }
MaskCpuFlags(0); MaskCpuFlags(disable_cpu_flags_);
double c_err, opt_err; double c_err, opt_err;
c_err = CalcFramePsnr(src_a + kSrcStride * b + b, kSrcStride, c_err = CalcFramePsnr(src_a + kSrcStride * b + b, kSrcStride,
...@@ -495,7 +495,7 @@ TEST_F(libyuvTest, Ssim) { ...@@ -495,7 +495,7 @@ TEST_F(libyuvTest, Ssim) {
} }
} }
MaskCpuFlags(0); MaskCpuFlags(disable_cpu_flags_);
double c_err, opt_err; double c_err, opt_err;
c_err = CalcFrameSsim(src_a + kSrcStride * b + b, kSrcStride, c_err = CalcFrameSsim(src_a + kSrcStride * b + b, kSrcStride,
......
...@@ -78,7 +78,7 @@ TEST_F(libyuvTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \ ...@@ -78,7 +78,7 @@ TEST_F(libyuvTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \
SUBSAMPLE(kHeight, SUBSAMP_Y)); \ SUBSAMPLE(kHeight, SUBSAMP_Y)); \
memset(dst_v_opt, 103, SUBSAMPLE(kWidth, SUBSAMP_X) * \ memset(dst_v_opt, 103, SUBSAMPLE(kWidth, SUBSAMP_X) * \
SUBSAMPLE(kHeight, SUBSAMP_Y)); \ SUBSAMPLE(kHeight, SUBSAMP_Y)); \
MaskCpuFlags(0); \ MaskCpuFlags(disable_cpu_flags_); \
SRC_FMT_PLANAR##To##FMT_PLANAR(src_y + OFF, kWidth, \ SRC_FMT_PLANAR##To##FMT_PLANAR(src_y + OFF, kWidth, \
src_u + OFF, \ src_u + OFF, \
SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \ SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \
...@@ -211,7 +211,7 @@ TEST_F(libyuvTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \ ...@@ -211,7 +211,7 @@ TEST_F(libyuvTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \
memset(dst_y_opt, 101, kWidth * kHeight); \ memset(dst_y_opt, 101, kWidth * kHeight); \
memset(dst_uv_opt, 102, SUBSAMPLE(kWidth * 2, SUBSAMP_X) * \ memset(dst_uv_opt, 102, SUBSAMPLE(kWidth * 2, SUBSAMP_X) * \
SUBSAMPLE(kHeight, SUBSAMP_Y)); \ SUBSAMPLE(kHeight, SUBSAMP_Y)); \
MaskCpuFlags(0); \ MaskCpuFlags(disable_cpu_flags_); \
SRC_FMT_PLANAR##To##FMT_PLANAR(src_y + OFF, kWidth, \ SRC_FMT_PLANAR##To##FMT_PLANAR(src_y + OFF, kWidth, \
src_u + OFF, \ src_u + OFF, \
SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \ SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \
...@@ -326,7 +326,7 @@ TEST_F(libyuvTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \ ...@@ -326,7 +326,7 @@ TEST_F(libyuvTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \
SUBSAMPLE(kHeight, SUBSAMP_Y)); \ SUBSAMPLE(kHeight, SUBSAMP_Y)); \
memset(dst_v_opt, 103, SUBSAMPLE(kWidth, SUBSAMP_X) * \ memset(dst_v_opt, 103, SUBSAMPLE(kWidth, SUBSAMP_X) * \
SUBSAMPLE(kHeight, SUBSAMP_Y)); \ SUBSAMPLE(kHeight, SUBSAMP_Y)); \
MaskCpuFlags(0); \ MaskCpuFlags(disable_cpu_flags_); \
SRC_FMT_PLANAR##To##FMT_PLANAR(src_y + OFF, kWidth, \ SRC_FMT_PLANAR##To##FMT_PLANAR(src_y + OFF, kWidth, \
src_uv + OFF, \ src_uv + OFF, \
2 * SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \ 2 * SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \
...@@ -435,7 +435,7 @@ TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \ ...@@ -435,7 +435,7 @@ TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \
} \ } \
memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \ memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \
memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \ memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \
MaskCpuFlags(0); \ MaskCpuFlags(disable_cpu_flags_); \
FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \
src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \
src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \
...@@ -538,7 +538,7 @@ TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \ ...@@ -538,7 +538,7 @@ TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \
} \ } \
memset(dst_argb_c, 1, kStrideB * kHeight); \ memset(dst_argb_c, 1, kStrideB * kHeight); \
memset(dst_argb_opt, 101, kStrideB * kHeight); \ memset(dst_argb_opt, 101, kStrideB * kHeight); \
MaskCpuFlags(0); \ MaskCpuFlags(disable_cpu_flags_); \
FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \
src_uv + OFF, SUBSAMPLE(kWidth, SUBSAMP_X) * 2, \ src_uv + OFF, SUBSAMPLE(kWidth, SUBSAMP_X) * 2, \
dst_argb_c, kWidth * BPP_B, \ dst_argb_c, kWidth * BPP_B, \
...@@ -632,7 +632,7 @@ TEST_F(libyuvTest, FMT_A##To##FMT_PLANAR##N) { \ ...@@ -632,7 +632,7 @@ TEST_F(libyuvTest, FMT_A##To##FMT_PLANAR##N) { \
for (int i = 0; i < kHeight; ++i) \ for (int i = 0; i < kHeight; ++i) \
for (int j = 0; j < kStride; ++j) \ for (int j = 0; j < kStride; ++j) \
src_argb[(i * kStride) + j + OFF] = (random() & 0xff); \ src_argb[(i * kStride) + j + OFF] = (random() & 0xff); \
MaskCpuFlags(0); \ MaskCpuFlags(disable_cpu_flags_); \
FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, \ FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, \
dst_y_c, kWidth, \ dst_y_c, kWidth, \
dst_u_c, SUBSAMPLE(kWidth, SUBSAMP_X), \ dst_u_c, SUBSAMPLE(kWidth, SUBSAMP_X), \
...@@ -738,7 +738,7 @@ TEST_F(libyuvTest, FMT_A##To##FMT_PLANAR##N) { \ ...@@ -738,7 +738,7 @@ TEST_F(libyuvTest, FMT_A##To##FMT_PLANAR##N) { \
memset(dst_y_opt, 101, kWidth * kHeight); \ memset(dst_y_opt, 101, kWidth * kHeight); \
memset(dst_uv_opt, 102, SUBSAMPLE(kWidth, SUBSAMP_X) * 2 * \ memset(dst_uv_opt, 102, SUBSAMPLE(kWidth, SUBSAMP_X) * 2 * \
SUBSAMPLE(kHeight, SUBSAMP_Y)); \ SUBSAMPLE(kHeight, SUBSAMP_Y)); \
MaskCpuFlags(0); \ MaskCpuFlags(disable_cpu_flags_); \
FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, \ FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, \
dst_y_c, kWidth, \ dst_y_c, kWidth, \
dst_uv_c, SUBSAMPLE(kWidth, SUBSAMP_X) * 2, \ dst_uv_c, SUBSAMPLE(kWidth, SUBSAMP_X) * 2, \
...@@ -814,7 +814,7 @@ TEST_F(libyuvTest, FMT_A##To##FMT_B##N) { \ ...@@ -814,7 +814,7 @@ TEST_F(libyuvTest, FMT_A##To##FMT_B##N) { \
} \ } \
memset(dst_argb_c, 1, kStrideB * kHeightB); \ memset(dst_argb_c, 1, kStrideB * kHeightB); \
memset(dst_argb_opt, 101, kStrideB * kHeightB); \ memset(dst_argb_opt, 101, kStrideB * kHeightB); \
MaskCpuFlags(0); \ MaskCpuFlags(disable_cpu_flags_); \
FMT_A##To##FMT_B(src_argb + OFF, kStrideA, \ FMT_A##To##FMT_B(src_argb + OFF, kStrideA, \
dst_argb_c, kStrideB, \ dst_argb_c, kStrideB, \
kWidth, NEG kHeight); \ kWidth, NEG kHeight); \
...@@ -858,7 +858,7 @@ TEST_F(libyuvTest, FMT_A##To##FMT_B##_Random) { \ ...@@ -858,7 +858,7 @@ TEST_F(libyuvTest, FMT_A##To##FMT_B##_Random) { \
} \ } \
memset(dst_argb_c, 123, kStrideB * kHeightB); \ memset(dst_argb_c, 123, kStrideB * kHeightB); \
memset(dst_argb_opt, 123, kStrideB * kHeightB); \ memset(dst_argb_opt, 123, kStrideB * kHeightB); \
MaskCpuFlags(0); \ MaskCpuFlags(disable_cpu_flags_); \
FMT_A##To##FMT_B(src_argb, kStrideA, \ FMT_A##To##FMT_B(src_argb, kStrideA, \
dst_argb_c, kStrideB, \ dst_argb_c, kStrideB, \
kWidth, kHeight); \ kWidth, kHeight); \
...@@ -948,7 +948,7 @@ TEST_F(libyuvTest, FMT_A##To##FMT_B##Dither##N) { \ ...@@ -948,7 +948,7 @@ TEST_F(libyuvTest, FMT_A##To##FMT_B##Dither##N) { \
} \ } \
memset(dst_argb_c, 1, kStrideB * kHeightB); \ memset(dst_argb_c, 1, kStrideB * kHeightB); \
memset(dst_argb_opt, 101, kStrideB * kHeightB); \ memset(dst_argb_opt, 101, kStrideB * kHeightB); \
MaskCpuFlags(0); \ MaskCpuFlags(disable_cpu_flags_); \
FMT_A##To##FMT_B##Dither(src_argb + OFF, kStrideA, \ FMT_A##To##FMT_B##Dither(src_argb + OFF, kStrideA, \
dst_argb_c, kStrideB, \ dst_argb_c, kStrideB, \
NULL, kWidth, NEG kHeight); \ NULL, kWidth, NEG kHeight); \
...@@ -992,7 +992,7 @@ TEST_F(libyuvTest, FMT_A##To##FMT_B##Dither_Random) { \ ...@@ -992,7 +992,7 @@ TEST_F(libyuvTest, FMT_A##To##FMT_B##Dither_Random) { \
} \ } \
memset(dst_argb_c, 123, kStrideB * kHeightB); \ memset(dst_argb_c, 123, kStrideB * kHeightB); \
memset(dst_argb_opt, 123, kStrideB * kHeightB); \ memset(dst_argb_opt, 123, kStrideB * kHeightB); \
MaskCpuFlags(0); \ MaskCpuFlags(disable_cpu_flags_); \
FMT_A##To##FMT_B##Dither(src_argb, kStrideA, \ FMT_A##To##FMT_B##Dither(src_argb, kStrideA, \
dst_argb_c, kStrideB, \ dst_argb_c, kStrideB, \
NULL, kWidth, kHeight); \ NULL, kWidth, kHeight); \
...@@ -1051,7 +1051,7 @@ TEST_F(libyuvTest, FMT_ATOB##_Symetric##N) { \ ...@@ -1051,7 +1051,7 @@ TEST_F(libyuvTest, FMT_ATOB##_Symetric##N) { \
} \ } \
memset(dst_argb_c, 1, kStrideA * kHeightA); \ memset(dst_argb_c, 1, kStrideA * kHeightA); \
memset(dst_argb_opt, 101, kStrideA * kHeightA); \ memset(dst_argb_opt, 101, kStrideA * kHeightA); \
MaskCpuFlags(0); \ MaskCpuFlags(disable_cpu_flags_); \
FMT_ATOB(src_argb + OFF, kStrideA, \ FMT_ATOB(src_argb + OFF, kStrideA, \
dst_argb_c, kStrideA, \ dst_argb_c, kStrideA, \
kWidth, NEG kHeight); \ kWidth, NEG kHeight); \
...@@ -1061,7 +1061,7 @@ TEST_F(libyuvTest, FMT_ATOB##_Symetric##N) { \ ...@@ -1061,7 +1061,7 @@ TEST_F(libyuvTest, FMT_ATOB##_Symetric##N) { \
dst_argb_opt, kStrideA, \ dst_argb_opt, kStrideA, \
kWidth, NEG kHeight); \ kWidth, NEG kHeight); \
} \ } \
MaskCpuFlags(0); \ MaskCpuFlags(disable_cpu_flags_); \
FMT_ATOB(dst_argb_c, kStrideA, \ FMT_ATOB(dst_argb_c, kStrideA, \
dst_argb_c, kStrideA, \ dst_argb_c, kStrideA, \
kWidth, NEG kHeight); \ kWidth, NEG kHeight); \
...@@ -1470,7 +1470,7 @@ TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##Dither##N) { \ ...@@ -1470,7 +1470,7 @@ TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##Dither##N) { \
} \ } \
memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \ memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \
memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \ memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \
MaskCpuFlags(0); \ MaskCpuFlags(disable_cpu_flags_); \
FMT_PLANAR##To##FMT_B##Dither(src_y + OFF, kWidth, \ FMT_PLANAR##To##FMT_B##Dither(src_y + OFF, kWidth, \
src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \
src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \
......
...@@ -105,7 +105,7 @@ TEST_F(libyuvTest, TestAttenuate) { ...@@ -105,7 +105,7 @@ TEST_F(libyuvTest, TestAttenuate) {
} }
static int TestAttenuateI(int width, int height, int benchmark_iterations, static int TestAttenuateI(int width, int height, int benchmark_iterations,
int invert, int off) { int disable_cpu_flags, int invert, int off) {
if (width < 1) { if (width < 1) {
width = 1; width = 1;
} }
...@@ -121,7 +121,7 @@ static int TestAttenuateI(int width, int height, int benchmark_iterations, ...@@ -121,7 +121,7 @@ static int TestAttenuateI(int width, int height, int benchmark_iterations,
memset(dst_argb_c, 0, kStride * height); memset(dst_argb_c, 0, kStride * height);
memset(dst_argb_opt, 0, kStride * height); memset(dst_argb_opt, 0, kStride * height);
MaskCpuFlags(0); MaskCpuFlags(disable_cpu_flags);
ARGBAttenuate(src_argb + off, kStride, ARGBAttenuate(src_argb + off, kStride,
dst_argb_c, kStride, dst_argb_c, kStride,
width, invert * height); width, invert * height);
...@@ -148,30 +148,30 @@ static int TestAttenuateI(int width, int height, int benchmark_iterations, ...@@ -148,30 +148,30 @@ static int TestAttenuateI(int width, int height, int benchmark_iterations,
TEST_F(libyuvTest, ARGBAttenuate_Any) { TEST_F(libyuvTest, ARGBAttenuate_Any) {
int max_diff = TestAttenuateI(benchmark_width_ - 1, benchmark_height_, int max_diff = TestAttenuateI(benchmark_width_ - 1, benchmark_height_,
benchmark_iterations_, +1, 0); benchmark_iterations_, disable_cpu_flags_, +1, 0);
EXPECT_LE(max_diff, 2); EXPECT_LE(max_diff, 2);
} }
TEST_F(libyuvTest, ARGBAttenuate_Unaligned) { TEST_F(libyuvTest, ARGBAttenuate_Unaligned) {
int max_diff = TestAttenuateI(benchmark_width_, benchmark_height_, int max_diff = TestAttenuateI(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 1); benchmark_iterations_, disable_cpu_flags_, +1, 1);
EXPECT_LE(max_diff, 2); EXPECT_LE(max_diff, 2);
} }
TEST_F(libyuvTest, ARGBAttenuate_Invert) { TEST_F(libyuvTest, ARGBAttenuate_Invert) {
int max_diff = TestAttenuateI(benchmark_width_, benchmark_height_, int max_diff = TestAttenuateI(benchmark_width_, benchmark_height_,
benchmark_iterations_, -1, 0); benchmark_iterations_, disable_cpu_flags_, -1, 0);
EXPECT_LE(max_diff, 2); EXPECT_LE(max_diff, 2);
} }
TEST_F(libyuvTest, ARGBAttenuate_Opt) { TEST_F(libyuvTest, ARGBAttenuate_Opt) {
int max_diff = TestAttenuateI(benchmark_width_, benchmark_height_, int max_diff = TestAttenuateI(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 0); benchmark_iterations_, disable_cpu_flags_, +1, 0);
EXPECT_LE(max_diff, 2); EXPECT_LE(max_diff, 2);
} }
static int TestUnattenuateI(int width, int height, int benchmark_iterations, static int TestUnattenuateI(int width, int height, int benchmark_iterations,
int invert, int off) { int disable_cpu_flags, int invert, int off) {
if (width < 1) { if (width < 1) {
width = 1; width = 1;
} }
...@@ -190,7 +190,7 @@ static int TestUnattenuateI(int width, int height, int benchmark_iterations, ...@@ -190,7 +190,7 @@ static int TestUnattenuateI(int width, int height, int benchmark_iterations,
memset(dst_argb_c, 0, kStride * height); memset(dst_argb_c, 0, kStride * height);
memset(dst_argb_opt, 0, kStride * height); memset(dst_argb_opt, 0, kStride * height);
MaskCpuFlags(0); MaskCpuFlags(disable_cpu_flags);
ARGBUnattenuate(src_argb + off, kStride, ARGBUnattenuate(src_argb + off, kStride,
dst_argb_c, kStride, dst_argb_c, kStride,
width, invert * height); width, invert * height);
...@@ -217,25 +217,25 @@ static int TestUnattenuateI(int width, int height, int benchmark_iterations, ...@@ -217,25 +217,25 @@ static int TestUnattenuateI(int width, int height, int benchmark_iterations,
TEST_F(libyuvTest, ARGBUnattenuate_Any) { TEST_F(libyuvTest, ARGBUnattenuate_Any) {
int max_diff = TestUnattenuateI(benchmark_width_ - 1, benchmark_height_, int max_diff = TestUnattenuateI(benchmark_width_ - 1, benchmark_height_,
benchmark_iterations_, +1, 0); benchmark_iterations_, disable_cpu_flags_, +1, 0);
EXPECT_LE(max_diff, 2); EXPECT_LE(max_diff, 2);
} }
TEST_F(libyuvTest, ARGBUnattenuate_Unaligned) { TEST_F(libyuvTest, ARGBUnattenuate_Unaligned) {
int max_diff = TestUnattenuateI(benchmark_width_, benchmark_height_, int max_diff = TestUnattenuateI(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 1); benchmark_iterations_, disable_cpu_flags_, +1, 1);
EXPECT_LE(max_diff, 2); EXPECT_LE(max_diff, 2);
} }
TEST_F(libyuvTest, ARGBUnattenuate_Invert) { TEST_F(libyuvTest, ARGBUnattenuate_Invert) {
int max_diff = TestUnattenuateI(benchmark_width_, benchmark_height_, int max_diff = TestUnattenuateI(benchmark_width_, benchmark_height_,
benchmark_iterations_, -1, 0); benchmark_iterations_, disable_cpu_flags_, -1, 0);
EXPECT_LE(max_diff, 2); EXPECT_LE(max_diff, 2);
} }
TEST_F(libyuvTest, ARGBUnattenuate_Opt) { TEST_F(libyuvTest, ARGBUnattenuate_Opt) {
int max_diff = TestUnattenuateI(benchmark_width_, benchmark_height_, int max_diff = TestUnattenuateI(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 0); benchmark_iterations_, disable_cpu_flags_, +1, 0);
EXPECT_LE(max_diff, 2); EXPECT_LE(max_diff, 2);
} }
...@@ -541,7 +541,7 @@ TEST_F(libyuvTest, TestARGBColorMatrix) { ...@@ -541,7 +541,7 @@ TEST_F(libyuvTest, TestARGBColorMatrix) {
orig_pixels[i][2] = i / 3; orig_pixels[i][2] = i / 3;
orig_pixels[i][3] = i; orig_pixels[i][3] = i;
} }
MaskCpuFlags(0); MaskCpuFlags(disable_cpu_flags_);
ARGBColorMatrix(&orig_pixels[0][0], 0, &dst_pixels_c[0][0], 0, ARGBColorMatrix(&orig_pixels[0][0], 0, &dst_pixels_c[0][0], 0,
&kRGBToSepia[0], 1280, 1); &kRGBToSepia[0], 1280, 1);
MaskCpuFlags(-1); MaskCpuFlags(-1);
...@@ -941,7 +941,7 @@ TEST_F(libyuvTest, ARGBInterpolate##TERP##N) { \ ...@@ -941,7 +941,7 @@ TEST_F(libyuvTest, ARGBInterpolate##TERP##N) { \
src_argb_a[i + OFF] = (random() & 0xff); \ src_argb_a[i + OFF] = (random() & 0xff); \
src_argb_b[i + OFF] = (random() & 0xff); \ src_argb_b[i + OFF] = (random() & 0xff); \
} \ } \
MaskCpuFlags(0); \ MaskCpuFlags(disable_cpu_flags_); \
ARGBInterpolate(src_argb_a + OFF, kStrideA, \ ARGBInterpolate(src_argb_a + OFF, kStrideA, \
src_argb_b + OFF, kStrideA, \ src_argb_b + OFF, kStrideA, \
dst_argb_c, kStrideB, \ dst_argb_c, kStrideB, \
...@@ -988,7 +988,7 @@ TESTINTERPOLATE(192) ...@@ -988,7 +988,7 @@ TESTINTERPOLATE(192)
TESTINTERPOLATE(255) TESTINTERPOLATE(255)
static int TestBlend(int width, int height, int benchmark_iterations, static int TestBlend(int width, int height, int benchmark_iterations,
int invert, int off) { int disable_cpu_flags, int invert, int off) {
if (width < 1) { if (width < 1) {
width = 1; width = 1;
} }
...@@ -1010,7 +1010,7 @@ static int TestBlend(int width, int height, int benchmark_iterations, ...@@ -1010,7 +1010,7 @@ static int TestBlend(int width, int height, int benchmark_iterations,
memset(dst_argb_c, 255, kStride * height); memset(dst_argb_c, 255, kStride * height);
memset(dst_argb_opt, 255, kStride * height); memset(dst_argb_opt, 255, kStride * height);
MaskCpuFlags(0); MaskCpuFlags(disable_cpu_flags);
ARGBBlend(src_argb_a + off, kStride, ARGBBlend(src_argb_a + off, kStride,
src_argb_b + off, kStride, src_argb_b + off, kStride,
dst_argb_c, kStride, dst_argb_c, kStride,
...@@ -1040,25 +1040,25 @@ static int TestBlend(int width, int height, int benchmark_iterations, ...@@ -1040,25 +1040,25 @@ static int TestBlend(int width, int height, int benchmark_iterations,
TEST_F(libyuvTest, ARGBBlend_Any) { TEST_F(libyuvTest, ARGBBlend_Any) {
int max_diff = TestBlend(benchmark_width_ - 4, benchmark_height_, int max_diff = TestBlend(benchmark_width_ - 4, benchmark_height_,
benchmark_iterations_, +1, 0); benchmark_iterations_, disable_cpu_flags_, +1, 0);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
TEST_F(libyuvTest, ARGBBlend_Unaligned) { TEST_F(libyuvTest, ARGBBlend_Unaligned) {
int max_diff = TestBlend(benchmark_width_, benchmark_height_, int max_diff = TestBlend(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 1); benchmark_iterations_, disable_cpu_flags_, +1, 1);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
TEST_F(libyuvTest, ARGBBlend_Invert) { TEST_F(libyuvTest, ARGBBlend_Invert) {
int max_diff = TestBlend(benchmark_width_, benchmark_height_, int max_diff = TestBlend(benchmark_width_, benchmark_height_,
benchmark_iterations_, -1, 0); benchmark_iterations_, disable_cpu_flags_, -1, 0);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
TEST_F(libyuvTest, ARGBBlend_Opt) { TEST_F(libyuvTest, ARGBBlend_Opt) {
int max_diff = TestBlend(benchmark_width_, benchmark_height_, int max_diff = TestBlend(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 0); benchmark_iterations_, disable_cpu_flags_, +1, 0);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
...@@ -1333,7 +1333,7 @@ TEST_F(libyuvTest, TestCopyPlane) { ...@@ -1333,7 +1333,7 @@ TEST_F(libyuvTest, TestCopyPlane) {
int stride = 8; int stride = 8;
// Disable all optimizations. // Disable all optimizations.
MaskCpuFlags(0); MaskCpuFlags(disable_cpu_flags_);
double c_time = get_time(); double c_time = get_time();
for (j = 0; j < benchmark_iterations_; j++) { for (j = 0; j < benchmark_iterations_; j++) {
CopyPlane(orig_y + y_off, y_st, dst_c + y_off, stride, yw, yh); CopyPlane(orig_y + y_off, y_st, dst_c + y_off, stride, yw, yh);
...@@ -1361,7 +1361,7 @@ TEST_F(libyuvTest, TestCopyPlane) { ...@@ -1361,7 +1361,7 @@ TEST_F(libyuvTest, TestCopyPlane) {
} }
static int TestMultiply(int width, int height, int benchmark_iterations, static int TestMultiply(int width, int height, int benchmark_iterations,
int invert, int off) { int disable_cpu_flags, int invert, int off) {
if (width < 1) { if (width < 1) {
width = 1; width = 1;
} }
...@@ -1379,7 +1379,7 @@ static int TestMultiply(int width, int height, int benchmark_iterations, ...@@ -1379,7 +1379,7 @@ static int TestMultiply(int width, int height, int benchmark_iterations,
memset(dst_argb_c, 0, kStride * height); memset(dst_argb_c, 0, kStride * height);
memset(dst_argb_opt, 0, kStride * height); memset(dst_argb_opt, 0, kStride * height);
MaskCpuFlags(0); MaskCpuFlags(disable_cpu_flags);
ARGBMultiply(src_argb_a + off, kStride, ARGBMultiply(src_argb_a + off, kStride,
src_argb_b + off, kStride, src_argb_b + off, kStride,
dst_argb_c, kStride, dst_argb_c, kStride,
...@@ -1409,30 +1409,30 @@ static int TestMultiply(int width, int height, int benchmark_iterations, ...@@ -1409,30 +1409,30 @@ static int TestMultiply(int width, int height, int benchmark_iterations,
TEST_F(libyuvTest, ARGBMultiply_Any) { TEST_F(libyuvTest, ARGBMultiply_Any) {
int max_diff = TestMultiply(benchmark_width_ - 1, benchmark_height_, int max_diff = TestMultiply(benchmark_width_ - 1, benchmark_height_,
benchmark_iterations_, +1, 0); benchmark_iterations_, disable_cpu_flags_, +1, 0);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
TEST_F(libyuvTest, ARGBMultiply_Unaligned) { TEST_F(libyuvTest, ARGBMultiply_Unaligned) {
int max_diff = TestMultiply(benchmark_width_, benchmark_height_, int max_diff = TestMultiply(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 1); benchmark_iterations_, disable_cpu_flags_, +1, 1);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
TEST_F(libyuvTest, ARGBMultiply_Invert) { TEST_F(libyuvTest, ARGBMultiply_Invert) {
int max_diff = TestMultiply(benchmark_width_, benchmark_height_, int max_diff = TestMultiply(benchmark_width_, benchmark_height_,
benchmark_iterations_, -1, 0); benchmark_iterations_, disable_cpu_flags_, -1, 0);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
TEST_F(libyuvTest, ARGBMultiply_Opt) { TEST_F(libyuvTest, ARGBMultiply_Opt) {
int max_diff = TestMultiply(benchmark_width_, benchmark_height_, int max_diff = TestMultiply(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 0); benchmark_iterations_, disable_cpu_flags_, +1, 0);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
static int TestAdd(int width, int height, int benchmark_iterations, static int TestAdd(int width, int height, int benchmark_iterations,
int invert, int off) { int disable_cpu_flags, int invert, int off) {
if (width < 1) { if (width < 1) {
width = 1; width = 1;
} }
...@@ -1450,7 +1450,7 @@ static int TestAdd(int width, int height, int benchmark_iterations, ...@@ -1450,7 +1450,7 @@ static int TestAdd(int width, int height, int benchmark_iterations,
memset(dst_argb_c, 0, kStride * height); memset(dst_argb_c, 0, kStride * height);
memset(dst_argb_opt, 0, kStride * height); memset(dst_argb_opt, 0, kStride * height);
MaskCpuFlags(0); MaskCpuFlags(disable_cpu_flags);
ARGBAdd(src_argb_a + off, kStride, ARGBAdd(src_argb_a + off, kStride,
src_argb_b + off, kStride, src_argb_b + off, kStride,
dst_argb_c, kStride, dst_argb_c, kStride,
...@@ -1480,30 +1480,30 @@ static int TestAdd(int width, int height, int benchmark_iterations, ...@@ -1480,30 +1480,30 @@ static int TestAdd(int width, int height, int benchmark_iterations,
TEST_F(libyuvTest, ARGBAdd_Any) { TEST_F(libyuvTest, ARGBAdd_Any) {
int max_diff = TestAdd(benchmark_width_ - 1, benchmark_height_, int max_diff = TestAdd(benchmark_width_ - 1, benchmark_height_,
benchmark_iterations_, +1, 0); benchmark_iterations_, disable_cpu_flags_, +1, 0);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
TEST_F(libyuvTest, ARGBAdd_Unaligned) { TEST_F(libyuvTest, ARGBAdd_Unaligned) {
int max_diff = TestAdd(benchmark_width_, benchmark_height_, int max_diff = TestAdd(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 1); benchmark_iterations_, disable_cpu_flags_, +1, 1);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
TEST_F(libyuvTest, ARGBAdd_Invert) { TEST_F(libyuvTest, ARGBAdd_Invert) {
int max_diff = TestAdd(benchmark_width_, benchmark_height_, int max_diff = TestAdd(benchmark_width_, benchmark_height_,
benchmark_iterations_, -1, 0); benchmark_iterations_, disable_cpu_flags_, -1, 0);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
TEST_F(libyuvTest, ARGBAdd_Opt) { TEST_F(libyuvTest, ARGBAdd_Opt) {
int max_diff = TestAdd(benchmark_width_, benchmark_height_, int max_diff = TestAdd(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 0); benchmark_iterations_, disable_cpu_flags_, +1, 0);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
static int TestSubtract(int width, int height, int benchmark_iterations, static int TestSubtract(int width, int height, int benchmark_iterations,
int invert, int off) { int disable_cpu_flags, int invert, int off) {
if (width < 1) { if (width < 1) {
width = 1; width = 1;
} }
...@@ -1521,7 +1521,7 @@ static int TestSubtract(int width, int height, int benchmark_iterations, ...@@ -1521,7 +1521,7 @@ static int TestSubtract(int width, int height, int benchmark_iterations,
memset(dst_argb_c, 0, kStride * height); memset(dst_argb_c, 0, kStride * height);
memset(dst_argb_opt, 0, kStride * height); memset(dst_argb_opt, 0, kStride * height);
MaskCpuFlags(0); MaskCpuFlags(disable_cpu_flags);
ARGBSubtract(src_argb_a + off, kStride, ARGBSubtract(src_argb_a + off, kStride,
src_argb_b + off, kStride, src_argb_b + off, kStride,
dst_argb_c, kStride, dst_argb_c, kStride,
...@@ -1551,30 +1551,30 @@ static int TestSubtract(int width, int height, int benchmark_iterations, ...@@ -1551,30 +1551,30 @@ static int TestSubtract(int width, int height, int benchmark_iterations,
TEST_F(libyuvTest, ARGBSubtract_Any) { TEST_F(libyuvTest, ARGBSubtract_Any) {
int max_diff = TestSubtract(benchmark_width_ - 1, benchmark_height_, int max_diff = TestSubtract(benchmark_width_ - 1, benchmark_height_,
benchmark_iterations_, +1, 0); benchmark_iterations_, disable_cpu_flags_, +1, 0);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
TEST_F(libyuvTest, ARGBSubtract_Unaligned) { TEST_F(libyuvTest, ARGBSubtract_Unaligned) {
int max_diff = TestSubtract(benchmark_width_, benchmark_height_, int max_diff = TestSubtract(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 1); benchmark_iterations_, disable_cpu_flags_, +1, 1);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
TEST_F(libyuvTest, ARGBSubtract_Invert) { TEST_F(libyuvTest, ARGBSubtract_Invert) {
int max_diff = TestSubtract(benchmark_width_, benchmark_height_, int max_diff = TestSubtract(benchmark_width_, benchmark_height_,
benchmark_iterations_, -1, 0); benchmark_iterations_, disable_cpu_flags_, -1, 0);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
TEST_F(libyuvTest, ARGBSubtract_Opt) { TEST_F(libyuvTest, ARGBSubtract_Opt) {
int max_diff = TestSubtract(benchmark_width_, benchmark_height_, int max_diff = TestSubtract(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 0); benchmark_iterations_, disable_cpu_flags_, +1, 0);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
static int TestSobel(int width, int height, int benchmark_iterations, static int TestSobel(int width, int height, int benchmark_iterations,
int invert, int off) { int disable_cpu_flags, int invert, int off) {
if (width < 1) { if (width < 1) {
width = 1; width = 1;
} }
...@@ -1591,7 +1591,7 @@ static int TestSobel(int width, int height, int benchmark_iterations, ...@@ -1591,7 +1591,7 @@ static int TestSobel(int width, int height, int benchmark_iterations,
memset(dst_argb_c, 0, kStride * height); memset(dst_argb_c, 0, kStride * height);
memset(dst_argb_opt, 0, kStride * height); memset(dst_argb_opt, 0, kStride * height);
MaskCpuFlags(0); MaskCpuFlags(disable_cpu_flags);
ARGBSobel(src_argb_a + off, kStride, ARGBSobel(src_argb_a + off, kStride,
dst_argb_c, kStride, dst_argb_c, kStride,
width, invert * height); width, invert * height);
...@@ -1618,30 +1618,30 @@ static int TestSobel(int width, int height, int benchmark_iterations, ...@@ -1618,30 +1618,30 @@ static int TestSobel(int width, int height, int benchmark_iterations,
TEST_F(libyuvTest, ARGBSobel_Any) { TEST_F(libyuvTest, ARGBSobel_Any) {
int max_diff = TestSobel(benchmark_width_ - 1, benchmark_height_, int max_diff = TestSobel(benchmark_width_ - 1, benchmark_height_,
benchmark_iterations_, +1, 0); benchmark_iterations_, disable_cpu_flags_, +1, 0);
EXPECT_EQ(0, max_diff); EXPECT_EQ(0, max_diff);
} }
TEST_F(libyuvTest, ARGBSobel_Unaligned) { TEST_F(libyuvTest, ARGBSobel_Unaligned) {
int max_diff = TestSobel(benchmark_width_, benchmark_height_, int max_diff = TestSobel(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 1); benchmark_iterations_, disable_cpu_flags_, +1, 1);
EXPECT_EQ(0, max_diff); EXPECT_EQ(0, max_diff);
} }
TEST_F(libyuvTest, ARGBSobel_Invert) { TEST_F(libyuvTest, ARGBSobel_Invert) {
int max_diff = TestSobel(benchmark_width_, benchmark_height_, int max_diff = TestSobel(benchmark_width_, benchmark_height_,
benchmark_iterations_, -1, 0); benchmark_iterations_, disable_cpu_flags_, -1, 0);
EXPECT_EQ(0, max_diff); EXPECT_EQ(0, max_diff);
} }
TEST_F(libyuvTest, ARGBSobel_Opt) { TEST_F(libyuvTest, ARGBSobel_Opt) {
int max_diff = TestSobel(benchmark_width_, benchmark_height_, int max_diff = TestSobel(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 0); benchmark_iterations_, disable_cpu_flags_, +1, 0);
EXPECT_EQ(0, max_diff); EXPECT_EQ(0, max_diff);
} }
static int TestSobelToPlane(int width, int height, int benchmark_iterations, static int TestSobelToPlane(int width, int height, int benchmark_iterations,
int invert, int off) { int disable_cpu_flags, int invert, int off) {
if (width < 1) { if (width < 1) {
width = 1; width = 1;
} }
...@@ -1660,7 +1660,7 @@ static int TestSobelToPlane(int width, int height, int benchmark_iterations, ...@@ -1660,7 +1660,7 @@ static int TestSobelToPlane(int width, int height, int benchmark_iterations,
memset(dst_argb_c, 0, kDstStride * height); memset(dst_argb_c, 0, kDstStride * height);
memset(dst_argb_opt, 0, kDstStride * height); memset(dst_argb_opt, 0, kDstStride * height);
MaskCpuFlags(0); MaskCpuFlags(disable_cpu_flags);
ARGBSobelToPlane(src_argb_a + off, kSrcStride, ARGBSobelToPlane(src_argb_a + off, kSrcStride,
dst_argb_c, kDstStride, dst_argb_c, kDstStride,
width, invert * height); width, invert * height);
...@@ -1687,30 +1687,30 @@ static int TestSobelToPlane(int width, int height, int benchmark_iterations, ...@@ -1687,30 +1687,30 @@ static int TestSobelToPlane(int width, int height, int benchmark_iterations,
TEST_F(libyuvTest, ARGBSobelToPlane_Any) { TEST_F(libyuvTest, ARGBSobelToPlane_Any) {
int max_diff = TestSobelToPlane(benchmark_width_ - 1, benchmark_height_, int max_diff = TestSobelToPlane(benchmark_width_ - 1, benchmark_height_,
benchmark_iterations_, +1, 0); benchmark_iterations_, disable_cpu_flags_, +1, 0);
EXPECT_EQ(0, max_diff); EXPECT_EQ(0, max_diff);
} }
TEST_F(libyuvTest, ARGBSobelToPlane_Unaligned) { TEST_F(libyuvTest, ARGBSobelToPlane_Unaligned) {
int max_diff = TestSobelToPlane(benchmark_width_, benchmark_height_, int max_diff = TestSobelToPlane(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 1); benchmark_iterations_, disable_cpu_flags_, +1, 1);
EXPECT_EQ(0, max_diff); EXPECT_EQ(0, max_diff);
} }
TEST_F(libyuvTest, ARGBSobelToPlane_Invert) { TEST_F(libyuvTest, ARGBSobelToPlane_Invert) {
int max_diff = TestSobelToPlane(benchmark_width_, benchmark_height_, int max_diff = TestSobelToPlane(benchmark_width_, benchmark_height_,
benchmark_iterations_, -1, 0); benchmark_iterations_, disable_cpu_flags_, -1, 0);
EXPECT_EQ(0, max_diff); EXPECT_EQ(0, max_diff);
} }
TEST_F(libyuvTest, ARGBSobelToPlane_Opt) { TEST_F(libyuvTest, ARGBSobelToPlane_Opt) {
int max_diff = TestSobelToPlane(benchmark_width_, benchmark_height_, int max_diff = TestSobelToPlane(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 0); benchmark_iterations_, disable_cpu_flags_, +1, 0);
EXPECT_EQ(0, max_diff); EXPECT_EQ(0, max_diff);
} }
static int TestSobelXY(int width, int height, int benchmark_iterations, static int TestSobelXY(int width, int height, int benchmark_iterations,
int invert, int off) { int disable_cpu_flags, int invert, int off) {
if (width < 1) { if (width < 1) {
width = 1; width = 1;
} }
...@@ -1727,7 +1727,7 @@ static int TestSobelXY(int width, int height, int benchmark_iterations, ...@@ -1727,7 +1727,7 @@ static int TestSobelXY(int width, int height, int benchmark_iterations,
memset(dst_argb_c, 0, kStride * height); memset(dst_argb_c, 0, kStride * height);
memset(dst_argb_opt, 0, kStride * height); memset(dst_argb_opt, 0, kStride * height);
MaskCpuFlags(0); MaskCpuFlags(disable_cpu_flags);
ARGBSobelXY(src_argb_a + off, kStride, ARGBSobelXY(src_argb_a + off, kStride,
dst_argb_c, kStride, dst_argb_c, kStride,
width, invert * height); width, invert * height);
...@@ -1754,30 +1754,30 @@ static int TestSobelXY(int width, int height, int benchmark_iterations, ...@@ -1754,30 +1754,30 @@ static int TestSobelXY(int width, int height, int benchmark_iterations,
TEST_F(libyuvTest, ARGBSobelXY_Any) { TEST_F(libyuvTest, ARGBSobelXY_Any) {
int max_diff = TestSobelXY(benchmark_width_ - 1, benchmark_height_, int max_diff = TestSobelXY(benchmark_width_ - 1, benchmark_height_,
benchmark_iterations_, +1, 0); benchmark_iterations_, disable_cpu_flags_, +1, 0);
EXPECT_EQ(0, max_diff); EXPECT_EQ(0, max_diff);
} }
TEST_F(libyuvTest, ARGBSobelXY_Unaligned) { TEST_F(libyuvTest, ARGBSobelXY_Unaligned) {
int max_diff = TestSobelXY(benchmark_width_, benchmark_height_, int max_diff = TestSobelXY(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 1); benchmark_iterations_, disable_cpu_flags_, +1, 1);
EXPECT_EQ(0, max_diff); EXPECT_EQ(0, max_diff);
} }
TEST_F(libyuvTest, ARGBSobelXY_Invert) { TEST_F(libyuvTest, ARGBSobelXY_Invert) {
int max_diff = TestSobelXY(benchmark_width_, benchmark_height_, int max_diff = TestSobelXY(benchmark_width_, benchmark_height_,
benchmark_iterations_, -1, 0); benchmark_iterations_, disable_cpu_flags_, -1, 0);
EXPECT_EQ(0, max_diff); EXPECT_EQ(0, max_diff);
} }
TEST_F(libyuvTest, ARGBSobelXY_Opt) { TEST_F(libyuvTest, ARGBSobelXY_Opt) {
int max_diff = TestSobelXY(benchmark_width_, benchmark_height_, int max_diff = TestSobelXY(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 0); benchmark_iterations_, disable_cpu_flags_, +1, 0);
EXPECT_EQ(0, max_diff); EXPECT_EQ(0, max_diff);
} }
static int TestBlur(int width, int height, int benchmark_iterations, static int TestBlur(int width, int height, int benchmark_iterations,
int invert, int off, int radius) { int disable_cpu_flags, int invert, int off, int radius) {
if (width < 1) { if (width < 1) {
width = 1; width = 1;
} }
...@@ -1795,7 +1795,7 @@ static int TestBlur(int width, int height, int benchmark_iterations, ...@@ -1795,7 +1795,7 @@ static int TestBlur(int width, int height, int benchmark_iterations,
memset(dst_argb_c, 0, kStride * height); memset(dst_argb_c, 0, kStride * height);
memset(dst_argb_opt, 0, kStride * height); memset(dst_argb_opt, 0, kStride * height);
MaskCpuFlags(0); MaskCpuFlags(disable_cpu_flags);
ARGBBlur(src_argb_a + off, kStride, ARGBBlur(src_argb_a + off, kStride,
dst_argb_c, kStride, dst_argb_c, kStride,
reinterpret_cast<int32*>(dst_cumsum), width * 4, reinterpret_cast<int32*>(dst_cumsum), width * 4,
...@@ -1826,50 +1826,50 @@ static int TestBlur(int width, int height, int benchmark_iterations, ...@@ -1826,50 +1826,50 @@ static int TestBlur(int width, int height, int benchmark_iterations,
static const int kBlurSize = 55; static const int kBlurSize = 55;
TEST_F(libyuvTest, ARGBBlur_Any) { TEST_F(libyuvTest, ARGBBlur_Any) {
int max_diff = TestBlur(benchmark_width_ - 1, benchmark_height_, int max_diff = TestBlur(benchmark_width_ - 1, benchmark_height_,
benchmark_iterations_, +1, 0, kBlurSize); benchmark_iterations_, disable_cpu_flags_, +1, 0, kBlurSize);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
TEST_F(libyuvTest, ARGBBlur_Unaligned) { TEST_F(libyuvTest, ARGBBlur_Unaligned) {
int max_diff = TestBlur(benchmark_width_, benchmark_height_, int max_diff = TestBlur(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 1, kBlurSize); benchmark_iterations_, disable_cpu_flags_, +1, 1, kBlurSize);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
TEST_F(libyuvTest, ARGBBlur_Invert) { TEST_F(libyuvTest, ARGBBlur_Invert) {
int max_diff = TestBlur(benchmark_width_, benchmark_height_, int max_diff = TestBlur(benchmark_width_, benchmark_height_,
benchmark_iterations_, -1, 0, kBlurSize); benchmark_iterations_, disable_cpu_flags_, -1, 0, kBlurSize);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
TEST_F(libyuvTest, ARGBBlur_Opt) { TEST_F(libyuvTest, ARGBBlur_Opt) {
int max_diff = TestBlur(benchmark_width_, benchmark_height_, int max_diff = TestBlur(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 0, kBlurSize); benchmark_iterations_, disable_cpu_flags_, +1, 0, kBlurSize);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
static const int kBlurSmallSize = 5; static const int kBlurSmallSize = 5;
TEST_F(libyuvTest, ARGBBlurSmall_Any) { TEST_F(libyuvTest, ARGBBlurSmall_Any) {
int max_diff = TestBlur(benchmark_width_ - 1, benchmark_height_, int max_diff = TestBlur(benchmark_width_ - 1, benchmark_height_,
benchmark_iterations_, +1, 0, kBlurSmallSize); benchmark_iterations_, disable_cpu_flags_, +1, 0, kBlurSmallSize);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
TEST_F(libyuvTest, ARGBBlurSmall_Unaligned) { TEST_F(libyuvTest, ARGBBlurSmall_Unaligned) {
int max_diff = TestBlur(benchmark_width_, benchmark_height_, int max_diff = TestBlur(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 1, kBlurSmallSize); benchmark_iterations_, disable_cpu_flags_, +1, 1, kBlurSmallSize);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
TEST_F(libyuvTest, ARGBBlurSmall_Invert) { TEST_F(libyuvTest, ARGBBlurSmall_Invert) {
int max_diff = TestBlur(benchmark_width_, benchmark_height_, int max_diff = TestBlur(benchmark_width_, benchmark_height_,
benchmark_iterations_, -1, 0, kBlurSmallSize); benchmark_iterations_, disable_cpu_flags_, -1, 0, kBlurSmallSize);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
TEST_F(libyuvTest, ARGBBlurSmall_Opt) { TEST_F(libyuvTest, ARGBBlurSmall_Opt) {
int max_diff = TestBlur(benchmark_width_, benchmark_height_, int max_diff = TestBlur(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 0, kBlurSmallSize); benchmark_iterations_, disable_cpu_flags_, +1, 0, kBlurSmallSize);
EXPECT_LE(max_diff, 1); EXPECT_LE(max_diff, 1);
} }
...@@ -1942,7 +1942,7 @@ TEST_F(libyuvTest, TestARGBPolynomial) { ...@@ -1942,7 +1942,7 @@ TEST_F(libyuvTest, TestARGBPolynomial) {
orig_pixels[i][3] = i; orig_pixels[i][3] = i;
} }
MaskCpuFlags(0); MaskCpuFlags(disable_cpu_flags_);
ARGBPolynomial(&orig_pixels[0][0], 0, &dst_pixels_c[0][0], 0, ARGBPolynomial(&orig_pixels[0][0], 0, &dst_pixels_c[0][0], 0,
&kWarmifyPolynomial[0], 1280, 1); &kWarmifyPolynomial[0], 1280, 1);
MaskCpuFlags(-1); MaskCpuFlags(-1);
...@@ -2019,7 +2019,7 @@ TEST_F(libyuvTest, TestARGBLumaColorTable) { ...@@ -2019,7 +2019,7 @@ TEST_F(libyuvTest, TestARGBLumaColorTable) {
orig_pixels[i][3] = i; orig_pixels[i][3] = i;
} }
MaskCpuFlags(0); MaskCpuFlags(disable_cpu_flags_);
ARGBLumaColorTable(&orig_pixels[0][0], 0, &dst_pixels_c[0][0], 0, ARGBLumaColorTable(&orig_pixels[0][0], 0, &dst_pixels_c[0][0], 0,
lumacolortable, 1280, 1); lumacolortable, 1280, 1);
MaskCpuFlags(-1); MaskCpuFlags(-1);
...@@ -2048,7 +2048,7 @@ TEST_F(libyuvTest, TestARGBCopyAlpha) { ...@@ -2048,7 +2048,7 @@ TEST_F(libyuvTest, TestARGBCopyAlpha) {
MemRandomize(dst_pixels_opt, kSize); MemRandomize(dst_pixels_opt, kSize);
memcpy(dst_pixels_c, dst_pixels_opt, kSize); memcpy(dst_pixels_c, dst_pixels_opt, kSize);
MaskCpuFlags(0); MaskCpuFlags(disable_cpu_flags_);
ARGBCopyAlpha(orig_pixels, benchmark_width_ * 4, ARGBCopyAlpha(orig_pixels, benchmark_width_ * 4,
dst_pixels_c, benchmark_width_ * 4, dst_pixels_c, benchmark_width_ * 4,
benchmark_width_, benchmark_height_); benchmark_width_, benchmark_height_);
...@@ -2078,7 +2078,7 @@ TEST_F(libyuvTest, TestARGBCopyYToAlpha) { ...@@ -2078,7 +2078,7 @@ TEST_F(libyuvTest, TestARGBCopyYToAlpha) {
MemRandomize(dst_pixels_opt, kPixels * 4); MemRandomize(dst_pixels_opt, kPixels * 4);
memcpy(dst_pixels_c, dst_pixels_opt, kPixels * 4); memcpy(dst_pixels_c, dst_pixels_opt, kPixels * 4);
MaskCpuFlags(0); MaskCpuFlags(disable_cpu_flags_);
ARGBCopyYToAlpha(orig_pixels, benchmark_width_, ARGBCopyYToAlpha(orig_pixels, benchmark_width_,
dst_pixels_c, benchmark_width_ * 4, dst_pixels_c, benchmark_width_ * 4,
benchmark_width_, benchmark_height_); benchmark_width_, benchmark_height_);
...@@ -2099,7 +2099,7 @@ TEST_F(libyuvTest, TestARGBCopyYToAlpha) { ...@@ -2099,7 +2099,7 @@ TEST_F(libyuvTest, TestARGBCopyYToAlpha) {
} }
static int TestARGBRect(int width, int height, int benchmark_iterations, static int TestARGBRect(int width, int height, int benchmark_iterations,
int invert, int off, int bpp) { int disable_cpu_flags, int invert, int off, int bpp) {
if (width < 1) { if (width < 1) {
width = 1; width = 1;
} }
...@@ -2113,7 +2113,7 @@ static int TestARGBRect(int width, int height, int benchmark_iterations, ...@@ -2113,7 +2113,7 @@ static int TestARGBRect(int width, int height, int benchmark_iterations,
MemRandomize(dst_argb_c + off, kSize); MemRandomize(dst_argb_c + off, kSize);
memcpy(dst_argb_opt + off, dst_argb_c + off, kSize); memcpy(dst_argb_opt + off, dst_argb_c + off, kSize);
MaskCpuFlags(0); MaskCpuFlags(disable_cpu_flags);
if (bpp == 4) { if (bpp == 4) {
ARGBRect(dst_argb_c + off, kStride, 0, 0, width, invert * height, v32); ARGBRect(dst_argb_c + off, kStride, 0, 0, width, invert * height, v32);
} else { } else {
...@@ -2144,49 +2144,49 @@ static int TestARGBRect(int width, int height, int benchmark_iterations, ...@@ -2144,49 +2144,49 @@ static int TestARGBRect(int width, int height, int benchmark_iterations,
TEST_F(libyuvTest, ARGBRect_Any) { TEST_F(libyuvTest, ARGBRect_Any) {
int max_diff = TestARGBRect(benchmark_width_ - 1, benchmark_height_, int max_diff = TestARGBRect(benchmark_width_ - 1, benchmark_height_,
benchmark_iterations_, +1, 0, 4); benchmark_iterations_, disable_cpu_flags_, +1, 0, 4);
EXPECT_EQ(0, max_diff); EXPECT_EQ(0, max_diff);
} }
TEST_F(libyuvTest, ARGBRect_Unaligned) { TEST_F(libyuvTest, ARGBRect_Unaligned) {
int max_diff = TestARGBRect(benchmark_width_, benchmark_height_, int max_diff = TestARGBRect(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 1, 4); benchmark_iterations_, disable_cpu_flags_, +1, 1, 4);
EXPECT_EQ(0, max_diff); EXPECT_EQ(0, max_diff);
} }
TEST_F(libyuvTest, ARGBRect_Invert) { TEST_F(libyuvTest, ARGBRect_Invert) {
int max_diff = TestARGBRect(benchmark_width_, benchmark_height_, int max_diff = TestARGBRect(benchmark_width_, benchmark_height_,
benchmark_iterations_, -1, 0, 4); benchmark_iterations_, disable_cpu_flags_, -1, 0, 4);
EXPECT_EQ(0, max_diff); EXPECT_EQ(0, max_diff);
} }
TEST_F(libyuvTest, ARGBRect_Opt) { TEST_F(libyuvTest, ARGBRect_Opt) {
int max_diff = TestARGBRect(benchmark_width_, benchmark_height_, int max_diff = TestARGBRect(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 0, 4); benchmark_iterations_, disable_cpu_flags_, +1, 0, 4);
EXPECT_EQ(0, max_diff); EXPECT_EQ(0, max_diff);
} }
TEST_F(libyuvTest, SetPlane_Any) { TEST_F(libyuvTest, SetPlane_Any) {
int max_diff = TestARGBRect(benchmark_width_ - 1, benchmark_height_, int max_diff = TestARGBRect(benchmark_width_ - 1, benchmark_height_,
benchmark_iterations_, +1, 0, 1); benchmark_iterations_, disable_cpu_flags_, +1, 0, 1);
EXPECT_EQ(0, max_diff); EXPECT_EQ(0, max_diff);
} }
TEST_F(libyuvTest, SetPlane_Unaligned) { TEST_F(libyuvTest, SetPlane_Unaligned) {
int max_diff = TestARGBRect(benchmark_width_, benchmark_height_, int max_diff = TestARGBRect(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 1, 1); benchmark_iterations_, disable_cpu_flags_, +1, 1, 1);
EXPECT_EQ(0, max_diff); EXPECT_EQ(0, max_diff);
} }
TEST_F(libyuvTest, SetPlane_Invert) { TEST_F(libyuvTest, SetPlane_Invert) {
int max_diff = TestARGBRect(benchmark_width_, benchmark_height_, int max_diff = TestARGBRect(benchmark_width_, benchmark_height_,
benchmark_iterations_, -1, 0, 1); benchmark_iterations_, disable_cpu_flags_, -1, 0, 1);
EXPECT_EQ(0, max_diff); EXPECT_EQ(0, max_diff);
} }
TEST_F(libyuvTest, SetPlane_Opt) { TEST_F(libyuvTest, SetPlane_Opt) {
int max_diff = TestARGBRect(benchmark_width_, benchmark_height_, int max_diff = TestARGBRect(benchmark_width_, benchmark_height_,
benchmark_iterations_, +1, 0, 1); benchmark_iterations_, disable_cpu_flags_, +1, 0, 1);
EXPECT_EQ(0, max_diff); EXPECT_EQ(0, max_diff);
} }
......
...@@ -20,7 +20,7 @@ namespace libyuv { ...@@ -20,7 +20,7 @@ namespace libyuv {
void TestRotateBpp(int src_width, int src_height, void TestRotateBpp(int src_width, int src_height,
int dst_width, int dst_height, int dst_width, int dst_height,
libyuv::RotationMode mode, libyuv::RotationMode mode,
int benchmark_iterations, int benchmark_iterations, int disable_cpu_flags,
const int kBpp) { const int kBpp) {
if (src_width < 1) { if (src_width < 1) {
src_width = 1; src_width = 1;
...@@ -49,7 +49,7 @@ void TestRotateBpp(int src_width, int src_height, ...@@ -49,7 +49,7 @@ void TestRotateBpp(int src_width, int src_height,
memset(dst_argb_opt, 3, dst_argb_plane_size); memset(dst_argb_opt, 3, dst_argb_plane_size);
if (kBpp == 1) { if (kBpp == 1) {
MaskCpuFlags(0); // Disable all CPU optimization. MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
RotatePlane(src_argb, src_stride_argb, RotatePlane(src_argb, src_stride_argb,
dst_argb_c, dst_stride_argb, dst_argb_c, dst_stride_argb,
src_width, src_height, mode); src_width, src_height, mode);
...@@ -61,7 +61,7 @@ void TestRotateBpp(int src_width, int src_height, ...@@ -61,7 +61,7 @@ void TestRotateBpp(int src_width, int src_height,
src_width, src_height, mode); src_width, src_height, mode);
} }
} else if (kBpp == 4) { } else if (kBpp == 4) {
MaskCpuFlags(0); // Disable all CPU optimization. MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
ARGBRotate(src_argb, src_stride_argb, ARGBRotate(src_argb, src_stride_argb,
dst_argb_c, dst_stride_argb, dst_argb_c, dst_stride_argb,
src_width, src_height, mode); src_width, src_height, mode);
...@@ -87,115 +87,115 @@ void TestRotateBpp(int src_width, int src_height, ...@@ -87,115 +87,115 @@ void TestRotateBpp(int src_width, int src_height,
static void ARGBTestRotate(int src_width, int src_height, static void ARGBTestRotate(int src_width, int src_height,
int dst_width, int dst_height, int dst_width, int dst_height,
libyuv::RotationMode mode, libyuv::RotationMode mode,
int benchmark_iterations) { int benchmark_iterations, int disable_cpu_flags) {
TestRotateBpp(src_width, src_height, TestRotateBpp(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
mode, benchmark_iterations, 4); mode, benchmark_iterations, disable_cpu_flags, 4);
} }
TEST_F(libyuvTest, ARGBRotate0) { TEST_F(libyuvTest, ARGBRotate0) {
ARGBTestRotate(benchmark_width_, benchmark_height_, ARGBTestRotate(benchmark_width_, benchmark_height_,
benchmark_width_, benchmark_height_, benchmark_width_, benchmark_height_,
kRotate0, benchmark_iterations_); kRotate0, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, ARGBRotate90) { TEST_F(libyuvTest, ARGBRotate90) {
ARGBTestRotate(benchmark_width_, benchmark_height_, ARGBTestRotate(benchmark_width_, benchmark_height_,
benchmark_height_, benchmark_width_, benchmark_height_, benchmark_width_,
kRotate90, benchmark_iterations_); kRotate90, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, ARGBRotate180) { TEST_F(libyuvTest, ARGBRotate180) {
ARGBTestRotate(benchmark_width_, benchmark_height_, ARGBTestRotate(benchmark_width_, benchmark_height_,
benchmark_width_, benchmark_height_, benchmark_width_, benchmark_height_,
kRotate180, benchmark_iterations_); kRotate180, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, ARGBRotate270) { TEST_F(libyuvTest, ARGBRotate270) {
ARGBTestRotate(benchmark_width_, benchmark_height_, ARGBTestRotate(benchmark_width_, benchmark_height_,
benchmark_height_, benchmark_width_, benchmark_height_, benchmark_width_,
kRotate270, benchmark_iterations_); kRotate270, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, ARGBRotate0_Odd) { TEST_F(libyuvTest, ARGBRotate0_Odd) {
ARGBTestRotate(benchmark_width_ - 3, benchmark_height_ - 1, ARGBTestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_width_ - 3, benchmark_height_ - 1, benchmark_width_ - 3, benchmark_height_ - 1,
kRotate0, benchmark_iterations_); kRotate0, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, ARGBRotate90_Odd) { TEST_F(libyuvTest, ARGBRotate90_Odd) {
ARGBTestRotate(benchmark_width_ - 3, benchmark_height_ - 1, ARGBTestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_height_ - 1, benchmark_width_ - 3, benchmark_height_ - 1, benchmark_width_ - 3,
kRotate90, benchmark_iterations_); kRotate90, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, ARGBRotate180_Odd) { TEST_F(libyuvTest, ARGBRotate180_Odd) {
ARGBTestRotate(benchmark_width_ - 3, benchmark_height_ - 1, ARGBTestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_width_ - 3, benchmark_height_ - 1, benchmark_width_ - 3, benchmark_height_ - 1,
kRotate180, benchmark_iterations_); kRotate180, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, ARGBRotate270_Odd) { TEST_F(libyuvTest, ARGBRotate270_Odd) {
ARGBTestRotate(benchmark_width_ - 3, benchmark_height_ - 1, ARGBTestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_height_ - 1, benchmark_width_ - 3, benchmark_height_ - 1, benchmark_width_ - 3,
kRotate270, benchmark_iterations_); kRotate270, benchmark_iterations_, disable_cpu_flags_);
} }
static void TestRotatePlane(int src_width, int src_height, static void TestRotatePlane(int src_width, int src_height,
int dst_width, int dst_height, int dst_width, int dst_height,
libyuv::RotationMode mode, libyuv::RotationMode mode,
int benchmark_iterations) { int benchmark_iterations, int disable_cpu_flags) {
TestRotateBpp(src_width, src_height, TestRotateBpp(src_width, src_height,
dst_width, dst_height, dst_width, dst_height,
mode, benchmark_iterations, 1); mode, benchmark_iterations, disable_cpu_flags, 1);
} }
TEST_F(libyuvTest, RotatePlane0) { TEST_F(libyuvTest, RotatePlane0) {
TestRotatePlane(benchmark_width_, benchmark_height_, TestRotatePlane(benchmark_width_, benchmark_height_,
benchmark_width_, benchmark_height_, benchmark_width_, benchmark_height_,
kRotate0, benchmark_iterations_); kRotate0, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, RotatePlane90) { TEST_F(libyuvTest, RotatePlane90) {
TestRotatePlane(benchmark_width_, benchmark_height_, TestRotatePlane(benchmark_width_, benchmark_height_,
benchmark_height_, benchmark_width_, benchmark_height_, benchmark_width_,
kRotate90, benchmark_iterations_); kRotate90, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, RotatePlane180) { TEST_F(libyuvTest, RotatePlane180) {
TestRotatePlane(benchmark_width_, benchmark_height_, TestRotatePlane(benchmark_width_, benchmark_height_,
benchmark_width_, benchmark_height_, benchmark_width_, benchmark_height_,
kRotate180, benchmark_iterations_); kRotate180, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, RotatePlane270) { TEST_F(libyuvTest, RotatePlane270) {
TestRotatePlane(benchmark_width_, benchmark_height_, TestRotatePlane(benchmark_width_, benchmark_height_,
benchmark_height_, benchmark_width_, benchmark_height_, benchmark_width_,
kRotate270, benchmark_iterations_); kRotate270, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, RotatePlane0_Odd) { TEST_F(libyuvTest, RotatePlane0_Odd) {
TestRotatePlane(benchmark_width_ - 3, benchmark_height_ - 1, TestRotatePlane(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_width_ - 3, benchmark_height_ - 1, benchmark_width_ - 3, benchmark_height_ - 1,
kRotate0, benchmark_iterations_); kRotate0, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, RotatePlane90_Odd) { TEST_F(libyuvTest, RotatePlane90_Odd) {
TestRotatePlane(benchmark_width_ - 3, benchmark_height_ - 1, TestRotatePlane(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_height_ - 1, benchmark_width_ - 3, benchmark_height_ - 1, benchmark_width_ - 3,
kRotate90, benchmark_iterations_); kRotate90, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, RotatePlane180_Odd) { TEST_F(libyuvTest, RotatePlane180_Odd) {
TestRotatePlane(benchmark_width_ - 3, benchmark_height_ - 1, TestRotatePlane(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_width_ - 3, benchmark_height_ - 1, benchmark_width_ - 3, benchmark_height_ - 1,
kRotate180, benchmark_iterations_); kRotate180, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, RotatePlane270_Odd) { TEST_F(libyuvTest, RotatePlane270_Odd) {
TestRotatePlane(benchmark_width_ - 3, benchmark_height_ - 1, TestRotatePlane(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_height_ - 1, benchmark_width_ - 3, benchmark_height_ - 1, benchmark_width_ - 3,
kRotate270, benchmark_iterations_); kRotate270, benchmark_iterations_, disable_cpu_flags_);
} }
} // namespace libyuv } // namespace libyuv
...@@ -20,7 +20,7 @@ namespace libyuv { ...@@ -20,7 +20,7 @@ namespace libyuv {
static void I420TestRotate(int src_width, int src_height, static void I420TestRotate(int src_width, int src_height,
int dst_width, int dst_height, int dst_width, int dst_height,
libyuv::RotationMode mode, libyuv::RotationMode mode,
int benchmark_iterations) { int benchmark_iterations, int disable_cpu_flags) {
if (src_width < 1) { if (src_width < 1) {
src_width = 1; src_width = 1;
} }
...@@ -49,7 +49,7 @@ static void I420TestRotate(int src_width, int src_height, ...@@ -49,7 +49,7 @@ static void I420TestRotate(int src_width, int src_height,
memset(dst_i420_c, 2, dst_i420_size); memset(dst_i420_c, 2, dst_i420_size);
memset(dst_i420_opt, 3, dst_i420_size); memset(dst_i420_opt, 3, dst_i420_size);
MaskCpuFlags(0); // Disable all CPU optimization. MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
I420Rotate(src_i420, src_width, I420Rotate(src_i420, src_width,
src_i420 + src_i420_y_size, (src_width + 1) / 2, src_i420 + src_i420_y_size, (src_width + 1) / 2,
src_i420 + src_i420_y_size + src_i420_uv_size, (src_width + 1) / 2, src_i420 + src_i420_y_size + src_i420_uv_size, (src_width + 1) / 2,
...@@ -85,55 +85,55 @@ static void I420TestRotate(int src_width, int src_height, ...@@ -85,55 +85,55 @@ static void I420TestRotate(int src_width, int src_height,
TEST_F(libyuvTest, I420Rotate0) { TEST_F(libyuvTest, I420Rotate0) {
I420TestRotate(benchmark_width_, benchmark_height_, I420TestRotate(benchmark_width_, benchmark_height_,
benchmark_width_, benchmark_height_, benchmark_width_, benchmark_height_,
kRotate0, benchmark_iterations_); kRotate0, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, I420Rotate90) { TEST_F(libyuvTest, I420Rotate90) {
I420TestRotate(benchmark_width_, benchmark_height_, I420TestRotate(benchmark_width_, benchmark_height_,
benchmark_height_, benchmark_width_, benchmark_height_, benchmark_width_,
kRotate90, benchmark_iterations_); kRotate90, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, I420Rotate180) { TEST_F(libyuvTest, I420Rotate180) {
I420TestRotate(benchmark_width_, benchmark_height_, I420TestRotate(benchmark_width_, benchmark_height_,
benchmark_width_, benchmark_height_, benchmark_width_, benchmark_height_,
kRotate180, benchmark_iterations_); kRotate180, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, I420Rotate270) { TEST_F(libyuvTest, I420Rotate270) {
I420TestRotate(benchmark_width_, benchmark_height_, I420TestRotate(benchmark_width_, benchmark_height_,
benchmark_height_, benchmark_width_, benchmark_height_, benchmark_width_,
kRotate270, benchmark_iterations_); kRotate270, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, I420Rotate0_Odd) { TEST_F(libyuvTest, I420Rotate0_Odd) {
I420TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, I420TestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_width_ - 3, benchmark_height_ - 1, benchmark_width_ - 3, benchmark_height_ - 1,
kRotate0, benchmark_iterations_); kRotate0, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, I420Rotate90_Odd) { TEST_F(libyuvTest, I420Rotate90_Odd) {
I420TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, I420TestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_height_ - 1, benchmark_width_ - 3, benchmark_height_ - 1, benchmark_width_ - 3,
kRotate90, benchmark_iterations_); kRotate90, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, I420Rotate180_Odd) { TEST_F(libyuvTest, I420Rotate180_Odd) {
I420TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, I420TestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_width_ - 3, benchmark_height_ - 1, benchmark_width_ - 3, benchmark_height_ - 1,
kRotate180, benchmark_iterations_); kRotate180, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, I420Rotate270_Odd) { TEST_F(libyuvTest, I420Rotate270_Odd) {
I420TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, I420TestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_height_ - 1, benchmark_width_ - 3, benchmark_height_ - 1, benchmark_width_ - 3,
kRotate270, benchmark_iterations_); kRotate270, benchmark_iterations_, disable_cpu_flags_);
} }
static void NV12TestRotate(int src_width, int src_height, static void NV12TestRotate(int src_width, int src_height,
int dst_width, int dst_height, int dst_width, int dst_height,
libyuv::RotationMode mode, libyuv::RotationMode mode,
int benchmark_iterations) { int benchmark_iterations, int disable_cpu_flags) {
if (src_width < 1) { if (src_width < 1) {
src_width = 1; src_width = 1;
} }
...@@ -162,7 +162,7 @@ static void NV12TestRotate(int src_width, int src_height, ...@@ -162,7 +162,7 @@ static void NV12TestRotate(int src_width, int src_height,
memset(dst_i420_c, 2, dst_i420_size); memset(dst_i420_c, 2, dst_i420_size);
memset(dst_i420_opt, 3, dst_i420_size); memset(dst_i420_opt, 3, dst_i420_size);
MaskCpuFlags(0); // Disable all CPU optimization. MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
NV12ToI420Rotate(src_nv12, src_width, NV12ToI420Rotate(src_nv12, src_width,
src_nv12 + src_nv12_y_size, (src_width + 1) & ~1, src_nv12 + src_nv12_y_size, (src_width + 1) & ~1,
dst_i420_c, dst_width, dst_i420_c, dst_width,
...@@ -195,49 +195,49 @@ static void NV12TestRotate(int src_width, int src_height, ...@@ -195,49 +195,49 @@ static void NV12TestRotate(int src_width, int src_height,
TEST_F(libyuvTest, NV12Rotate0) { TEST_F(libyuvTest, NV12Rotate0) {
NV12TestRotate(benchmark_width_, benchmark_height_, NV12TestRotate(benchmark_width_, benchmark_height_,
benchmark_width_, benchmark_height_, benchmark_width_, benchmark_height_,
kRotate0, benchmark_iterations_); kRotate0, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, NV12Rotate90) { TEST_F(libyuvTest, NV12Rotate90) {
NV12TestRotate(benchmark_width_, benchmark_height_, NV12TestRotate(benchmark_width_, benchmark_height_,
benchmark_height_, benchmark_width_, benchmark_height_, benchmark_width_,
kRotate90, benchmark_iterations_); kRotate90, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, NV12Rotate180) { TEST_F(libyuvTest, NV12Rotate180) {
NV12TestRotate(benchmark_width_, benchmark_height_, NV12TestRotate(benchmark_width_, benchmark_height_,
benchmark_width_, benchmark_height_, benchmark_width_, benchmark_height_,
kRotate180, benchmark_iterations_); kRotate180, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, NV12Rotate270) { TEST_F(libyuvTest, NV12Rotate270) {
NV12TestRotate(benchmark_width_, benchmark_height_, NV12TestRotate(benchmark_width_, benchmark_height_,
benchmark_height_, benchmark_width_, benchmark_height_, benchmark_width_,
kRotate270, benchmark_iterations_); kRotate270, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, NV12Rotate0_Odd) { TEST_F(libyuvTest, NV12Rotate0_Odd) {
NV12TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, NV12TestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_width_ - 3, benchmark_height_ - 1, benchmark_width_ - 3, benchmark_height_ - 1,
kRotate0, benchmark_iterations_); kRotate0, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, NV12Rotate90_Odd) { TEST_F(libyuvTest, NV12Rotate90_Odd) {
NV12TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, NV12TestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_height_ - 1, benchmark_width_ - 3, benchmark_height_ - 1, benchmark_width_ - 3,
kRotate90, benchmark_iterations_); kRotate90, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, NV12Rotate180_Odd) { TEST_F(libyuvTest, NV12Rotate180_Odd) {
NV12TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, NV12TestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_width_ - 3, benchmark_height_ - 1, benchmark_width_ - 3, benchmark_height_ - 1,
kRotate180, benchmark_iterations_); kRotate180, benchmark_iterations_, disable_cpu_flags_);
} }
TEST_F(libyuvTest, NV12Rotate270_Odd) { TEST_F(libyuvTest, NV12Rotate270_Odd) {
NV12TestRotate(benchmark_width_ - 3, benchmark_height_ - 1, NV12TestRotate(benchmark_width_ - 3, benchmark_height_ - 1,
benchmark_height_ - 1, benchmark_width_ - 3, benchmark_height_ - 1, benchmark_width_ - 3,
kRotate270, benchmark_iterations_); kRotate270, benchmark_iterations_, disable_cpu_flags_);
} }
} // namespace libyuv } // namespace libyuv
...@@ -21,7 +21,8 @@ namespace libyuv { ...@@ -21,7 +21,8 @@ namespace libyuv {
// Test scaling with C vs Opt and return maximum pixel difference. 0 = exact. // Test scaling with C vs Opt and return maximum pixel difference. 0 = exact.
static int ARGBTestFilter(int src_width, int src_height, static int ARGBTestFilter(int src_width, int src_height,
int dst_width, int dst_height, int dst_width, int dst_height,
FilterMode f, int benchmark_iterations) { FilterMode f, int benchmark_iterations,
int disable_cpu_flags) {
int i, j; int i, j;
const int b = 0; // 128 to test for padding/stride. const int b = 0; // 128 to test for padding/stride.
int src_argb_plane_size = (Abs(src_width) + b * 2) * int src_argb_plane_size = (Abs(src_width) + b * 2) *
...@@ -41,7 +42,7 @@ static int ARGBTestFilter(int src_width, int src_height, ...@@ -41,7 +42,7 @@ static int ARGBTestFilter(int src_width, int src_height,
memset(dst_argb_opt, 3, dst_argb_plane_size); memset(dst_argb_opt, 3, dst_argb_plane_size);
// Warm up both versions for consistent benchmarks. // Warm up both versions for consistent benchmarks.
MaskCpuFlags(0); // Disable all CPU optimization. MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb, ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb,
src_width, src_height, src_width, src_height,
dst_argb_c + (dst_stride_argb * b) + b * 4, dst_stride_argb, dst_argb_c + (dst_stride_argb * b) + b * 4, dst_stride_argb,
...@@ -52,7 +53,7 @@ static int ARGBTestFilter(int src_width, int src_height, ...@@ -52,7 +53,7 @@ static int ARGBTestFilter(int src_width, int src_height,
dst_argb_opt + (dst_stride_argb * b) + b * 4, dst_stride_argb, dst_argb_opt + (dst_stride_argb * b) + b * 4, dst_stride_argb,
dst_width, dst_height, f); dst_width, dst_height, f);
MaskCpuFlags(0); // Disable all CPU optimization. MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
double c_time = get_time(); double c_time = get_time();
ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb, ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb,
src_width, src_height, src_width, src_height,
...@@ -200,7 +201,8 @@ static int ARGBClipTestFilter(int src_width, int src_height, ...@@ -200,7 +201,8 @@ static int ARGBClipTestFilter(int src_width, int src_height,
int diff = ARGBTestFilter(benchmark_width_, benchmark_height_, \ int diff = ARGBTestFilter(benchmark_width_, benchmark_height_, \
Abs(benchmark_width_) * hfactor, \ Abs(benchmark_width_) * hfactor, \
Abs(benchmark_height_) * vfactor, \ Abs(benchmark_height_) * vfactor, \
kFilter##filter, benchmark_iterations_); \ kFilter##filter, benchmark_iterations_, \
disable_cpu_flags_); \
EXPECT_LE(diff, max_diff); \ EXPECT_LE(diff, max_diff); \
} \ } \
TEST_F(libyuvTest, ARGBScaleDownClipBy##name##_##filter) { \ TEST_F(libyuvTest, ARGBScaleDownClipBy##name##_##filter) { \
...@@ -231,13 +233,15 @@ TEST_FACTOR(3by8, 3 / 8, 3 / 8) ...@@ -231,13 +233,15 @@ TEST_FACTOR(3by8, 3 / 8, 3 / 8)
TEST_F(libyuvTest, name##To##width##x##height##_##filter) { \ TEST_F(libyuvTest, name##To##width##x##height##_##filter) { \
int diff = ARGBTestFilter(benchmark_width_, benchmark_height_, \ int diff = ARGBTestFilter(benchmark_width_, benchmark_height_, \
width, height, \ width, height, \
kFilter##filter, benchmark_iterations_); \ kFilter##filter, benchmark_iterations_, \
disable_cpu_flags_); \
EXPECT_LE(diff, max_diff); \ EXPECT_LE(diff, max_diff); \
} \ } \
TEST_F(libyuvTest, name##From##width##x##height##_##filter) { \ TEST_F(libyuvTest, name##From##width##x##height##_##filter) { \
int diff = ARGBTestFilter(width, height, \ int diff = ARGBTestFilter(width, height, \
Abs(benchmark_width_), Abs(benchmark_height_), \ Abs(benchmark_width_), Abs(benchmark_height_), \
kFilter##filter, benchmark_iterations_); \ kFilter##filter, benchmark_iterations_, \
disable_cpu_flags_); \
EXPECT_LE(diff, max_diff); \ EXPECT_LE(diff, max_diff); \
} \ } \
TEST_F(libyuvTest, name##ClipTo##width##x##height##_##filter) { \ TEST_F(libyuvTest, name##ClipTo##width##x##height##_##filter) { \
......
...@@ -20,7 +20,8 @@ namespace libyuv { ...@@ -20,7 +20,8 @@ namespace libyuv {
// Test scaling with C vs Opt and return maximum pixel difference. 0 = exact. // Test scaling with C vs Opt and return maximum pixel difference. 0 = exact.
static int TestFilter(int src_width, int src_height, static int TestFilter(int src_width, int src_height,
int dst_width, int dst_height, int dst_width, int dst_height,
FilterMode f, int benchmark_iterations) { FilterMode f, int benchmark_iterations,
int disable_cpu_flags) {
int i, j; int i, j;
const int b = 0; // 128 to test for padding/stride. const int b = 0; // 128 to test for padding/stride.
int src_width_uv = (Abs(src_width) + 1) >> 1; int src_width_uv = (Abs(src_width) + 1) >> 1;
...@@ -56,8 +57,7 @@ static int TestFilter(int src_width, int src_height, ...@@ -56,8 +57,7 @@ static int TestFilter(int src_width, int src_height,
align_buffer_page_end(dst_u_opt, dst_uv_plane_size) align_buffer_page_end(dst_u_opt, dst_uv_plane_size)
align_buffer_page_end(dst_v_opt, dst_uv_plane_size) align_buffer_page_end(dst_v_opt, dst_uv_plane_size)
MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
MaskCpuFlags(0); // Disable all CPU optimization.
double c_time = get_time(); double c_time = get_time();
I420Scale(src_y + (src_stride_y * b) + b, src_stride_y, I420Scale(src_y + (src_stride_y * b) + b, src_stride_y,
src_u + (src_stride_uv * b) + b, src_stride_uv, src_u + (src_stride_uv * b) + b, src_stride_uv,
...@@ -265,7 +265,8 @@ static int TestFilter_16(int src_width, int src_height, ...@@ -265,7 +265,8 @@ static int TestFilter_16(int src_width, int src_height,
int diff = TestFilter(benchmark_width_, benchmark_height_, \ int diff = TestFilter(benchmark_width_, benchmark_height_, \
Abs(benchmark_width_) * hfactor, \ Abs(benchmark_width_) * hfactor, \
Abs(benchmark_height_) * vfactor, \ Abs(benchmark_height_) * vfactor, \
kFilter##filter, benchmark_iterations_); \ kFilter##filter, benchmark_iterations_, \
disable_cpu_flags_); \
EXPECT_LE(diff, max_diff); \ EXPECT_LE(diff, max_diff); \
} \ } \
TEST_F(libyuvTest, ScaleDownBy##name##_##filter##_16) { \ TEST_F(libyuvTest, ScaleDownBy##name##_##filter##_16) { \
...@@ -296,13 +297,15 @@ TEST_FACTOR(3by8, 3 / 8, 3 / 8) ...@@ -296,13 +297,15 @@ TEST_FACTOR(3by8, 3 / 8, 3 / 8)
TEST_F(libyuvTest, name##To##width##x##height##_##filter) { \ TEST_F(libyuvTest, name##To##width##x##height##_##filter) { \
int diff = TestFilter(benchmark_width_, benchmark_height_, \ int diff = TestFilter(benchmark_width_, benchmark_height_, \
width, height, \ width, height, \
kFilter##filter, benchmark_iterations_); \ kFilter##filter, benchmark_iterations_, \
disable_cpu_flags_); \
EXPECT_LE(diff, max_diff); \ EXPECT_LE(diff, max_diff); \
} \ } \
TEST_F(libyuvTest, name##From##width##x##height##_##filter) { \ TEST_F(libyuvTest, name##From##width##x##height##_##filter) { \
int diff = TestFilter(width, height, \ int diff = TestFilter(width, height, \
Abs(benchmark_width_), Abs(benchmark_height_), \ Abs(benchmark_width_), Abs(benchmark_height_), \
kFilter##filter, benchmark_iterations_); \ kFilter##filter, benchmark_iterations_, \
disable_cpu_flags_); \
EXPECT_LE(diff, max_diff); \ EXPECT_LE(diff, max_diff); \
} \ } \
TEST_F(libyuvTest, name##To##width##x##height##_##filter##_16) { \ TEST_F(libyuvTest, name##To##width##x##height##_##filter##_16) { \
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
libyuvTest::libyuvTest() : rotate_max_w_(128), rotate_max_h_(128), libyuvTest::libyuvTest() : rotate_max_w_(128), rotate_max_h_(128),
benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128), benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128),
benchmark_height_(72) { benchmark_height_(72), disable_cpu_flags_(0) {
const char* repeat = getenv("LIBYUV_REPEAT"); const char* repeat = getenv("LIBYUV_REPEAT");
if (repeat) { if (repeat) {
benchmark_iterations_ = atoi(repeat); // NOLINT benchmark_iterations_ = atoi(repeat); // NOLINT
...@@ -39,6 +39,10 @@ libyuvTest::libyuvTest() : rotate_max_w_(128), rotate_max_h_(128), ...@@ -39,6 +39,10 @@ libyuvTest::libyuvTest() : rotate_max_w_(128), rotate_max_h_(128),
if (height) { if (height) {
benchmark_height_ = atoi(height); // NOLINT benchmark_height_ = atoi(height); // NOLINT
} }
const char* cpu_flags = getenv("LIBYUV_FLAGS");
if (cpu_flags) {
disable_cpu_flags_ = atoi(cpu_flags); // NOLINT
}
benchmark_pixels_div256_ = static_cast<int>(( benchmark_pixels_div256_ = static_cast<int>((
static_cast<double>(Abs(benchmark_width_)) * static_cast<double>(Abs(benchmark_width_)) *
static_cast<double>(Abs(benchmark_height_)) * static_cast<double>(Abs(benchmark_height_)) *
......
...@@ -81,6 +81,7 @@ class libyuvTest : public ::testing::Test { ...@@ -81,6 +81,7 @@ class libyuvTest : public ::testing::Test {
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA. int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
int benchmark_pixels_div256_; // Total pixels to benchmark / 256. int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280. int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
int disable_cpu_flags_; // Default 0. Use -1 for benchmarking.
}; };
#endif // UNIT_TEST_UNIT_TEST_H_ NOLINT #endif // UNIT_TEST_UNIT_TEST_H_ NOLINT
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