// Include the header
#include "hobot/hb_ucp.h"
#include "hobot/vp/hb_vp.h"
#include "hobot/vp/hb_vp_remap.h"
// init remap param
hbUCPSysMem custom_mem;
hbUCPMallocCached(&custom_mem, width * height * sizeof(double) * 2, 0);
hbVPRemapParam param;
param.srcHeight = height;
param.srcWidth = width;
param.mapHeight = height;
param.mapWidth = width;
param.mapPhyAddr = custom_mem.phyAddr;
param.mapVirAddr = custom_mem.virAddr;
param.dataType = HB_VP_IMAGE_TYPE_F64C2;
param.interpoType = HB_VP_INTER_LINEAR;
// init param
hbVPMapWrap_t vp_map_wrap{nullptr};
// create map
hbVPCreateMapWrap(&vp_map_wrap, ¶m, HB_UCP_CORE_ANY);
// init Image, allocate memory for image data
hbUCPSysMem src_mem;
hbUCPMallocCached(&src_mem, src_stride * src_height * 3 / 2, 0);
hbVPImage src_img{HB_VP_IMAGE_FORMAT_NV12,
HB_VP_IMAGE_TYPE_U8C1,
src_width,
src_height,
src_stride,
src_mem.virAddr,
src_mem.phyAddr,
reinterpret_cast<char *>(src_img.dataVirAddr) + src_stride * src_height,
src_img.dataPhyAddr + src_stride * src_height,
src_stride};
hbUCPSysMem dst_mem;
hbUCPMallocCached(&dst_mem, dst_stride * dst_height * 3 / 2, 0);
hbVPImage dst_img{HB_VP_IMAGE_FORMAT_NV12,
HB_VP_IMAGE_TYPE_U8C1,
dst_width,
dst_height,
dst_stride,
dst_mem.virAddr,
dst_mem.phyAddr,
reinterpret_cast<char *>(dst_img.dataVirAddr) + dst_stride * dst_height,
dst_img.dataPhyAddr + dst_stride * dst_height,
dst_stride};
// init task handle and schedule param
hbUCPTaskHandle_t task_handle{nullptr};
hbUCPSchedParam sched_param;
HB_UCP_INITIALIZE_SCHED_PARAM(&sched_param);
sched_param.backend = HB_UCP_DSP_CORE_0;
// create task
hbVPRemap(&task_handle, &dst_img, &src_img, vp_map_wrap);
// submit task
hbUCPSubmitTask(task_handle, &sched_param);
// wait for task done
hbUCPWaitTaskDone(task_handle, 0);
// release task handle
hbUCPReleaseTask(task_handle);
// release map
hbVPReleaseMapWrap(vp_map_wrap);
// release memory
hbUCPFree(&custom_mem);
hbUCPFree(&src_mem);
hbUCPFree(&dst_mem);