MCPcopy Index your code
hub / github.com/StevenWang30/R-PCC / intra_predict

Function intra_predict

ops/cpp_modules/src/cpp_modules.cpp:248–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246}
247
248py::array_t<float> intra_predict(py::array_t<int> seg_idx, py::array_t<float> model_param, py::array_t<float> transform_map) {
249 // input array
250 py::buffer_info si_buf = seg_idx.request();
251 int *si_ptr = (int *) si_buf.ptr;
252 py::buffer_info mp_buf = model_param.request();
253 float *mp_ptr = (float *) mp_buf.ptr;
254 py::buffer_info tm_buf = transform_map.request();
255 float *tm_ptr = (float *) tm_buf.ptr;
256 int h = si_buf.shape[0];
257 int w = si_buf.shape[1];
258
259 // return array
260 auto pred_range_image = py::array_t<float>(si_buf.size);
261 py::buffer_info pred_buf = pred_range_image.request();
262 float *pred_ptr = (float *) pred_buf.ptr;
263
264 for (int h_i = 0; h_i < h; h_i++) {
265 for (int w_i = 0; w_i < w; w_i++){
266 int model_idx = si_ptr[h_i * w + w_i];
267 float param[4] = {mp_ptr[model_idx * 4],
268 mp_ptr[model_idx * 4 + 1],
269 mp_ptr[model_idx * 4 + 2],
270 mp_ptr[model_idx * 4 + 3]};
271 if (param[0] + param[1] + param[2] == 0){
272 pred_ptr[h_i * w + w_i] = param[3];
273 }
274 else{
275 float r_plane = -param[3] / (param[0] * tm_ptr[(h_i * w + w_i) * 3] +
276 param[1] * tm_ptr[(h_i * w + w_i) * 3 + 1] +
277 param[2] * tm_ptr[(h_i * w + w_i) * 3 + 2]);
278 pred_ptr[h_i * w + w_i] = r_plane;
279 }
280 }
281 }
282
283 pred_range_image.resize({h, w, 1});
284 return pred_range_image;
285}
286
287
288py::array_t<int> uniform_quantize(py::array_t<int> seg_idx, py::array_t<float> residual, float acc) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected