Commit 2b022abbd7 for aom
commit 2b022abbd7b9d03e86d17cbabbb443a6a0941448
Author: Wan-Teh Chang <wtc@google.com>
Date: Wed Jul 8 12:59:20 2026 -0700
sum_squares_sve: Call funcs under right conditions
Some functions in sum_squares_sve.c require `height` to be an even
number. Some also work when `width` is not only 8 or 16 but also a
multiple of 8 or 16. Call such functions under the right conditions.
Bug: 527078408
Change-Id: Ie4c31c2a41aac964e7d8807ece69bad3550b5312
diff --git a/aom_dsp/arm/sum_squares_sve.c b/aom_dsp/arm/sum_squares_sve.c
index 450fb029b5..9f4bd82be8 100644
--- a/aom_dsp/arm/sum_squares_sve.c
+++ b/aom_dsp/arm/sum_squares_sve.c
@@ -104,10 +104,10 @@ static inline uint64_t aom_sum_squares_2d_i16_wxh_sve(const int16_t *src,
uint64_t aom_sum_squares_2d_i16_sve(const int16_t *src, int stride, int width,
int height) {
- if (width == 4) {
+ if (width == 4 && height % 2 == 0) {
return aom_sum_squares_2d_i16_4xh_sve(src, stride, height);
}
- if (width == 8) {
+ if (width == 8 && height % 2 == 0) {
return aom_sum_squares_2d_i16_8xh_sve(src, stride, height);
}
if (width % 16 == 0) {
@@ -225,9 +225,9 @@ uint64_t aom_sum_sse_2d_i16_sve(const int16_t *src, int stride, int width,
int height, int *sum) {
uint64_t sse;
- if (width == 4) {
+ if (width == 4 && height % 2 == 0) {
sse = aom_sum_sse_2d_i16_4xh_sve(src, stride, height, sum);
- } else if (width == 8) {
+ } else if (width == 8 && height % 2 == 0) {
sse = aom_sum_sse_2d_i16_8xh_sve(src, stride, height, sum);
} else if (width % 16 == 0) {
sse = aom_sum_sse_2d_i16_16xh_sve(src, stride, width, height, sum);
@@ -240,7 +240,7 @@ uint64_t aom_sum_sse_2d_i16_sve(const int16_t *src, int stride, int width,
#if CONFIG_AV1_HIGHBITDEPTH
static inline uint64_t aom_var_2d_u16_4xh_sve(uint8_t *src, int src_stride,
- int width, int height) {
+ int height) {
uint16_t *src_u16 = CONVERT_TO_SHORTPTR(src);
uint64_t sum = 0;
uint64_t sse = 0;
@@ -263,7 +263,7 @@ static inline uint64_t aom_var_2d_u16_4xh_sve(uint8_t *src, int src_stride,
sum += vaddlvq_u32(sum_u32);
sse += vaddvq_u64(sse_u64);
- return sse - sum * sum / (width * height);
+ return sse - sum * sum / (4 * height);
}
static inline uint64_t aom_var_2d_u16_8xh_sve(uint8_t *src, int src_stride,
@@ -388,17 +388,17 @@ static inline uint64_t aom_var_2d_u16_large_sve(uint8_t *src, int src_stride,
uint64_t aom_var_2d_u16_sve(uint8_t *src, int src_stride, int width,
int height) {
- if (width == 4) {
- return aom_var_2d_u16_4xh_sve(src, src_stride, width, height);
+ if (width == 4 && height % 2 == 0) {
+ return aom_var_2d_u16_4xh_sve(src, src_stride, height);
}
- if (width == 8) {
- return aom_var_2d_u16_8xh_sve(src, src_stride, width, height);
+ if (width % 32 == 0) {
+ return aom_var_2d_u16_large_sve(src, src_stride, width, height);
}
- if (width == 16) {
+ if (width % 16 == 0) {
return aom_var_2d_u16_16xh_sve(src, src_stride, width, height);
}
- if (width % 32 == 0) {
- return aom_var_2d_u16_large_sve(src, src_stride, width, height);
+ if (width % 8 == 0) {
+ return aom_var_2d_u16_8xh_sve(src, src_stride, width, height);
}
return aom_var_2d_u16_neon(src, src_stride, width, height);
}
diff --git a/test/sse_sum_test.cc b/test/sse_sum_test.cc
index 8b33cf1850..c35770c063 100644
--- a/test/sse_sum_test.cc
+++ b/test/sse_sum_test.cc
@@ -50,7 +50,7 @@ class SumSSETest : public ::testing::TestWithParam<TestFuncs> {
}
void TearDown() override { aom_free(src_); }
- void RunTest(int isRandom);
+ void RunTest(int is_random, int multiple_of_4);
void RunSpeedTest();
void GenRandomData(int width, int height, int stride) {
@@ -82,15 +82,17 @@ class SumSSETest : public ::testing::TestWithParam<TestFuncs> {
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(SumSSETest);
-void SumSSETest::RunTest(int isRandom) {
+void SumSSETest::RunTest(int is_random, int multiple_of_4) {
for (int k = 0; k < kNumIterations; k++) {
- const int width = 4 * (rnd_(31) + 1); // Up to 128x128
- const int height = 4 * (rnd_(31) + 1); // Up to 128x128
- int stride = 4 << rnd_(7); // Up to 256 stride
- while (stride < width) { // Make sure it's valid
+ // Up to 128x128
+ const int width = multiple_of_4 ? 4 * (rnd_(31) + 1) : rnd_(127) + 1;
+ // Up to 128x128
+ const int height = multiple_of_4 ? 4 * (rnd_(31) + 1) : rnd_(127) + 1;
+ int stride = 4 << rnd_(7); // Up to 256 stride
+ while (stride < width) { // Make sure it's valid
stride = 4 << rnd_(7);
}
- if (isRandom) {
+ if (is_random) {
GenRandomData(width, height, stride);
} else {
GenExtremeData(width, height, stride);
@@ -145,11 +147,16 @@ void SumSSETest::RunSpeedTest() {
}
TEST_P(SumSSETest, OperationCheck) {
- RunTest(1); // GenRandomData
+ RunTest(1, 1); // GenRandomData, width and height multiple of 4
}
TEST_P(SumSSETest, ExtremeValues) {
- RunTest(0); // GenExtremeData
+ RunTest(0, 1); // GenExtremeData, width and height multiple of 4
+}
+
+TEST_P(SumSSETest, ArbitraryWidthAndHeight) {
+ // GenRandomData, width and height not necessarily multiple of 4
+ RunTest(1, 0);
}
TEST_P(SumSSETest, DISABLED_Speed) { RunSpeedTest(); }
diff --git a/test/sum_squares_test.cc b/test/sum_squares_test.cc
index 09b3c056d7..e6719e40c3 100644
--- a/test/sum_squares_test.cc
+++ b/test/sum_squares_test.cc
@@ -53,7 +53,7 @@ class SumSquaresTest : public ::testing::TestWithParam<TestFuncs> {
}
void TearDown() override { aom_free(src_); }
- void RunTest(bool is_random);
+ void RunTest(bool is_random, bool multiple_of_4);
void RunSpeedTest();
void GenRandomData(int width, int height, int stride) {
@@ -84,13 +84,15 @@ class SumSquaresTest : public ::testing::TestWithParam<TestFuncs> {
};
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(SumSquaresTest);
-void SumSquaresTest::RunTest(bool is_random) {
+void SumSquaresTest::RunTest(bool is_random, bool multiple_of_4) {
int failed = 0;
for (int k = 0; k < kNumIterations; k++) {
- const int width = 4 * (rnd_(31) + 1); // Up to 128x128
- const int height = 4 * (rnd_(31) + 1); // Up to 128x128
- int stride = 4 << rnd_(7); // Up to 256 stride
- while (stride < width) { // Make sure it's valid
+ // Up to 128x128
+ const int width = multiple_of_4 ? 4 * (rnd_(31) + 1) : rnd_(127) + 1;
+ // Up to 128x128
+ const int height = multiple_of_4 ? 4 * (rnd_(31) + 1) : rnd_(127) + 1;
+ int stride = 4 << rnd_(7); // Up to 256 stride
+ while (stride < width) { // Make sure it's valid
stride = 4 << rnd_(7);
}
if (is_random) {
@@ -145,11 +147,16 @@ void SumSquaresTest::RunSpeedTest() {
}
TEST_P(SumSquaresTest, OperationCheck) {
- RunTest(true); // GenRandomData
+ RunTest(true, true); // GenRandomData, width and height multiple of 4
}
TEST_P(SumSquaresTest, ExtremeValues) {
- RunTest(false); // GenExtremeData
+ RunTest(false, true); // GenExtremeData, width and height multiple of 4
+}
+
+TEST_P(SumSquaresTest, ArbitraryWidthAndHeight) {
+ // GenRandomData, width and height not necessarily multiple of 4
+ RunTest(true, false);
}
TEST_P(SumSquaresTest, DISABLED_Speed) { RunSpeedTest(); }