Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions prj/vs2022/Sve2.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\src\Simd\SimdSve2Background.cpp" />
<ClCompile Include="..\..\src\Simd\SimdSve2BgraToGray.cpp" />
<ClCompile Include="..\..\src\Simd\SimdSve2BgrToGray.cpp" />
<ClCompile Include="..\..\src\Simd\SimdSve2Conditional.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions prj/vs2022/Sve2.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@
<Filter Include="Sve2\Math">
<UniqueIdentifier>{20effda6-54db-458e-893a-7d219e5ec991}</UniqueIdentifier>
</Filter>
<Filter Include="Sve2\Motion">
<UniqueIdentifier>{c7b7a0a0-3931-46d4-b726-c78f5257c775}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\Simd\SimdSve2.h">
<Filter>Sve2</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\Simd\SimdSve2Background.cpp">
<Filter>Sve2\Motion</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Simd\SimdSve2Cpu.cpp">
<Filter>Sve2\System</Filter>
</ClCompile>
Expand Down
5 changes: 5 additions & 0 deletions src/Simd/SimdLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/Simd/SimdSve2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
72 changes: 72 additions & 0 deletions src/Simd/SimdSve2Background.cpp
Original file line number Diff line number Diff line change
@@ -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
}
5 changes: 5 additions & 0 deletions src/Test/TestBackground.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Loading