Coverage Report

Created: 2026-04-09 07:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/Simd/src/Simd/SimdAvx2Int16ToGray.cpp
Line
Count
Source
1
/*
2
* Simd Library (http://ermig1979.github.io/Simd).
3
*
4
* Copyright (c) 2011-2020 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/SimdStore.h"
25
#include "Simd/SimdMemory.h"
26
27
namespace Simd
28
{
29
#ifdef SIMD_AVX2_ENABLE    
30
    namespace Avx2
31
    {
32
        template <bool align> SIMD_INLINE void Int16ToGray(const int16_t * src, uint8_t * dst)
33
0
        {
34
0
            __m256i lo = Load<align>((__m256i*)src + 0);
35
0
            __m256i hi = Load<align>((__m256i*)src + 1);
36
0
            Store<align>((__m256i*)dst, PackI16ToU8(lo, hi));
37
0
        }
Unexecuted instantiation: void Simd::Avx2::Int16ToGray<true>(short const*, unsigned char*)
Unexecuted instantiation: void Simd::Avx2::Int16ToGray<false>(short const*, unsigned char*)
38
39
        template <bool align> void Int16ToGray(const int16_t * src, size_t width, size_t height, size_t srcStride, uint8_t * dst, size_t dstStride)
40
0
        {
41
0
            assert(width >= A);
42
0
            if (align)
43
0
                assert(Aligned(src) && Aligned(srcStride, HA) && Aligned(dst) && Aligned(dstStride));
44
45
0
            size_t alignedWidth = AlignLo(width, A);
46
0
            for (size_t row = 0; row < height; ++row)
47
0
            {
48
0
                for (size_t col = 0; col < alignedWidth; col += A)
49
0
                    Int16ToGray<align>(src + col, dst + col);
50
0
                if (alignedWidth != width)
51
0
                    Int16ToGray<false>(src + width - A, dst + width - A);
52
0
                src += srcStride;
53
0
                dst += dstStride;
54
0
            }
55
0
        }
Unexecuted instantiation: void Simd::Avx2::Int16ToGray<true>(short const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long)
Unexecuted instantiation: void Simd::Avx2::Int16ToGray<false>(short const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long)
56
57
        void Int16ToGray(const uint8_t * src, size_t width, size_t height, size_t srcStride, uint8_t * dst, size_t dstStride)
58
0
        {
59
0
            if (Aligned(src) && Aligned(srcStride) && Aligned(dst) && Aligned(dstStride))
60
0
                Int16ToGray<true>((const int16_t *)src, width, height, srcStride / sizeof(int16_t), dst, dstStride);
61
0
            else
62
0
                Int16ToGray<false>((const int16_t *)src, width, height, srcStride / sizeof(int16_t), dst, dstStride);
63
0
        }
64
    }
65
#endif// SIMD_AVX2_ENABLE
66
}