linear 8u
| 488 | |
| 489 | // linear 8u |
| 490 | void build_tabs_linear_8u( |
| 491 | const Mat8u& src, const Mat8u& dst, AlignedVector<int>& tabsx, |
| 492 | AlignedVector<int>& tabsy, AlignedVector<int>& tabrx, |
| 493 | AlignedVector<int>& tabry) { |
| 494 | megdnn_assert(src.rows() >= 2); |
| 495 | megdnn_assert(src.cols() >= 2); |
| 496 | megdnn_assert(dst.rows() >= 2); |
| 497 | megdnn_assert(dst.cols() >= 2); |
| 498 | const float fx = static_cast<float>(dst.rows()) / src.rows(); |
| 499 | const float fy = static_cast<float>(dst.cols()) / src.cols(); |
| 500 | const float ifx = 1.0f / fx; |
| 501 | const float ify = 1.0f / fy; |
| 502 | for (size_t dx = 0; dx < dst.rows(); ++dx) { |
| 503 | float rx = (dx + 0.5f) * ifx - 0.5f; |
| 504 | int sx = static_cast<int>(floor(rx)); |
| 505 | rx -= sx; |
| 506 | if (sx < 0) { |
| 507 | sx = 0; |
| 508 | rx = 0; |
| 509 | } else if (sx + 1 >= static_cast<int>(src.rows())) { |
| 510 | sx = src.rows() - 2; |
| 511 | rx = 1; |
| 512 | } |
| 513 | tabsx[dx] = sx; |
| 514 | tabrx[dx] = static_cast<int>(rx * (1 << SCALE)); |
| 515 | } |
| 516 | for (size_t dy = 0; dy < dst.cols(); ++dy) { |
| 517 | float ry = (dy + 0.5f) * ify - 0.5f; |
| 518 | int sy = static_cast<int>(floor(ry)); |
| 519 | ry -= sy; |
| 520 | if (sy < 0) { |
| 521 | sy = 0; |
| 522 | ry = 0; |
| 523 | } else if (sy + 1 >= static_cast<int>(src.cols())) { |
| 524 | sy = src.cols() - 2; |
| 525 | ry = 1; |
| 526 | } |
| 527 | tabsy[dy] = sy; |
| 528 | tabry[dy] = static_cast<int>(ry * (1 << SCALE)); |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | void calc_cache_8uc1_1( |
| 533 | const Mat8u& src, const Mat8u& dst, const AlignedVector<int>& tabsx, |
no test coverage detected