/* * description: * There are two mode to displsy decoded picture in VO: * (1) bind mode. * (2) user-send mode. * * To use bind mode, call HI_MPI_VDEC_BindOutput(). It is recommended. * To use user-send mode, do as proc_recvPic() did. It is not recommended. * * remark: * How to send pictures to VO is totally left to user in user-send mode. * So it is more complicated, but also more flexible. User can do some * special control in user-send mode. */ void* proc_recvPic(void* p) { HI_S32 s32ret; while(1) { VDEC_DATA_S stVdecData; s32ret = HI_MPI_VDEC_GetData(0, &stVdecData, HI_IO_BLOCK); if (HI_SUCCESS == s32ret) { if(stVdecData.stFrameInfo.bValid) { HI_MPI_VO_SendFrame(0, &stVdecData.stFrameInfo.stVideoFrameInfo); usleep(40000); } HI_MPI_VDEC_ReleaseData(0, &stVdecData); } } return NULL; }
HI_S32 SAMPLE_VIO_TDE_1Screen_VoVGA() { VB_CONF_S stVbConf = {0}; HI_S32 s32ViChnTotal = 1; HI_S32 s32VoChnTotal = 1; VO_DEV VoDev; VO_CHN VoChn; VI_DEV ViDev; VI_CHN ViChn; VI_PUB_ATTR_S stViDevAttr; VI_CHN_ATTR_S stViChnAttr; VO_PUB_ATTR_S stVoDevAttr; VO_VIDEO_LAYER_ATTR_S stVideoLayerAttr; VIDEO_FRAME_INFO_S stFrame; HI_S32 s32Ret = HI_SUCCESS; HI_S32 u32PhyAddr; stVbConf.astCommPool[0].u32BlkSize = 704 * 576 * 2; stVbConf.astCommPool[0].u32BlkCnt = 20; stVbConf.astCommPool[1].u32BlkSize = 384 * 288 * 2; stVbConf.astCommPool[1].u32BlkCnt = 20; if (HI_SUCCESS != SAMPLE_InitMPP(&stVbConf)) { return -1; } /* Config VI to input standard-definition video */ ViDev = 0; SAMPLE_GetViCfg_SD(PIC_D1, &stViDevAttr, &stViChnAttr); // SAMPLE_GetViCfg_SD(PIC_CIF, &stViDevAttr, &stViChnAttr); s32Ret = SAMPLE_StartViByChn(s32ViChnTotal, &stViDevAttr, &stViChnAttr); if (HI_SUCCESS != s32Ret) { return HI_FAILURE; } /* display VGA video on vo HD divice. */ VoDev = VO_DEV_HD; SAMPLE_GetVoCfg_VGA_800x600(&stVoDevAttr, &stVideoLayerAttr); s32Ret = SAMPLE_StartVo(s32VoChnTotal, VoDev, &stVoDevAttr, &stVideoLayerAttr); if (HI_SUCCESS != s32Ret) { return HI_FAILURE; } printf("start VI to VO preview \n"); master_thread_init_ok = 1; sleep(3); /** 1. 打开TDE */ HI_TDE2_Open(); /** 2. 创建Y U V OSD surface */ g_stOsdYSurface.enColorFmt = TDE2_COLOR_FMT_ARGB1555; g_stOsdYSurface.bYCbCrClut = 1; g_stOsdYSurface.bAlphaMax255 = HI_TRUE; g_stOsdYSurface.enColorSpaceConv = TDE2_ITU_R_BT601_VIDEO; g_stOsdUSurface.enColorFmt = TDE2_COLOR_FMT_ARGB1555; g_stOsdUSurface.bYCbCrClut = 0; g_stOsdUSurface.bAlphaMax255 = HI_TRUE; g_stOsdUSurface.enColorSpaceConv = TDE2_ITU_R_BT601_VIDEO; g_stOsdVSurface.enColorFmt = TDE2_COLOR_FMT_ARGB1555; g_stOsdVSurface.bYCbCrClut = 1; g_stOsdVSurface.bAlphaMax255 = HI_TRUE; g_stOsdVSurface.enColorSpaceConv = TDE2_ITU_R_BT601_VIDEO; while(1) { TGT_SET_S *target_set = &gstPeaResult.stTargetSet; EVT_SET_S *event_set = &gstPeaResult.stEventSet; IMP_S32 s32TargetNum = target_set->s32TargetNum; /** 获取图像 */ if (HI_MPI_VI_GetFrame(ViDev, 0, &stFrame)) { printf("HI_MPI_VI_GetFrame err, vi(%d,%d)\n", ViDev, 0); return -1; } if(s32TargetNum > 0 ) { TDE_HANDLE s32Handle; /* 3. 开始TDE任务 */ s32Handle = HI_TDE2_BeginJob(); if(HI_ERR_TDE_INVALID_HANDLE == s32Handle) { printf("start job failed!\n"); continue; } /** 4. 配置YUV Surface数据 长度、宽度、stride、物理地址等 */ u32PhyAddr = stFrame.stVFrame.u32PhyAddr[0]; g_stOsdYSurface.u32Width = stFrame.stVFrame.u32Width; g_stOsdYSurface.u32Height = stFrame.stVFrame.u32Height; g_stOsdYSurface.u32Stride = stFrame.stVFrame.u32Stride[0]; g_stOsdYSurface.u32PhyAddr = u32PhyAddr; g_stOsdUSurface.u32Width = stFrame.stVFrame.u32Width>>1; g_stOsdUSurface.u32Height = stFrame.stVFrame.u32Height>>1; g_stOsdUSurface.u32Stride = stFrame.stVFrame.u32Stride[1]; g_stOsdUSurface.u32PhyAddr = stFrame.stVFrame.u32PhyAddr[1]+1; g_stOsdVSurface = g_stOsdUSurface; g_stOsdVSurface.u32PhyAddr = stFrame.stVFrame.u32PhyAddr[1]; /** 5. 通过TDE绘制修改YUV数据显示PEA数据结果 TDE只支持绘制矩形区域、直线等*/ IMP_TDE_DrawPeaResult( s32Handle, &g_stOsdYSurface,&g_stOsdVSurface, &gstPeaResult,IMP_D1,IMP_QCIF ); /** 6. 直接修改YUV数据显示PEA数据结果 绘制轨迹线、用户配置的规则信息等*/ IMP_DrawPeaResult( &stFrame.stVFrame, &gstPeaResult,IMP_D1,IMP_QCIF ); /** 7. 结束TDE任务 */ s32Ret = HI_TDE2_EndJob(s32Handle, HI_FALSE, HI_TRUE, 10); if(s32Ret < 0) { printf("Line:%d,HI_TDE2_EndJob failed,ret=0x%x!\n", __LINE__, s32Ret); HI_TDE2_CancelJob(s32Handle); return ; } } /** 8. 将修改后的YUV数据送给VO设备 */ HI_MPI_VO_SendFrame( VoDev,0,&stFrame); /** 9. 释放图像 */ HI_MPI_VI_ReleaseFrame(ViDev, 0, &stFrame); }