linear 8u
| 263 | |
| 264 | // linear 8u |
| 265 | void build_tabs_linear_8u( |
| 266 | const Mat8u& src, const Mat8u& dst, AlignedVector<int>& tabsx, |
| 267 | AlignedVector<int>& tabsy, AlignedVector<int>& tabrx, |
| 268 | AlignedVector<int>& tabry) { |
| 269 | megdnn_assert(src.rows() >= 2); |
| 270 | megdnn_assert(src.cols() >= 2); |
| 271 | megdnn_assert(dst.rows() >= 2); |
| 272 | megdnn_assert(dst.cols() >= 2); |
| 273 | const float fx = static_cast<float>(dst.rows()) / src.rows(); |
| 274 | const float fy = static_cast<float>(dst.cols()) / src.cols(); |
| 275 | const float ifx = 1.0f / fx; |
| 276 | const float ify = 1.0f / fy; |
| 277 | for (size_t dx = 0; dx < dst.rows(); ++dx) { |
| 278 | float rx = (dx + 0.5f) * ifx - 0.5f; |
| 279 | int sx = static_cast<int>(floor(rx)); |
| 280 | rx -= sx; |
| 281 | if (sx < 0) { |
| 282 | sx = 0; |
| 283 | rx = 0; |
| 284 | } else if (sx + 1 >= static_cast<int>(src.rows())) { |
| 285 | sx = src.rows() - 2; |
| 286 | rx = 1; |
| 287 | } |
| 288 | tabsx[dx] = sx; |
| 289 | tabrx[dx] = static_cast<int>(rx * (1 << SCALE)); |
| 290 | } |
| 291 | for (size_t dy = 0; dy < dst.cols(); ++dy) { |
| 292 | float ry = (dy + 0.5f) * ify - 0.5f; |
| 293 | int sy = static_cast<int>(floor(ry)); |
| 294 | ry -= sy; |
| 295 | if (sy < 0) { |
| 296 | sy = 0; |
| 297 | ry = 0; |
| 298 | } else if (sy + 1 >= static_cast<int>(src.cols())) { |
| 299 | sy = src.cols() - 2; |
| 300 | ry = 1; |
| 301 | } |
| 302 | tabsy[dy] = sy; |
| 303 | tabry[dy] = static_cast<int>(ry * (1 << SCALE)); |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | void resize_linear_8u(const Mat8u& src, Mat8u& dst) { |
| 308 | AlignedVector<int> tabsx(dst.rows()); |
no test coverage detected