Skip to content

Commit 470b3ea

Browse files
author
Gin
committed
Fix NEON image filter kernel after refactor
1 parent b138762 commit 470b3ea

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

SerialPrograms/Source/Kernels/ImageFilters/Kernels_ImageFilter_Basic_Routines_ARM64_NEON.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ namespace Kernels{
1616

1717

1818
template <typename PixelTester>
19-
class ToBlackWhite_Rgb32_ARM64_NEON{
19+
class FilterImage_Rgb32_ARM64_NEON{
2020
public:
2121
static const size_t VECTOR_SIZE = 4;
2222
using Mask = size_t;
2323

2424
public:
25-
ToBlackWhite_Rgb32_ARM64_NEON(
25+
FilterImage_Rgb32_ARM64_NEON(
2626
const PixelTester& tester,
2727
uint32_t replacement_color, bool replace_color_within_range
2828
)
@@ -45,7 +45,8 @@ class ToBlackWhite_Rgb32_ARM64_NEON{
4545
// The resulting pixels are saved in out[4]
4646
PA_FORCE_INLINE void process_full(uint32_t out[4], const uint32_t in[4], const uint32x4_t* cmp_mask_u32 = nullptr){
4747
uint32x4_t pixel = vld1q_u32(in);
48-
uint32x4_t cmp_u32 = process_word(pixel);
48+
// If a pixel is within [mins, maxs], its uint32_t in `cmp_u32` is all 1 bits, otherwise, all 0 bits
49+
uint32x4_t cmp_u32 = m_tester.test_word(pixel);
4950
if (cmp_mask_u32) {
5051
cmp_u32 = vandq_u32(cmp_u32, *cmp_mask_u32);
5152
}
@@ -111,9 +112,10 @@ class ToBlackWhite_Rgb32_ARM64_NEON{
111112
// If a per-pixel mask, cmp_mask_u32 is not nullptr, it only counts the pixels covered by the mask.
112113
// It also changes pixels into black or white depending on whether they are in range.
113114
// The resulting pixels are saved in out[4]
114-
PA_FORCE_INLINE void process_full(uint32_t* out, const uint32_t* in){
115+
PA_FORCE_INLINE void process_full(uint32_t* out, const uint32_t* in, const uint32x4_t* cmp_mask_u32 = nullptr){
115116
uint32x4_t pixel = vld1q_u32(in);
116-
uint32x4_t cmp_u32 = process_word(pixel);
117+
// If a pixel is within [mins, maxs], its uint32_t in `cmp_u32` is all 1 bits, otherwise, all 0 bits
118+
uint32x4_t cmp_u32 = m_tester.test_word(pixel);
117119
if (cmp_mask_u32) {
118120
cmp_u32 = vandq_u32(cmp_u32, *cmp_mask_u32);
119121
}

SerialPrograms/Source/Kernels/ImageFilters/RGB32_Range/Kernels_ImageFilter_RGB32_Range_ARM64_NEON.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class PixelTest_Rgb32Range_ARM64_NEON{
4343
{}
4444

4545
// Return a mask indicating which lanes are in range.
46-
PA_FORCE_INLINE uint32x4_t test_word(uint32x4_t pixel) const{
46+
PA_FORCE_INLINE uint32x4_t test_word(uint32x4_t& pixel) const{
4747
uint8x16_t in_u8 = vreinterpretq_u8_u32(pixel);
4848

4949
// Check if mins > pixel per color channel

0 commit comments

Comments
 (0)