资源简介
海思ive 用户图像基本操作,后续会上传ive图像处理详情请参考博客
http://blog.csdn.net/qq_21193563/article/details/78401966
代码片段和文件信息
/*
* userHisiCode.c
*
* Created on: 2017年10月31日
* Author: JasonHuo
*/
#include “userHisiCode.h“
#include
#include
#include
static int userIveAllocImg(IVE_IMAGE_S *pImgIVE_IMAGE_TYPE_E imgTypeint widthint height)
{
int size = 0;
int ret = 0;
//判断输入指针是否为空
if(pImg==NULL)
return HI_FAILURE;
//配置图像类型和计算图像基本信息
pImg->enType = imgType;
pImg->u16Height = (HI_U16)height;
pImg->u16Width = (HI_U16)width;
pImg->u16Stride[0] = CALC_STRIDE(widthUSER_IVE_ALIGN);
switch(imgType)
{
//八位单通道图像
case IVE_IMAGE_TYPE_U8C1:
case IVE_IMAGE_TYPE_S8C1:
{
size = pImg->u16Stride[0]*pImg->u16Height;
ret = HI_MPI_SYS_MmzAlloc_Cached(&pImg->u32PhyAddr[0] (void**)&pImg->pu8VirAddr[0] NULL HI_NULL size);
HI_CHECK_MPI_SYS_RET(ret“userIveAllocImg failError(%#x)\r\n“);
}break;
//yuv420sp格式
case IVE_IMAGE_TYPE_YUV420SP:
{
size = (pImg->u16Stride[0]*pImg->u16Height*3)>>1;//1.5倍的图像尺寸
ret = HI_MPI_SYS_MmzAlloc_Cached(&pImg->u32PhyAddr[0] (void**)&pImg->pu8VirAddr[0] NULL HI_NULL size);
HI_CHECK_MPI_SYS_RET(ret“userIveAllocImg failError(%#x)\r\n“);
pImg->u16Stride[1] = pImg->u16Stride[0];
pImg->pu8VirAddr[1] = pImg->pu8VirAddr[0] + pImg->u16Stride[0]*pImg->u16Height;
pImg->u32PhyAddr[1] = pImg->u32PhyAddr[1] + pImg->u16Stride[0]*pImg->u16Height;
}break;
//yuv420p
case IVE_IMAGE_TYPE_YUV420P:
{
size = (pImg->u16Stride[0]*pImg->u16Height*3)>>1;//1.5倍的图像尺寸
ret = HI_MPI_SYS_MmzAlloc_Cached(&pImg->u32PhyAddr[0] (void**)&pImg->pu8VirAddr[0] NULL HI_NULL size);
HI_CHECK_MPI_SYS_RET(ret“userIveAllocImg failError(%#x)\r\n“);
int tempWidth = width>>1;
pImg->u16Stride[1] = CALC_STRIDE(tempWidthUSER_IVE_ALIGN);
pImg->pu8VirAddr[1] = pImg->pu8VirAddr[0] + pImg->u16Stride[0]*pImg->u16Height;
pImg->u32PhyAddr[1] = pImg->u32PhyAddr[0] + pImg->u16Stride[0]*pImg->u16Height;
pImg->u16Stride[2] = pImg->u16Stride[1];
pImg->pu8VirAddr[2] = pImg->pu8VirAddr[1] + pImg->u16Stride[1]*pImg->u16Height/2;
pImg->u32PhyAddr[2] = pImg->u32PhyAddr[1] + pImg->u16Stride[1]*pImg->u16Height/2;
}break;
//yuv422sp
case IVE_IMAGE_TYPE_YUV422SP:
// case IVE_IMAGE_TYPE_S8C2_PLANAR:
{
size = pImg->u16Stride[0]*pImg->u16Height*2;//2倍的图像尺寸
ret = HI_MPI_SYS_MmzAlloc_Cached(&pImg->u32PhyAddr[0] (void**)&pImg->pu8VirAddr[0] NULL HI_NULL size);
HI_CHECK_MPI_SYS_RET(ret“userIveAllocImg failError(%#x)\r\n“);
pImg->u16Stride[1] = pImg->u16Stride[0];
pImg->pu8VirAddr[1] = pImg->pu8VirAddr[0] + pImg->u16Stride[0]*pImg->u16Height;
pImg->u32PhyAddr[1] = pImg->u32PhyAddr[0] + pImg->u16Stride[0]*pImg->u16Height;
}break;
//yuv422p
case IVE_IMAGE_TYPE_YUV422P:
{
size = pImg->u16Stride[0]*pImg->u16Height*2;//2倍的图像尺寸
ret = HI_MPI_SYS_MmzAlloc_Cached(&pImg->u32PhyAddr[0] (void**)&pImg->pu8VirAddr[0] NULL HI_NULL size);
HI_CHECK_MPI_SYS_RET(ret“userIveAllocImg failError(%#x)\r\n“);
int tempWidth = width>>1;
pImg->u16Stride[1] = CALC_STRIDE(tempWidthUSER_IVE_
- 上一篇:类似携程的城市选择
- 下一篇:STM32F103超声波检测
评论
共有 条评论