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,
......
This diff is collapsed.
This diff is collapsed.
...@@ -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