mpp 海思HI_MPI_IVE_DMA抠图
原文链接: mpp 海思HI_MPI_IVE_DMA抠图
s32Ret = HI_MPI_VPSS_GetChnFrame(s32VpssGrp, as32VpssChn[1], &stExtFrmInfo, s32MilliSec);
海思HI_MPI_IVE_DMA抠图
从原图坐标(x_start, y_start)为起点,抠大小为width_dst、height_dst的图:
int yuv400_crop(uint32_t width_src, uint32_t height_src, VIDEO_FRAME_INFO_S *stFrame,
uint32_t x_start, uint32_t y_start, uint32_t width_dst, uint32_t height_dst, IVE_IMAGE_S * dst_mmz) {
if (width_dst == 0 || height_dst == 0 ||
(x_start + width_dst) > width_src || (y_start + height_dst) > height_src) {
return -1;
}
IVE_HANDLE hIveHandle;
IVE_SRC_DATA_S stSrcData;
IVE_DST_DATA_S stDstData;
HI_S32 s32Ret;
IVE_DMA_CTRL_S stCtrl = {IVE_DMA_MODE_DIRECT_COPY,0};
HI_BOOL bInstant = HI_TRUE;
HI_BOOL bBlock = HI_TRUE;
HI_BOOL bFinish = HI_FALSE;
//fill src
//stSrcData.u64VirAddr = pstFrameInfo->stVFrame.u64VirAddr[0];
stSrcData.u64PhyAddr = (stFrame->stVFrame.u64PhyAddr[0]) + (stFrame->stVFrame.u32Stride[0]) * y_start + x_start;
stSrcData.u32Width = BSF_BMP_WIDTH;
stSrcData.u32Height = BSF_BMP_HEIGHT;
stSrcData.u32Stride = stFrame->stVFrame.u32Stride[0];
//fill dst
//stDstData.u64VirAddr = pstDst->au64VirAddr[0];
stDstData.u64PhyAddr = (dst_mmz->au64PhyAddr[0]);
stDstData.u32Width = BSF_BMP_WIDTH;
stDstData.u32Height = BSF_BMP_HEIGHT;
stDstData.u32Stride = BSF_BMP_WIDTH;
s32Ret = HI_MPI_IVE_DMA(&hIveHandle,&stSrcData,&stDstData,&stCtrl,bInstant);
if (HI_SUCCESS == s32Ret && HI_TRUE == bInstant) {
}
s32Ret = HI_MPI_IVE_Query(hIveHandle, &bFinish, bBlock);
while (HI_ERR_IVE_QUERY_TIMEOUT == s32Ret)
{
usleep(100);
s32Ret = HI_MPI_IVE_Query(hIveHandle, &bFinish, bBlock);
}
return 0;
}