Tweak fix for aom_highbd_convolve_copy_neon() bug Use memmove() instead of memcpy(), as in aom_highbd_convolve_copy_c() and aom_highbd_convolve_copy_avx2(). I don't know if the src and dst buffers may actually overlap, but it's good to be consistent. Revert the new tests that use unaligned dst buffers, because aom_highbd_convolve_copy_sse2() calls _mm_store_si128(), which requires 16-byte alignment. Bug: 349832592 Change-Id: Ieddb00d39385fb690a4997ad0f9dbd2bfac946d7 (cherry picked from commit dd1e6c7806d041948fdc355ee6d78e33c829b150)
diff --git a/aom_dsp/arm/aom_convolve_copy_neon.c b/aom_dsp/arm/aom_convolve_copy_neon.c index 02f7cd2..db084d5 100644 --- a/aom_dsp/arm/aom_convolve_copy_neon.c +++ b/aom_dsp/arm/aom_convolve_copy_neon.c
@@ -58,11 +58,11 @@ int h) { if (w < 4) { // copy2 do { - memcpy(dst, src, 4); + memmove(dst, src, 2 * sizeof(*src)); src += src_stride; dst += dst_stride; - memcpy(dst, src, 4); + memmove(dst, src, 2 * sizeof(*src)); src += src_stride; dst += dst_stride; h -= 2;
diff --git a/test/av1_convolve_test.cc b/test/av1_convolve_test.cc index 1bd6905..14da82e 100644 --- a/test/av1_convolve_test.cc +++ b/test/av1_convolve_test.cc
@@ -11,8 +11,6 @@ #include <cstddef> #include <cstdint> -#include <memory> -#include <new> #include <ostream> #include <set> #include <vector> @@ -222,12 +220,12 @@ // Check that two 8-bit output buffers are identical. void AssertOutputBufferEq(const uint8_t *p1, const uint8_t *p2, int width, - int height, ptrdiff_t stride = kOutputStride) { + int height) { ASSERT_TRUE(p1 != p2) << "Buffers must be at different memory locations"; for (int j = 0; j < height; ++j) { if (memcmp(p1, p2, sizeof(*p1) * width) == 0) { - p1 += stride; - p2 += stride; + p1 += kOutputStride; + p2 += kOutputStride; continue; } for (int i = 0; i < width; ++i) { @@ -240,12 +238,12 @@ // Check that two 16-bit output buffers are identical. void AssertOutputBufferEq(const uint16_t *p1, const uint16_t *p2, int width, - int height, ptrdiff_t stride = kOutputStride) { + int height) { ASSERT_TRUE(p1 != p2) << "Buffers must be in different memory locations"; for (int j = 0; j < height; ++j) { if (memcmp(p1, p2, sizeof(*p1) * width) == 0) { - p1 += stride; - p2 += stride; + p1 += kOutputStride; + p2 += kOutputStride; continue; } for (int i = 0; i < width; ++i) { @@ -1112,17 +1110,6 @@ DECLARE_ALIGNED(32, uint8_t, test[MAX_SB_SQUARE]); GetParam().TestFunction()(input, width, test, kOutputStride, width, height); AssertOutputBufferEq(reference, test, width, height); - - // Test again with dst_stride=width. - std::unique_ptr<uint8_t[]> reference2(new (std::nothrow) - uint8_t[width * height]); - ASSERT_NE(reference2, nullptr); - aom_convolve_copy_c(input, width, reference2.get(), width, width, height); - std::unique_ptr<uint8_t[]> test2(new (std::nothrow) - uint8_t[width * height]); - ASSERT_NE(test2, nullptr); - GetParam().TestFunction()(input, width, test2.get(), width, width, height); - AssertOutputBufferEq(reference2.get(), test2.get(), width, height, width); } }; @@ -1170,18 +1157,6 @@ DECLARE_ALIGNED(32, uint16_t, test[MAX_SB_SQUARE]); GetParam().TestFunction()(input, width, test, kOutputStride, width, height); AssertOutputBufferEq(reference, test, width, height); - - // Test again with dst_stride=width. - std::unique_ptr<uint16_t[]> reference2(new (std::nothrow) - uint16_t[width * height]); - ASSERT_NE(reference2, nullptr); - aom_highbd_convolve_copy_c(input, width, reference2.get(), width, width, - height); - std::unique_ptr<uint16_t[]> test2(new (std::nothrow) - uint16_t[width * height]); - ASSERT_NE(test2, nullptr); - GetParam().TestFunction()(input, width, test2.get(), width, width, height); - AssertOutputBufferEq(reference2.get(), test2.get(), width, height, width); } };