MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / operator()

Method operator()

dnn/src/common/cv/filter.h:245–288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243 : RowFilter<ST, DT, VecOp>(kernel_, anchor_, vec_op_) {}
244
245 void operator()(const uchar* src, uchar* dst, int width, int cn) {
246 int ksize2 = this->ksize / 2, ksize2n = ksize2 * cn;
247 const DT* kx = this->kernel.ptr() + ksize2;
248 DT* D = reinterpret_cast<DT*>(dst);
249 int i = this->vec_op(src, dst, width, cn), j, k;
250
251 //! The center
252 const ST* S = reinterpret_cast<const ST*>(src) + i + ksize2n;
253 width *= cn;
254
255 if (this->ksize == 1 && kx[0] == 1) {
256 for (; i <= width - 2; i += 2) {
257 DT s0 = S[i], s1 = S[i + 1];
258 D[i] = s0;
259 D[i + 1] = s1;
260 }
261 S += i;
262 } else if (this->ksize == 3) {
263 DT k0 = kx[0], k1 = kx[1];
264 for (; i <= width - 2; i += 2, S += 2) {
265 DT s0 = S[0] * k0 + (S[-cn] + S[cn]) * k1,
266 s1 = S[1] * k0 + (S[1 - cn] + S[1 + cn]) * k1;
267 D[i] = s0;
268 D[i + 1] = s1;
269 }
270 } else if (this->ksize == 5) {
271 DT k0 = kx[0], k1 = kx[1], k2 = kx[2];
272 for (; i <= width - 2; i += 2, S += 2) {
273 DT s0 = S[0] * k0 + (S[-cn] + S[cn]) * k1 +
274 (S[-cn * 2] + S[cn * 2]) * k2;
275 DT s1 = S[1] * k0 + (S[1 - cn] + S[1 + cn]) * k1 +
276 (S[1 - cn * 2] + S[1 + cn * 2]) * k2;
277 D[i] = s0;
278 D[i + 1] = s1;
279 }
280 }
281
282 for (; i < width; i++, S++) {
283 DT s0 = kx[0] * S[0];
284 for (k = 1, j = cn; k <= ksize2; k++, j += cn)
285 s0 += kx[k] * (S[j] + S[-j]);
286 D[i] = s0;
287 }
288 }
289};
290
291template <class CastOp, class VecOp>

Callers

nothing calls this directly

Calls 1

ptrMethod · 0.45

Tested by

no test coverage detected