Coverage Report

Created: 2026-10-28 07:09

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/Simd/src/Simd/SimdBaseCopy.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/SimdDefs.h"
25
26
namespace Simd
27
{
28
    namespace Base
29
    {
30
        void Copy(const uint8_t * src, size_t srcStride, size_t width, size_t height, size_t pixelSize, uint8_t * dst, size_t dstStride)
31
2.83k
        {
32
2.83k
            size_t rowSize = width*pixelSize;
33
16.6M
            for (size_t row = 0; row < height; ++row)
34
16.6M
            {
35
16.6M
                memcpy(dst, src, rowSize);
36
16.6M
                src += srcStride;
37
16.6M
                dst += dstStride;
38
16.6M
            }
39
2.83k
        }
40
41
        void CopyFrame(const uint8_t * src, size_t srcStride, size_t width, size_t height, size_t pixelSize,
42
            size_t frameLeft, size_t frameTop, size_t frameRight, size_t frameBottom, uint8_t * dst, size_t dstStride)
43
0
        {
44
0
            if (frameTop > frameBottom || frameBottom > height || frameLeft > frameRight || frameRight > width)
45
0
                return;
46
47
0
            if (frameTop > 0)
48
0
            {
49
0
                size_t srcOffset = 0;
50
0
                size_t dstOffset = 0;
51
0
                size_t size = width*pixelSize;
52
0
                for (size_t row = 0; row < frameTop; ++row)
53
0
                {
54
0
                    memcpy(dst + dstOffset, src + srcOffset, size);
55
0
                    srcOffset += srcStride;
56
0
                    dstOffset += dstStride;
57
0
                }
58
0
            }
59
0
            if (frameBottom < height)
60
0
            {
61
0
                size_t srcOffset = frameBottom*srcStride;
62
0
                size_t dstOffset = frameBottom*dstStride;
63
0
                size_t size = width*pixelSize;
64
0
                for (size_t row = frameBottom; row < height; ++row)
65
0
                {
66
0
                    memcpy(dst + dstOffset, src + srcOffset, size);
67
0
                    srcOffset += srcStride;
68
0
                    dstOffset += dstStride;
69
0
                }
70
0
            }
71
0
            if (frameLeft > 0)
72
0
            {
73
0
                size_t srcOffset = frameTop*srcStride;
74
0
                size_t dstOffset = frameTop*dstStride;
75
0
                size_t size = frameLeft*pixelSize;
76
0
                for (size_t row = frameTop; row < frameBottom; ++row)
77
0
                {
78
0
                    memcpy(dst + dstOffset, src + srcOffset, size);
79
0
                    srcOffset += srcStride;
80
0
                    dstOffset += dstStride;
81
0
                }
82
0
            }
83
0
            if (frameRight < width)
84
0
            {
85
0
                size_t srcOffset = frameTop*srcStride + frameRight*pixelSize;
86
0
                size_t dstOffset = frameTop*dstStride + frameRight*pixelSize;
87
0
                size_t size = (width - frameRight)*pixelSize;
88
0
                for (size_t row = frameTop; row < frameBottom; ++row)
89
0
                {
90
0
                    memcpy(dst + dstOffset, src + srcOffset, size);
91
0
                    srcOffset += srcStride;
92
0
                    dstOffset += dstStride;
93
0
                }
94
0
            }
95
0
        }
96
    }
97
}