MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / proceed

Method proceed

dnn/src/common/cv/filter.cpp:184–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182
183template <typename ST, typename FT>
184int FilterEngine<ST, FT>::proceed(
185 const uchar* src, int srcstep, int count, uchar* dst, int dststep) {
186 const int* btab = &m_border_table[0];
187 int src_elem_size = static_cast<int>(sizeof(ST) * m_ch);
188 bool makeBorder = (m_left_width > 0 || m_right_width > 0) &&
189 m_bmode != BorderMode::BORDER_CONSTANT;
190 int dy = 0, i = 0;
191
192 int row_count = 0;
193 int start_y = 0;
194 std::vector<uchar*> buf_rows(m_ksize.rows(), nullptr);
195 for (;; dst += dststep * i, dy += i) {
196 int dcount = m_ksize.height() - m_anchor.y - start_y - row_count;
197 dcount = dcount > 0 ? dcount : 1;
198 dcount = std::min<int>(dcount, count);
199 count -= dcount;
200 for (; dcount-- > 0; src += srcstep) {
201 int bi = (start_y + row_count) % m_ksize.height();
202 uchar* brow = align_ptr(&m_ring_buf[0], VEC_ALIGN) + bi * m_buf_step;
203 uchar* row = &m_src_row[0];
204
205 if (++row_count > static_cast<int>(m_ksize.height())) {
206 --row_count;
207 ++start_y;
208 }
209
210 memcpy(row + m_left_width * src_elem_size, src,
211 m_whole_size.width() * src_elem_size);
212
213 if (makeBorder) {
214 if (m_border_elem_size * static_cast<int>(sizeof(int)) ==
215 src_elem_size) {
216 const int* isrc = reinterpret_cast<const int*>(src);
217 int* irow = reinterpret_cast<int*>(row);
218
219 for (int i = 0; i < m_left_width * m_border_elem_size; i++)
220 irow[i] = isrc[btab[i]];
221 for (int i = 0; i < m_right_width * m_border_elem_size; i++) {
222 irow[i + (m_whole_size.width() + m_left_width) *
223 m_border_elem_size] =
224 isrc[btab[i + m_left_width * m_border_elem_size]];
225 }
226 } else {
227 for (int i = 0; i < m_left_width * src_elem_size; i++)
228 row[i] = src[btab[i]];
229 for (int i = 0; i < m_right_width * src_elem_size; i++)
230 row[i + (m_whole_size.width() + m_left_width) * src_elem_size] =
231 src[btab[i + m_left_width * src_elem_size]];
232 }
233 }
234
235 (*m_row_filter)(row, brow, m_whole_size.width(), m_ch);
236 }
237
238 int max_i = std::min<int>(
239 m_ksize.height(), m_whole_size.height() - dy + (m_ksize.height() - 1));
240 for (i = 0; i < max_i; i++) {
241 int src_y = gaussian_blur::border_interpolate(

Callers

nothing calls this directly

Calls 5

align_ptrFunction · 0.70
border_interpolateFunction · 0.70
rowsMethod · 0.45
heightMethod · 0.45
widthMethod · 0.45

Tested by

no test coverage detected