1 // Tencent is pleased to support the open source community by making ncnn available.
2 //
3 // Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
4 //
5 // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 // in compliance with the License. You may obtain a copy of the License at
7 //
8 // https://opensource.org/licenses/BSD-3-Clause
9 //
10 // Unless required by applicable law or agreed to in writing, software distributed
11 // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 // specific language governing permissions and limitations under the License.
14
padding_constant_pack8_int8_sse(const Mat & src,Mat & dst,int top,int bottom,int left,int right,int64_t _v)15 static void padding_constant_pack8_int8_sse(const Mat& src, Mat& dst, int top, int bottom, int left, int right, int64_t _v)
16 {
17 const int64_t* ptr = src;
18 int64_t* outptr = dst;
19
20 // fill top
21 for (int y = 0; y < top; y++)
22 {
23 for (int x = 0; x < dst.w; x++)
24 {
25 *outptr++ = _v;
26 }
27 }
28 // fill center
29 for (int y = 0; y < src.h; y++)
30 {
31 for (int x = 0; x < left; x++)
32 {
33 *outptr++ = _v;
34 }
35 for (int x = 0; x < src.w; x++)
36 {
37 *outptr++ = *ptr++;
38 }
39 for (int x = 0; x < right; x++)
40 {
41 *outptr++ = _v;
42 }
43 }
44 // fill bottom
45 for (int y = 0; y < bottom; y++)
46 {
47 for (int x = 0; x < dst.w; x++)
48 {
49 *outptr++ = _v;
50 }
51 }
52 }
53
padding_replicate_pack8_int8_sse(const Mat & src,Mat & dst,int top,int bottom,int left,int right)54 static void padding_replicate_pack8_int8_sse(const Mat& src, Mat& dst, int top, int bottom, int left, int right)
55 {
56 const int64_t* ptr = src;
57 int64_t* outptr = dst;
58
59 // fill top
60 for (int y = 0; y < top; y++)
61 {
62 const int64_t* ptr0 = ptr;
63 int64_t _p = *ptr0;
64 for (int x = 0; x < left; x++)
65 {
66 *outptr++ = _p;
67 }
68 for (int x = 0; x < src.w; x++)
69 {
70 *outptr++ = *ptr0++;
71 }
72 for (int x = 0; x < right; x++)
73 {
74 *outptr++ = _p;
75 }
76 }
77 // fill center
78 for (int y = 0; y < src.h; y++)
79 {
80 int64_t _p = *ptr;
81 for (int x = 0; x < left; x++)
82 {
83 *outptr++ = _p;
84 }
85 for (int x = 0; x < src.w; x++)
86 {
87 *outptr++ = *ptr++;
88 }
89 for (int x = 0; x < right; x++)
90 {
91 *outptr++ = _p;
92 }
93 }
94 // fill bottom
95 ptr -= src.w;
96 for (int y = 0; y < bottom; y++)
97 {
98 const int64_t* ptr0 = ptr;
99 int64_t _p = *ptr0;
100 for (int x = 0; x < left; x++)
101 {
102 *outptr++ = _p;
103 }
104 for (int x = 0; x < src.w; x++)
105 {
106 *outptr++ = *ptr0++;
107 }
108 for (int x = 0; x < right; x++)
109 {
110 *outptr++ = _p;
111 }
112 }
113 }
114
padding_reflect_pack8_int8_sse(const Mat & src,Mat & dst,int top,int bottom,int left,int right)115 static void padding_reflect_pack8_int8_sse(const Mat& src, Mat& dst, int top, int bottom, int left, int right)
116 {
117 const int64_t* ptr = src;
118 int64_t* outptr = dst;
119
120 // fill top
121 ptr += top * src.w;
122 for (int y = 0; y < top; y++)
123 {
124 const int64_t* ptr0 = ptr;
125 for (int x = 0; x < left; x++)
126 {
127 *outptr++ = ptr0[left - x];
128 }
129 for (int x = 0; x < src.w; x++)
130 {
131 *outptr++ = *ptr0++;
132 }
133 for (int x = 0; x < right; x++)
134 {
135 *outptr++ = ptr0[-2 - x];
136 }
137 ptr -= src.w;
138 }
139 // fill center
140 for (int y = 0; y < src.h; y++)
141 {
142 for (int x = 0; x < left; x++)
143 {
144 *outptr++ = ptr[left - x];
145 }
146 for (int x = 0; x < src.w; x++)
147 {
148 *outptr++ = *ptr++;
149 }
150 for (int x = 0; x < right; x++)
151 {
152 *outptr++ = ptr[-2 - x];
153 }
154 }
155 // fill bottom
156 ptr -= 2 * src.w;
157 for (int y = 0; y < bottom; y++)
158 {
159 const int64_t* ptr0 = ptr;
160 for (int x = 0; x < left; x++)
161 {
162 *outptr++ = ptr0[left - x];
163 }
164 for (int x = 0; x < src.w; x++)
165 {
166 *outptr++ = *ptr0++;
167 }
168 for (int x = 0; x < right; x++)
169 {
170 *outptr++ = ptr0[-2 - x];
171 }
172 ptr -= src.w;
173 }
174 }
175