From b00d40160a5a5d78a014ebbbdc4ced728d0f9cc5 Mon Sep 17 00:00:00 2001 From: Frank Barchard Date: Fri, 27 May 2016 18:02:47 -0700 Subject: [PATCH] make unittest allocator align to 64 bytes. blur requires memory be aligned. change the unittest allocator to guarantee 64 byte alignment. re-enable blur any test that fails if memory is unaligned. TBR=harryjin@google.com BUG=libyuv:596,libyuv:594 TESTED=local build passes with row.h removed from tests. Review URL: https://codereview.chromium.org/2019753002 . --- README.chromium | 2 +- include/libyuv/version.h | 2 +- source/planar_functions.cc | 4 +--- source/row_win.cc | 1 + unit_test/planar_test.cc | 2 +- unit_test/unit_test.cc | 2 +- unit_test/unit_test.h | 6 +++--- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/README.chromium b/README.chromium index 985e74df7..979ed8d70 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 1591 +Version: 1592 License: BSD License File: LICENSE diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 20220ec79..ab3aa363e 100644 --- a/include/libyuv/version.h +++ b/include/libyuv/version.h @@ -11,6 +11,6 @@ #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #define INCLUDE_LIBYUV_VERSION_H_ -#define LIBYUV_VERSION 1591 +#define LIBYUV_VERSION 1592 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/source/planar_functions.cc b/source/planar_functions.cc index 2e2351aaf..b1b1f2c83 100644 --- a/source/planar_functions.cc +++ b/source/planar_functions.cc @@ -1744,9 +1744,7 @@ int ARGBBlur(const uint8* src_argb, int src_stride_argb, #if defined(HAS_CUMULATIVESUMTOAVERAGEROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { ComputeCumulativeSumRow = ComputeCumulativeSumRow_SSE2; - if (IS_ALIGNED(dst_cumsum, 16)) { - CumulativeSumToAverageRow = CumulativeSumToAverageRow_SSE2; - } + CumulativeSumToAverageRow = CumulativeSumToAverageRow_SSE2; } #endif // Compute enough CumulativeSum for first row to be blurred. After this diff --git a/source/row_win.cc b/source/row_win.cc index dc325fb97..cdb760603 100644 --- a/source/row_win.cc +++ b/source/row_win.cc @@ -5275,6 +5275,7 @@ void SobelXYRow_SSE2(const uint8* src_sobelx, const uint8* src_sobely, // dst points to pixel to store result to. // count is number of averaged pixels to produce. // Does 4 pixels at a time. +// This function requires alignment on accumulation buffer pointers. void CumulativeSumToAverageRow_SSE2(const int32* topleft, const int32* botleft, int width, int area, uint8* dst, int count) { diff --git a/unit_test/planar_test.cc b/unit_test/planar_test.cc index d2ae35d05..bc0eebb52 100644 --- a/unit_test/planar_test.cc +++ b/unit_test/planar_test.cc @@ -1929,7 +1929,7 @@ static int TestBlur(int width, int height, int benchmark_iterations, } static const int kBlurSize = 55; -TEST_F(LibYUVPlanarTest, DISABLED_ARGBBlur_Any) { +TEST_F(LibYUVPlanarTest, ARGBBlur_Any) { int max_diff = TestBlur(benchmark_width_ - 1, benchmark_height_, benchmark_iterations_, disable_cpu_flags_, benchmark_cpu_info_, diff --git a/unit_test/unit_test.cc b/unit_test/unit_test.cc index c98c285cb..95398285c 100644 --- a/unit_test/unit_test.cc +++ b/unit_test/unit_test.cc @@ -34,7 +34,7 @@ DEFINE_int32(libyuv_cpu_info, -1, // Set flags to -1 for benchmarking to avoid slower C code. LibYUVConvertTest::LibYUVConvertTest() : - benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(130), + benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128), benchmark_height_(72), disable_cpu_flags_(1), benchmark_cpu_info_(-1) { const char* repeat = getenv("LIBYUV_REPEAT"); if (repeat) { diff --git a/unit_test/unit_test.h b/unit_test/unit_test.h index 51e938df8..f2c4bef00 100644 --- a/unit_test/unit_test.h +++ b/unit_test/unit_test.h @@ -67,9 +67,9 @@ static inline bool SizeValid(int src_width, int src_height, #define align_buffer_page_end(var, size) \ uint8* var; \ uint8* var##_mem; \ - var##_mem = reinterpret_cast(malloc((((size) + 4095) & ~4095) + \ - OFFBY)); \ - var = var##_mem + (-(size) & 4095) + OFFBY; + var##_mem = reinterpret_cast(malloc(((size) + 4095 + 63) & ~4095)); \ + var = (uint8*)((intptr_t)(var##_mem + (((size) + 4095 + 63) & ~4095) - \ + (size)) & ~63); #define free_aligned_buffer_page_end(var) \ free(var##_mem); \