| 102 | } |
| 103 | |
| 104 | std::string ResizeKernel::GetCVKernelBody(TContext* context) const { |
| 105 | auto kernel_sig = GetCVKernelSignature(context); |
| 106 | std::string body_temp = R"( |
| 107 | #include <math.h> |
| 108 | #include <stdalign.h> |
| 109 | #include <string.h> |
| 110 | #include "marm_neon.h" |
| 111 | #include "tinycv_c.h" |
| 112 | #define rep(i, n) for (int i = 0; i < (n); ++i) |
| 113 | static inline uint8_t output_converter(float x){ |
| 114 | x = fmin(255.0f, fmax(0.0f, x)); |
| 115 | return (uint8_t) roundf(x); |
| 116 | } |
| 117 | |
| 118 | static inline void get_nearest_linear_coord(float scale, int size, int idx, float* ah0, int* ih0, float* ah1, int* ih1){ |
| 119 | if (size == 1) { |
| 120 | *ah0 = 1.f; |
| 121 | *ih0 = 0; |
| 122 | *ah1 = 0.f; |
| 123 | *ih1 = 0; |
| 124 | } |
| 125 | |
| 126 | float alpha = (idx + 0.5f) / scale - 0.5f; |
| 127 | int origin_idx = (int)(floorf(alpha)); |
| 128 | alpha -= origin_idx; |
| 129 | |
| 130 | if (origin_idx < 0) { |
| 131 | origin_idx = 0; |
| 132 | alpha = 0; |
| 133 | } else if (origin_idx + 1 >= size) { |
| 134 | origin_idx = size - 2; |
| 135 | alpha = 1; |
| 136 | } |
| 137 | |
| 138 | *ah0 = 1 - alpha; |
| 139 | *ih0 = origin_idx; |
| 140 | *ah1 = alpha; |
| 141 | *ih1 = origin_idx + 1; |
| 142 | } |
| 143 | #ifdef RESIZE_INT_IMPLEMENT |
| 144 | #define SCALE 11 |
| 145 | static inline void calc_cache_8uc3_1(const uint8_t* src, const int src_h_stride, const uint8_t* dst, const int OW, |
| 146 | const int* tabsx, |
| 147 | const int* tabsy, |
| 148 | const int* tabrx, |
| 149 | const int* tabry, int dx, |
| 150 | int* cache0, int* cache1) { |
| 151 | (void)tabrx; |
| 152 | const uint8_t* psrc1 = src + (tabsx[dx] + 1) * src_h_stride; |
| 153 | |
| 154 | int dy = 0, dy3 = 0; |
| 155 | |
| 156 | for (; dy < OW; ++dy, dy3 += 3) { |
| 157 | const uint8_t* pcsrc10 = psrc1 + (tabsy[dy] + 0) * 3; |
| 158 | const uint8_t* pcsrc11 = psrc1 + (tabsy[dy] + 1) * 3; |
| 159 | int ry = tabry[dy]; |
| 160 | int iry = (1 << SCALE) - ry; |
| 161 | cache1[dy3 + 0] = pcsrc11[0] * ry + pcsrc10[0] * iry; |
nothing calls this directly
no test coverage detected