Coverage Report

Created: 2026-07-21 07:36

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/Simd/src/Simd/SimdAvx2Lbp.cpp
Line
Count
Source
1
/*
2
* Simd Library (http://ermig1979.github.io/Simd).
3
*
4
* Copyright (c) 2011-2017 Yermalayeu Ihar.
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a copy
7
* of this software and associated documentation files (the "Software"), to deal
8
* in the Software without restriction, including without limitation the rights
9
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
* copies of the Software, and to permit persons to whom the Software is
11
* furnished to do so, subject to the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be included in
14
* all copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
* SOFTWARE.
23
*/
24
#include "Simd/SimdMemory.h"
25
#include "Simd/SimdStore.h"
26
#include "Simd/SimdCompare.h"
27
28
namespace Simd
29
{
30
#ifdef SIMD_AVX2_ENABLE    
31
    namespace Avx2
32
    {
33
        template <bool align> void LbpEstimate(const uint8_t * src, ptrdiff_t stride, uint8_t * dst)
34
0
        {
35
0
            __m256i threshold = Load<false>((__m256i*)src);
36
0
            __m256i lbp = _mm256_setzero_si256();
37
0
            lbp = _mm256_or_si256(lbp, _mm256_and_si256(GreaterOrEqual8u(Load<align>((__m256i*)(src - 1 - stride)), threshold), K8_01));
38
0
            lbp = _mm256_or_si256(lbp, _mm256_and_si256(GreaterOrEqual8u(Load<false>((__m256i*)(src - stride)), threshold), K8_02));
39
0
            lbp = _mm256_or_si256(lbp, _mm256_and_si256(GreaterOrEqual8u(Load<false>((__m256i*)(src + 1 - stride)), threshold), K8_04));
40
0
            lbp = _mm256_or_si256(lbp, _mm256_and_si256(GreaterOrEqual8u(Load<false>((__m256i*)(src + 1)), threshold), K8_08));
41
0
            lbp = _mm256_or_si256(lbp, _mm256_and_si256(GreaterOrEqual8u(Load<false>((__m256i*)(src + 1 + stride)), threshold), K8_10));
42
0
            lbp = _mm256_or_si256(lbp, _mm256_and_si256(GreaterOrEqual8u(Load<false>((__m256i*)(src + stride)), threshold), K8_20));
43
0
            lbp = _mm256_or_si256(lbp, _mm256_and_si256(GreaterOrEqual8u(Load<align>((__m256i*)(src - 1 + stride)), threshold), K8_40));
44
0
            lbp = _mm256_or_si256(lbp, _mm256_and_si256(GreaterOrEqual8u(Load<align>((__m256i*)(src - 1)), threshold), K8_80));
45
0
            Store<false>((__m256i*)dst, lbp);
46
0
        }
Unexecuted instantiation: void Simd::Avx2::LbpEstimate<true>(unsigned char const*, long, unsigned char*)
Unexecuted instantiation: void Simd::Avx2::LbpEstimate<false>(unsigned char const*, long, unsigned char*)
47
48
        template <bool align> void LbpEstimate(
49
            const uint8_t * src, size_t srcStride, size_t width, size_t height, uint8_t * dst, size_t dstStride)
50
0
        {
51
0
            assert(width >= A + 2);
52
0
            if (align)
53
0
                assert(Aligned(src) && Aligned(srcStride) && Aligned(dst) && Aligned(dstStride));
54
55
0
            size_t alignedWidth = AlignLo(width - 2, A) + 1;
56
57
0
            memset(dst, 0, width);
58
0
            src += srcStride;
59
0
            dst += dstStride;
60
0
            for (size_t row = 2; row < height; ++row)
61
0
            {
62
0
                dst[0] = 0;
63
0
                for (size_t col = 1; col < alignedWidth; col += A)
64
0
                    LbpEstimate<align>(src + col, srcStride, dst + col);
65
0
                if (alignedWidth != width - 1)
66
0
                    LbpEstimate<false>(src + width - 1 - A, srcStride, dst + width - 1 - A);
67
0
                dst[width - 1] = 0;
68
69
0
                src += srcStride;
70
0
                dst += dstStride;
71
0
            }
72
0
            memset(dst, 0, width);
73
0
        }
Unexecuted instantiation: void Simd::Avx2::LbpEstimate<true>(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long)
Unexecuted instantiation: void Simd::Avx2::LbpEstimate<false>(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long)
74
75
        void LbpEstimate(const uint8_t * src, size_t srcStride, size_t width, size_t height, uint8_t * dst, size_t dstStride)
76
0
        {
77
0
            if (Aligned(src) && Aligned(srcStride) && Aligned(dst) && Aligned(dstStride))
78
0
                LbpEstimate<true>(src, srcStride, width, height, dst, dstStride);
79
0
            else
80
0
                LbpEstimate<false>(src, srcStride, width, height, dst, dstStride);
81
0
        }
82
    }
83
#endif// SIMD_AVX2_ENABLE
84
}