3941
- 收藏
- 点赞
- 分享
- 举报
HI_MPI_VENC_SendFrame failed 0xa0088003!
各位大牛!本人在hi3519av100上做视频压缩,通过读取yuv420sp文件发送给venc编码 但是不管怎么操作都是参数错误!!!
pFile1 = fopen("test.h264","wb+");
if(pFile1 == NULL)
{
printf("new test.h264 file failed\n");
return -1;
}
pFile2 = fopen("yuv420sp","r+");
if(pFile2 == NULL)
{
printf("open yuv420sp file failed\n");
return -1;
}
VencFd = HI_MPI_VENC_GetFd(VencChn);
if (VencFd < 0)
{
SAMPLE_PRT("HI_MPI_VENC_GetFd failed with %#x!\n",VencFd);
return NULL;
}
VB_POOL_CONFIG_S stVbPoolCfg;
VB_BLK handleY = VB_INVALID_HANDLE;
HI_U32 phyYaddr,*pVirYaddr;
VIDEO_FRAME_INFO_S *pstFrame = malloc(sizeof(VIDEO_FRAME_INFO_S));
HI_U32 u32Stride;
HI_U32 u32LStride;
HI_U32 u32CStride;
HI_U32 u32LumaSize = 0;
HI_U32 u32ChrmSize = 0;
HI_U32 u32Size;
u32Stride = ALIGN_UP((1920 * 8 + 7) >> 3, DEFAULT_ALIGN);
u32LStride = u32Stride;
u32CStride = u32Stride;
u32Size = u32Stride * 1080 * 3 / 2;
u32LumaSize = u32Stride * 1080;
u32ChrmSize = u32Stride * 1080 / 4;
memset(&stVbPoolCfg, 0, sizeof(VB_POOL_CONFIG_S));
stVbPoolCfg.u64BlkSize = u32Size;
stVbPoolCfg.u32BlkCnt = 2;
stVbPoolCfg.enRemapMode = VB_REMAP_MODE_NONE;
VB_POOL u32PoolId = HI_MPI_VB_CreatePool(&stVbPoolCfg);
/******************************************
step 2: Start to get streams of each channel.
******************************************/
while (frame < 30)
{
/* 分配物理buffer并且映射到用户空间 */
do
{
handleY = HI_MPI_VB_GetBlock(u32PoolId, 1920 * 1080 * 3 / 2, NULL);
}
while (VB_INVALID_HANDLE == handleY);
if( handleY == VB_INVALID_HANDLE)
{
printf("getblock for y failed\n");
return -1;
}
VB_POOL poolID = HI_MPI_VB_Handle2PoolId (handleY);
phyYaddr = HI_MPI_VB_Handle2PhysAddr(handleY);
if( phyYaddr == 0)
{
printf("HI_MPI_VB_Handle2PhysAddr for handleY failed\n");
return -1;
}
pVirYaddr = (HI_U8*) HI_MPI_SYS_Mmap(phyYaddr, 1920 * 1080 * 3 / 2);
/* 图像帧结构初始化 */
memset(&(pstFrame->stVFrame),0x00,sizeof(VIDEO_FRAME_S));
pstFrame->stVFrame.u32Width = 1920;
pstFrame->stVFrame.u32Height = 1080;
pstFrame->stVFrame.enPixelFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420;
pstFrame->u32PoolId = poolID;
//pstFrame->enModId = HI_ID_VI;
pstFrame->stVFrame.enField = VIDEO_FIELD_FRAME;
pstFrame->stVFrame.enCompressMode = COMPRESS_MODE_NONE;
//pstFrame->stVFrame.enVideoFormat = VIDEO_FORMAT_LINEAR;
pstFrame->stVFrame.u64PTS = frame * 40;
pstFrame->stVFrame.u32TimeRef = frame * 2;
//pstFrame->stVFrame.enDynamicRange = DYNAMIC_RANGE_SDR8;
//pstFrame->stVFrame.enColorGamut = COLOR_GAMUT_BT709;
pstFrame->stVFrame.u64PhyAddr[0] = phyYaddr;
pstFrame->stVFrame.u64PhyAddr[1] = pstFrame->stVFrame.u64PhyAddr[0] + u32LumaSize;
pstFrame->stVFrame.u64PhyAddr[2] = pstFrame->stVFrame.u64PhyAddr[1] + u32ChrmSize;
pstFrame->stVFrame.u64VirAddr[0] = (HI_U64)(HI_UL)pVirYaddr;
pstFrame->stVFrame.u64VirAddr[1] = (HI_UL)(pstFrame->stVFrame.u64VirAddr[0]) + u32LumaSize;
pstFrame->stVFrame.u64VirAddr[2] = (HI_UL)(pstFrame->stVFrame.u64VirAddr[1]) + u32ChrmSize;
pstFrame->stVFrame.u32Stride[0] = u32LStride ;
pstFrame->stVFrame.u32Stride[1] = u32CStride ;
pstFrame->stVFrame.u32Stride[2] = u32CStride ;
printf("u32Stride = %d,u32Size = %d,u32LumaSize = %d,u32ChrmSize = %d,u32LStride = %d\n",u32Stride,u32Size,u32LumaSize,u32ChrmSize,u32LStride);
/* 从原始文件读取yuv420sp帧,然后调用给编码接口 */
//SAMPLE_VI_COMM_ReadYuvFile(pFile2, pstFrame);
s32Ret = fread(pVirYaddr,1920 * 1080 * 3 / 2, 1, pFile2);
if(s32Ret < 0)
{
printf("fread yuv420sp failed\n");
return -1;
}
/* 开始发送读到的数据到编码接口 */
s32Ret = HI_MPI_VENC_SendFrame(VencChn, pstFrame, -1);
if(s32Ret != 0)
{
//printf("HI_MPI_VENC_SendFrame failed %d\n",s32Ret);
SAMPLE_PRT("HI_MPI_VENC_SendFrame failed %#x!\n", s32Ret);
HI_MPI_SYS_Munmap(pVirYaddr, 1920 * 1080 * 3 / 2);
HI_MPI_VB_ReleaseBlock(handleY);
HI_MPI_VB_DestroyPool(u32PoolId);
handleY = VB_INVALID_HANDLE;
return -1;
}
pFile1 = fopen("test.h264","wb+");
if(pFile1 == NULL)
{
printf("new test.h264 file failed\n");
return -1;
}
pFile2 = fopen("yuv420sp","r+");
if(pFile2 == NULL)
{
printf("open yuv420sp file failed\n");
return -1;
}
VencFd = HI_MPI_VENC_GetFd(VencChn);
if (VencFd < 0)
{
SAMPLE_PRT("HI_MPI_VENC_GetFd failed with %#x!\n",VencFd);
return NULL;
}
VB_POOL_CONFIG_S stVbPoolCfg;
VB_BLK handleY = VB_INVALID_HANDLE;
HI_U32 phyYaddr,*pVirYaddr;
VIDEO_FRAME_INFO_S *pstFrame = malloc(sizeof(VIDEO_FRAME_INFO_S));
HI_U32 u32Stride;
HI_U32 u32LStride;
HI_U32 u32CStride;
HI_U32 u32LumaSize = 0;
HI_U32 u32ChrmSize = 0;
HI_U32 u32Size;
u32Stride = ALIGN_UP((1920 * 8 + 7) >> 3, DEFAULT_ALIGN);
u32LStride = u32Stride;
u32CStride = u32Stride;
u32Size = u32Stride * 1080 * 3 / 2;
u32LumaSize = u32Stride * 1080;
u32ChrmSize = u32Stride * 1080 / 4;
memset(&stVbPoolCfg, 0, sizeof(VB_POOL_CONFIG_S));
stVbPoolCfg.u64BlkSize = u32Size;
stVbPoolCfg.u32BlkCnt = 2;
stVbPoolCfg.enRemapMode = VB_REMAP_MODE_NONE;
VB_POOL u32PoolId = HI_MPI_VB_CreatePool(&stVbPoolCfg);
/******************************************
step 2: Start to get streams of each channel.
******************************************/
while (frame < 30)
{
/* 分配物理buffer并且映射到用户空间 */
do
{
handleY = HI_MPI_VB_GetBlock(u32PoolId, 1920 * 1080 * 3 / 2, NULL);
}
while (VB_INVALID_HANDLE == handleY);
if( handleY == VB_INVALID_HANDLE)
{
printf("getblock for y failed\n");
return -1;
}
VB_POOL poolID = HI_MPI_VB_Handle2PoolId (handleY);
phyYaddr = HI_MPI_VB_Handle2PhysAddr(handleY);
if( phyYaddr == 0)
{
printf("HI_MPI_VB_Handle2PhysAddr for handleY failed\n");
return -1;
}
pVirYaddr = (HI_U8*) HI_MPI_SYS_Mmap(phyYaddr, 1920 * 1080 * 3 / 2);
/* 图像帧结构初始化 */
memset(&(pstFrame->stVFrame),0x00,sizeof(VIDEO_FRAME_S));
pstFrame->stVFrame.u32Width = 1920;
pstFrame->stVFrame.u32Height = 1080;
pstFrame->stVFrame.enPixelFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420;
pstFrame->u32PoolId = poolID;
//pstFrame->enModId = HI_ID_VI;
pstFrame->stVFrame.enField = VIDEO_FIELD_FRAME;
pstFrame->stVFrame.enCompressMode = COMPRESS_MODE_NONE;
//pstFrame->stVFrame.enVideoFormat = VIDEO_FORMAT_LINEAR;
pstFrame->stVFrame.u64PTS = frame * 40;
pstFrame->stVFrame.u32TimeRef = frame * 2;
//pstFrame->stVFrame.enDynamicRange = DYNAMIC_RANGE_SDR8;
//pstFrame->stVFrame.enColorGamut = COLOR_GAMUT_BT709;
pstFrame->stVFrame.u64PhyAddr[0] = phyYaddr;
pstFrame->stVFrame.u64PhyAddr[1] = pstFrame->stVFrame.u64PhyAddr[0] + u32LumaSize;
pstFrame->stVFrame.u64PhyAddr[2] = pstFrame->stVFrame.u64PhyAddr[1] + u32ChrmSize;
pstFrame->stVFrame.u64VirAddr[0] = (HI_U64)(HI_UL)pVirYaddr;
pstFrame->stVFrame.u64VirAddr[1] = (HI_UL)(pstFrame->stVFrame.u64VirAddr[0]) + u32LumaSize;
pstFrame->stVFrame.u64VirAddr[2] = (HI_UL)(pstFrame->stVFrame.u64VirAddr[1]) + u32ChrmSize;
pstFrame->stVFrame.u32Stride[0] = u32LStride ;
pstFrame->stVFrame.u32Stride[1] = u32CStride ;
pstFrame->stVFrame.u32Stride[2] = u32CStride ;
printf("u32Stride = %d,u32Size = %d,u32LumaSize = %d,u32ChrmSize = %d,u32LStride = %d\n",u32Stride,u32Size,u32LumaSize,u32ChrmSize,u32LStride);
/* 从原始文件读取yuv420sp帧,然后调用给编码接口 */
//SAMPLE_VI_COMM_ReadYuvFile(pFile2, pstFrame);
s32Ret = fread(pVirYaddr,1920 * 1080 * 3 / 2, 1, pFile2);
if(s32Ret < 0)
{
printf("fread yuv420sp failed\n");
return -1;
}
/* 开始发送读到的数据到编码接口 */
s32Ret = HI_MPI_VENC_SendFrame(VencChn, pstFrame, -1);
if(s32Ret != 0)
{
//printf("HI_MPI_VENC_SendFrame failed %d\n",s32Ret);
SAMPLE_PRT("HI_MPI_VENC_SendFrame failed %#x!\n", s32Ret);
HI_MPI_SYS_Munmap(pVirYaddr, 1920 * 1080 * 3 / 2);
HI_MPI_VB_ReleaseBlock(handleY);
HI_MPI_VB_DestroyPool(u32PoolId);
handleY = VB_INVALID_HANDLE;
return -1;
}
我来回答
回答2个
时间排序
认可量排序
认可0
认可0
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2019-08-30 09:57:03
-
2020-07-23 17:45:58
-
2017-09-20 15:05:29
-
2019-07-12 18:29:38
-
2020-08-06 12:57:35
-
2019-03-13 15:57:54
-
2022-11-02 20:17:05
-
2019-09-01 12:01:05
-
2016-06-23 09:48:58
-
2020-10-29 11:14:15
-
2016-10-26 11:55:21
-
2018-11-19 08:53:29
-
2017-08-10 21:02:27
-
2018-07-24 16:43:24
-
2018-09-21 08:56:19
-
2016-09-10 09:35:34
-
2017-03-10 11:44:32
-
2020-04-07 11:51:15
-
2016-09-20 16:15:23
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
5cat /dev/logmpp 报错 <3>[ vi] [func]:vi_send_frame_node [line]:99 [info]:vi pic queue is full!
-
50如何获取vpss chn的图像修改后发送至vo
-
5FPGA通过Bt1120传YUV422数据过来,vi接收不到数据——3516dv500
-
50SS928 运行PQtools 拼接 推到设备里有一半画面会异常
-
53536AV100的sample_vdec输出到CVBS显示
-
10海思板子mpp怎么在vi阶段改变视频数据尺寸
-
10HI3559AV100 多摄像头同步模式
-
9海思ss928单路摄像头vio中加入opencv处理并显示
-
10EB-RV1126-BC-191板子运行自己编码的程序
-
10求HI3519DV500_SDK_V2.0.1.1
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认