diff --git a/prj/vs2022/Sve2.vcxproj b/prj/vs2022/Sve2.vcxproj
index 1eb1cf8043..1109399979 100644
--- a/prj/vs2022/Sve2.vcxproj
+++ b/prj/vs2022/Sve2.vcxproj
@@ -21,6 +21,7 @@
+
diff --git a/prj/vs2022/Sve2.vcxproj.filters b/prj/vs2022/Sve2.vcxproj.filters
index 3cdf51a9d0..1a7d26552e 100644
--- a/prj/vs2022/Sve2.vcxproj.filters
+++ b/prj/vs2022/Sve2.vcxproj.filters
@@ -16,6 +16,9 @@
{20effda6-54db-458e-893a-7d219e5ec991}
+
+ {c7b7a0a0-3931-46d4-b726-c78f5257c775}
+
@@ -23,6 +26,9 @@
+
+ Sve2\Motion
+
Sve2\System
diff --git a/src/Simd/SimdLib.cpp b/src/Simd/SimdLib.cpp
index cd6bc44ccc..f1d879d286 100644
--- a/src/Simd/SimdLib.cpp
+++ b/src/Simd/SimdLib.cpp
@@ -801,6 +801,11 @@ SIMD_API void SimdBackgroundIncrementCount(const uint8_t * value, size_t valueSt
Sse41::BackgroundIncrementCount(value, valueStride, width, height, loValue, loValueStride, hiValue, hiValueStride, loCount, loCountStride, hiCount, hiCountStride);
else
#endif
+#ifdef SIMD_SVE2_ENABLE
+ if (Sve2::Enable)
+ Sve2::BackgroundIncrementCount(value, valueStride, width, height, loValue, loValueStride, hiValue, hiValueStride, loCount, loCountStride, hiCount, hiCountStride);
+ else
+#endif
#ifdef SIMD_NEON_ENABLE
if (Neon::Enable && width >= Neon::A)
Neon::BackgroundIncrementCount(value, valueStride, width, height, loValue, loValueStride, hiValue, hiValueStride, loCount, loCountStride, hiCount, hiCountStride);
diff --git a/src/Simd/SimdSve2.h b/src/Simd/SimdSve2.h
index 5838fbd9da..23d393c176 100644
--- a/src/Simd/SimdSve2.h
+++ b/src/Simd/SimdSve2.h
@@ -31,6 +31,10 @@ namespace Simd
#ifdef SIMD_SVE2_ENABLE
namespace Sve2
{
+ void BackgroundIncrementCount(const uint8_t* value, size_t valueStride, size_t width, size_t height,
+ const uint8_t* loValue, size_t loValueStride, const uint8_t* hiValue, size_t hiValueStride,
+ uint8_t* loCount, size_t loCountStride, uint8_t* hiCount, size_t hiCountStride);
+
void BgraToGray(const uint8_t* bgra, size_t width, size_t height, size_t bgraStride, uint8_t* gray, size_t grayStride);
void BgrToGray(const uint8_t* bgr, size_t width, size_t height, size_t bgrStride, uint8_t* gray, size_t grayStride);
diff --git a/src/Simd/SimdSve2Background.cpp b/src/Simd/SimdSve2Background.cpp
new file mode 100644
index 0000000000..7c9fe1af4e
--- /dev/null
+++ b/src/Simd/SimdSve2Background.cpp
@@ -0,0 +1,72 @@
+/*
+* Simd Library (http://ermig1979.github.io/Simd).
+*
+* Copyright (c) 2011-2026 Yermalayeu Ihar.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*/
+#include "Simd/SimdMemory.h"
+
+namespace Simd
+{
+#ifdef SIMD_SVE2_ENABLE
+ namespace Sve2
+ {
+ SIMD_INLINE void BackgroundIncrementCount(const uint8_t* value, const uint8_t* loValue, const uint8_t* hiValue,
+ uint8_t* loCount, uint8_t* hiCount, const svuint8_t& _1, const svbool_t& mask)
+ {
+ svuint8_t _value = svld1_u8(mask, value);
+ svuint8_t _loValue = svld1_u8(mask, loValue);
+ svuint8_t _hiValue = svld1_u8(mask, hiValue);
+ svuint8_t _loCount = svld1_u8(mask, loCount);
+ svuint8_t _hiCount = svld1_u8(mask, hiCount);
+
+ svbool_t incLo = svcmplt_u8(mask, _value, _loValue);
+ svbool_t incHi = svcmpgt_u8(mask, _value, _hiValue);
+
+ svst1_u8(mask, loCount, svqadd_u8(_loCount, svand_u8_z(incLo, _1, _1)));
+ svst1_u8(mask, hiCount, svqadd_u8(_hiCount, svand_u8_z(incHi, _1, _1)));
+ }
+
+ void BackgroundIncrementCount(const uint8_t* value, size_t valueStride, size_t width, size_t height,
+ const uint8_t* loValue, size_t loValueStride, const uint8_t* hiValue, size_t hiValueStride,
+ uint8_t* loCount, size_t loCountStride, uint8_t* hiCount, size_t hiCountStride)
+ {
+ size_t A = svlen(svuint8_t());
+ size_t widthA = AlignLo(width, A);
+ const svbool_t body = svptrue_b8();
+ const svbool_t tail = svwhilelt_b8(widthA, width);
+ svuint8_t _1 = svdup_n_u8(1);
+ for (size_t row = 0; row < height; ++row)
+ {
+ size_t col = 0;
+ for (; col < widthA; col += A)
+ BackgroundIncrementCount(value + col, loValue + col, hiValue + col, loCount + col, hiCount + col, _1, body);
+ if (widthA < width)
+ BackgroundIncrementCount(value + col, loValue + col, hiValue + col, loCount + col, hiCount + col, _1, tail);
+ value += valueStride;
+ loValue += loValueStride;
+ hiValue += hiValueStride;
+ loCount += loCountStride;
+ hiCount += hiCountStride;
+ }
+ }
+ }
+#endif
+}
diff --git a/src/Test/TestBackground.cpp b/src/Test/TestBackground.cpp
index 60ea6cebb8..abe8e3ae37 100644
--- a/src/Test/TestBackground.cpp
+++ b/src/Test/TestBackground.cpp
@@ -534,6 +534,11 @@ namespace Test
result = result && BackgroundIncrementCountAutoTest(FUNC2(Simd::Neon::BackgroundIncrementCount), FUNC2(SimdBackgroundIncrementCount));
#endif
+#ifdef SIMD_SVE2_ENABLE
+ if (Simd::Sve2::Enable && TestSve2(options))
+ result = result && BackgroundIncrementCountAutoTest(FUNC2(Simd::Sve2::BackgroundIncrementCount), FUNC2(SimdBackgroundIncrementCount));
+#endif
+
return result;
}