#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* End of #ifdef __cplusplus */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/prctl.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include "sample_comm.h"
pthread_t VgsThreadId;
HI_BOOL bVgsThreadExit = HI_FALSE;
/******************************************************************************
* function : show usage
******************************************************************************/
HI_VOID SAMPLE_VGS_VoInterface_Usage(HI_VOID)
{
printf("intf:\n");
printf("\t 0) vo HDMI output, default.\n");
printf("\t 1) vo BT1120 output.\n");
}
void SAMPLE_VGS_Usage(char* sPrgNm)
{
printf("Usage : %s <index> <intf>\n", sPrgNm);
printf("index:\n");
printf("\t 0) SDR10 COMPRESS, VI - VGS - VO - HDMI. \n");
printf("intf:\n");
printf("\t 0) vo HDMI output, default.\n");
printf("\t 1) vo BT1120 output.\n");
return;
}
/******************************************************************************
* function : to process abnormal case
******************************************************************************/
void SAMPLE_VGS_HandleSig(HI_S32 signo)
{
if (SIGINT == signo || SIGTERM == signo)
{
SAMPLE_COMM_All_ISP_Stop();
SAMPLE_COMM_SYS_Exit();
printf("\033[0;31mprogram termination abnormally!\033[0;39m\n");
}
exit(-1);
}
typedef struct hiSAMPLE_VGS_MOD_INFO_S
{
VI_PIPE ViPipe;
VI_CHN ViChn;
VO_DEV VoDev;
VO_CHN VoChn;
}SAMPLE_VGS_MOD_INFO_S;
static HI_VOID *SAMPLE_VGS_Get_Frame_Thread(HI_VOID *arg)
{
SAMPLE_VGS_MOD_INFO_S *pstVgsModInfo = (SAMPLE_VGS_MOD_INFO_S *)arg;
VI_PIPE ViPipe = pstVgsModInfo->ViPipe;
VI_CHN ViChn = pstVgsModInfo->ViChn;
VO_DEV VoDev = pstVgsModInfo->VoDev;
VO_CHN VoChn = pstVgsModInfo->VoChn;
VGS_HANDLE hHandle;
HI_U32 u32OutWidth = 1920;
HI_U32 u32OutHeight = 1080;
VGS_TASK_ATTR_S stTask;
HI_U32 u32Align;
HI_U32 u32Width;
HI_U32 u32Height;
PIXEL_FORMAT_E enPixelFormat;
DATA_BITWIDTH_E enBitWidth;
COMPRESS_MODE_E enCmpMode;
VB_CAL_CONFIG_S stCalConfig;
VB_BLK VbHandle = 0;
HI_S32 s32Ret = HI_FAILURE;
HI_S32 s32MilliSec = -1;
HI_U32 u32OldDepth = 2;
HI_U32 u32Depth = 2;
VI_CHN_ATTR_S stChnAttr;
HI_CHAR acThreadName[15] = {0};
snprintf(acThreadName,sizeof(acThreadName),"VgsGetFrame");
prctl(PR_SET_NAME,(unsigned long)acThreadName);
/************************************************
Set depth
*************************************************/
s32Ret = HI_MPI_VI_GetChnAttr(ViPipe,ViChn,&stChnAttr);
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_VI_GetChnAttr failed, s32Ret:0x%x\n",s32Ret);
goto EXIT;
}
u32OldDepth = stChnAttr.u32Depth;
stChnAttr.u32Depth = u32Depth;
s32Ret = HI_MPI_VI_SetChnAttr(ViPipe,ViChn,&stChnAttr);
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_VI_SetChnAttr failed, s32Ret:0x%x\n",s32Ret);
goto EXIT;
}
while(HI_FALSE == bVgsThreadExit)
{
/************************************************
Get VI chn frame
*************************************************/
s32Ret = HI_MPI_VI_GetChnFrame(ViPipe, ViChn, &stTask.stImgIn, s32MilliSec);
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_VI_GetChnFrame failed, s32Ret:0x%x\n",s32Ret);
goto EXIT;
}
/************************************************
Create VGS job
*************************************************/
u32Align = 32;
enCmpMode = COMPRESS_MODE_SEG;
enPixelFormat = PIXEL_FORMAT_YVU_SEMIPLANAR_420;
enBitWidth = DATA_BITWIDTH_10;
u32Width = u32OutWidth;
u32Height = u32OutHeight;
COMMON_GetPicBufferConfig(u32Width, u32Height, enPixelFormat, enBitWidth, enCmpMode, u32Align, &stCalConfig);
VbHandle = HI_MPI_VB_GetBlock(VB_INVALID_POOLID, stCalConfig.u32VBSize, HI_NULL);
if (VB_INVALID_HANDLE == VbHandle)
{
SAMPLE_PRT("HI_MPI_VB_GetBlock failed!\n");
goto EXIT;
}
stTask.stImgOut.u32PoolId = HI_MPI_VB_Handle2PoolId(VbHandle);
stTask.stImgOut.enModId = HI_ID_VGS;
stTask.stImgOut.stVFrame.u32Width = u32Width;
stTask.stImgOut.stVFrame.u32Height = u32Height;
stTask.stImgOut.stVFrame.enDynamicRange = DYNAMIC_RANGE_SDR10;
stTask.stImgOut.stVFrame.enCompressMode = enCmpMode;
stTask.stImgOut.stVFrame.enPixelFormat = enPixelFormat;
stTask.stImgOut.stVFrame.enVideoFormat = VIDEO_FORMAT_LINEAR;
stTask.stImgOut.stVFrame.enField = VIDEO_FIELD_FRAME;
stTask.stImgOut.stVFrame.enColorGamut = COLOR_GAMUT_BT709;
stTask.stImgOut.stVFrame.u32MaxLuminance = 1200;
stTask.stImgOut.stVFrame.u32MinLuminance = 200;
stTask.stImgOut.stVFrame.u64HeaderPhyAddr[0] = HI_MPI_VB_Handle2PhysAddr(VbHandle);
stTask.stImgOut.stVFrame.u64HeaderPhyAddr[1] = stTask.stImgOut.stVFrame.u64HeaderPhyAddr[0] + stCalConfig.u32HeadYSize;
stTask.stImgOut.stVFrame.u64HeaderPhyAddr[2] = stTask.stImgOut.stVFrame.u64HeaderPhyAddr[1];
stTask.stImgOut.stVFrame.u64HeaderVirAddr[0] = (HI_U64)HI_MPI_SYS_Mmap(stTask.stImgOut.stVFrame.u64HeaderPhyAddr[0], stCalConfig.u32VBSize);
stTask.stImgOut.stVFrame.u64HeaderVirAddr[1] = stTask.stImgOut.stVFrame.u64HeaderVirAddr[0] + stCalConfig.u32HeadYSize;
stTask.stImgOut.stVFrame.u64HeaderVirAddr[2] = stTask.stImgOut.stVFrame.u64HeaderVirAddr[1];
stTask.stImgOut.stVFrame.u32HeaderStride[0] = stCalConfig.u32HeadStride;
stTask.stImgOut.stVFrame.u32HeaderStride[1] = stCalConfig.u32HeadStride;
stTask.stImgOut.stVFrame.u32HeaderStride[2] = stCalConfig.u32HeadStride;
stTask.stImgOut.stVFrame.u64PhyAddr[0] = stTask.stImgOut.stVFrame.u64HeaderPhyAddr[0] + stCalConfig.u32HeadSize;
stTask.stImgOut.stVFrame.u64PhyAddr[1] = stTask.stImgOut.stVFrame.u64PhyAddr[0] + stCalConfig.u32MainYSize;
stTask.stImgOut.stVFrame.u64PhyAddr[2] = stTask.stImgOut.stVFrame.u64PhyAddr[1];
stTask.stImgOut.stVFrame.u64VirAddr[0] = stTask.stImgOut.stVFrame.u64HeaderVirAddr[0] + stCalConfig.u32HeadSize;
stTask.stImgOut.stVFrame.u64VirAddr[1] = stTask.stImgOut.stVFrame.u64VirAddr[0] + stCalConfig.u32MainYSize;
stTask.stImgOut.stVFrame.u64VirAddr[2] = stTask.stImgOut.stVFrame.u64VirAddr[1];
stTask.stImgOut.stVFrame.u32Stride[0] = stCalConfig.u32MainStride;
stTask.stImgOut.stVFrame.u32Stride[1] = stCalConfig.u32MainStride;
stTask.stImgOut.stVFrame.u32Stride[2] = stCalConfig.u32MainStride;
stTask.stImgOut.stVFrame.u64ExtPhyAddr[0] = stTask.stImgOut.stVFrame.u64PhyAddr[0] + stCalConfig.u32MainSize;
stTask.stImgOut.stVFrame.u64ExtPhyAddr[1] = stTask.stImgOut.stVFrame.u64ExtPhyAddr[0] + stCalConfig.u32ExtYSize;
stTask.stImgOut.stVFrame.u64ExtPhyAddr[2] = stTask.stImgOut.stVFrame.u64ExtPhyAddr[1];
stTask.stImgOut.stVFrame.u64ExtVirAddr[0] = stTask.stImgOut.stVFrame.u64VirAddr[0] + stCalConfig.u32MainSize;
stTask.stImgOut.stVFrame.u64ExtVirAddr[1] = s
没有合适的资源?快使用搜索试试~ 我知道了~
vgs.rar_python
共4个文件
o:1个
makefile:1个
sample_vgs:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 44 浏览量
2022-09-15
01:57:19
上传
评论
收藏 862KB RAR 举报
温馨提示
用于神经网络加速的算法,提高数组的操作
资源推荐
资源详情
资源评论
收起资源包目录
vgs.rar (4个子文件)
vgs
sample_vgs.c 17KB
sample_vgs.o 90KB
Makefile 174B
sample_vgs 3.07MB
共 4 条
- 1
资源评论
钱亚锋
- 粉丝: 90
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功