| 337 | } |
| 338 | |
| 339 | int FilterEngine::proceed( const uchar* src, int srcstep, int count, |
| 340 | uchar* dst, int dststep ) |
| 341 | { |
| 342 | CV_Assert( wholeSize.width > 0 && wholeSize.height > 0 ); |
| 343 | |
| 344 | const int *btab = &borderTab[0]; |
| 345 | int esz = (int)getElemSize(srcType), btab_esz = borderElemSize; |
| 346 | uchar** brows = &rows[0]; |
| 347 | int bufRows = (int)rows.size(); |
| 348 | int cn = CV_MAT_CN(bufType); |
| 349 | int width = roi.width, kwidth = ksize.width; |
| 350 | int kheight = ksize.height, ay = anchor.y; |
| 351 | int _dx1 = dx1, _dx2 = dx2; |
| 352 | int width1 = roi.width + kwidth - 1; |
| 353 | int xofs1 = std::min(roi.x, anchor.x); |
| 354 | bool isSep = isSeparable(); |
| 355 | bool makeBorder = (_dx1 > 0 || _dx2 > 0) && rowBorderType != BORDER_CONSTANT; |
| 356 | int dy = 0, i = 0; |
| 357 | |
| 358 | src -= xofs1*esz; |
| 359 | count = std::min(count, remainingInputRows()); |
| 360 | |
| 361 | CV_Assert( src && dst && count > 0 ); |
| 362 | |
| 363 | for(;; dst += dststep*i, dy += i) |
| 364 | { |
| 365 | int dcount = bufRows - ay - startY - rowCount + roi.y; |
| 366 | dcount = dcount > 0 ? dcount : bufRows - kheight + 1; |
| 367 | dcount = std::min(dcount, count); |
| 368 | count -= dcount; |
| 369 | for( ; dcount-- > 0; src += srcstep ) |
| 370 | { |
| 371 | int bi = (startY - startY0 + rowCount) % bufRows; |
| 372 | uchar* brow = alignPtr(&ringBuf[0], VEC_ALIGN) + bi*bufStep; |
| 373 | uchar* row = isSep ? &srcRow[0] : brow; |
| 374 | |
| 375 | if( ++rowCount > bufRows ) |
| 376 | { |
| 377 | --rowCount; |
| 378 | ++startY; |
| 379 | } |
| 380 | |
| 381 | memcpy( row + _dx1*esz, src, (width1 - _dx2 - _dx1)*esz ); |
| 382 | |
| 383 | if( makeBorder ) |
| 384 | { |
| 385 | if( btab_esz*(int)sizeof(int) == esz ) |
| 386 | { |
| 387 | const int* isrc = (const int*)src; |
| 388 | int* irow = (int*)row; |
| 389 | |
| 390 | for( i = 0; i < _dx1*btab_esz; i++ ) |
| 391 | irow[i] = isrc[btab[i]]; |
| 392 | for( i = 0; i < _dx2*btab_esz; i++ ) |
| 393 | irow[i + (width1 - _dx2)*btab_esz] = isrc[btab[i+_dx1*btab_esz]]; |
| 394 | } |
| 395 | else |
| 396 | { |
no test coverage detected