hi3518e - mpp2/sample_venc 解读

SAMPLE_VENC_720P_MJPEG(HI_VOID)
// step  1: init sys variable 
 u32BlkSize = SAMPLE_COMM_SYS_CalcPicVbBlkSize(gs_enNorm,\
                enSize, SAMPLE_PIXEL_FORMAT, SAMPLE_SYS_ALIGN_WIDTH,);
// step 2: mpp system init. 
s32Ret = SAMPLE_COMM_SYS_Init(&stVbConf);
    HI_MPI_SYS_Exit();
    HI_MPI_VB_Exit();
    s32Ret = HI_MPI_VB_SetConf(pstVbConf);
    s32Ret = HI_MPI_VB_Init();
    s32Ret = HI_MPI_SYS_SetConf(&stSysConf);
    s32Ret = HI_MPI_SYS_Init();
// step 3: start vi dev & chn to capture
s32Ret = SAMPLE_COMM_VI_StartVi(&stViConfig);
    s32Ret = SAMPLE_COMM_VI_StartIsp(pstViConfig);
    			//* step 1: configure sensor.
    			s32Ret = SAMPLE_COMM_ISP_SensorInit();
    					  //** 1. sensor init */
    					 sensor_init();
    					 			sensor_write_register(int addr, int data)
    					 						 //  打开的是/dev/gpioi2c_ov 还是/dev/hi_i2c 要由#ifdef HI_GPIO_I2C确定
     					 						 fd = open("/dev/gpioi2c_ov", 0);
    					 						 ret = ioctl(fd, GPIO_I2C_WRITE, &value);
    					 					   close(fd);
    					 //** 2. sensor register callback */
    					 s32Ret = sensor_register_callback(); ??
    		  //* step 2: configure & run isp thread 
    		  s32Ret = SAMPLE_COMM_ISP_Run();
    		  			s32Ret = SAMPLE_COMM_ISP_Init();
    		  			pthread_create(&gs_IspPid, 0, (void* (*)(void*))HI_MPI_ISP_Run, NULL)
    		  			s32Ret = SAMPLE_COMM_ISP_LoadRegFile(CFG_OPT_LOAD, SAMPLE_ISPCFG_FILE);
    		  
    		  //* step 3 : config & start vicap dev
    		  s32Ret = SAMPLE_COMM_VI_StartDev(ViDev, enViMode);
    		  			memcpy(&stViDevAttr,&DEV_ATTR_OV9712_DC_720P,sizeof(stViDevAttr));
    		  			s32Ret = HI_MPI_VI_SetDevAttr(ViDev, &stViDevAttr);  //设置设备的属性
    		  			s32Ret = HI_MPI_VI_EnableDev(ViDev);
    		  //* Step 4: config & start vicap chn (max 1)  			
    	 	  s32Ret = SAMPLE_COMM_VI_StartChn(ViChn, &stCapRect, &stTargetSize, pstViConfig);
    		 				s32Ret = HI_MPI_VI_SetChnAttr(ViChn, &stChnAttr);
    		 				s32Ret = HI_MPI_VI_SetRotate(ViChn, enRotate);
    		 				s32Ret = HI_MPI_VI_EnableChn(ViChn);
// step 4: start vpss and vi bind vpss	 				
s32Ret = SAMPLE_COMM_SYS_GetPicSize(gs_enNorm, enSize, &stSize);
s32Ret = SAMPLE_COMM_VPSS_StartGroup(VpssGrp, &stVpssGrpAttr);    
			s32Ret = HI_MPI_VPSS_CreateGrp(VpssGrp, pstVpssGrpAttr);
			s32Ret = HI_MPI_VPSS_GetGrpParam(VpssGrp, &stVpssParam);
			s32Ret = HI_MPI_VPSS_SetGrpParam(VpssGrp, &stVpssParam);
			s32Ret = HI_MPI_VPSS_StartGrp(VpssGrp);
s32Ret = SAMPLE_COMM_VI_BindVpss(stViConfig.enViMode);			
			s32Ret = SAMPLE_COMM_VI_Mode2Param(enViMode, &stViParam);
			s32Ret = HI_MPI_SYS_Bind(&stSrcChn, &stDestChn);
s32Ret = SAMPLE_COMM_VPSS_EnableChn(VpssGrp, VpssChn, &stVpssChnAttr, HI_NULL, HI_NULL);
			s32Ret = HI_MPI_VPSS_SetChnAttr(VpssGrp, VpssChn, pstVpssChnAttr);
			s32Ret = HI_MPI_VPSS_SetChnMode(VpssGrp, VpssChn, pstVpssChnMode);
			s32Ret = HI_MPI_VPSS_EnableChn(VpssGrp, VpssChn);
// step 5: start stream venc			
s32Ret = SAMPLE_COMM_VENC_Start(VencGrp, VencChn, enPayLoad,gs_enNorm, enSize, enRcMode);
s32Ret = SAMPLE_COMM_VENC_BindVpss(VencGrp, VpssGrp, VpssChn);
			s32Ret = HI_MPI_SYS_Bind(HI_ID_VPSS, HI_ID_GROUP);
// step 6: stream venc process -- get stream, then save it to file. 
s32Ret = SAMPLE_COMM_VENC_StartGetStream(s32ChnNum);
			pthread_create(&gs_VencPid, 0, SAMPLE_COMM_VENC_GetVencStreamProc, (HI_VOID*)&gs_stPara);
getchar();
getchar();



产生的线程一:(pthread_create(&gs_IspPid, 0, (void* (*)(void*))HI_MPI_ISP_Run, NULL))
(void* (*)(void*))HI_MPI_ISP_Run

产生的线程二:pthread_create(&gs_VencPid, 0, SAMPLE_COMM_VENC_GetVencStreamProc, (HI_VOID*)&gs_stPara);
HI_VOID* SAMPLE_COMM_VENC_GetVencStreamProc(HI_VOID *p)

//  step 1:  check & prepare save-file & venc-fd
s32Ret = HI_MPI_VENC_GetChnAttr(VencChn, &stVencChnAttr);
s32Ret = SAMPLE_COMM_VENC_GetFilePostfix(enPayLoadType[i], szFilePostfix);
			strcpy(szFilePostfix, ".h264");
sprintf(aszFileName[i], "stream_chn%d%s", i, szFilePostfix);
pFile[i] = fopen(aszFileName[i], "wb");
VencFd[i] = HI_MPI_VENC_GetFd(i);

//  step 2:  Start to get streams of each channel.
while (HI_TRUE == pstPara->bThreadStart)
{
s32Ret = HI_MPI_VENC_Query(i, &stStat);
stStream.pstPack = (VENC_PACK_S*)malloc(sizeof(VENC_PACK_S) * stStat.u32CurPacks);
s32Ret = HI_MPI_VENC_GetStream(i, &stStream, HI_TRUE);
s32Ret = SAMPLE_COMM_VENC_SaveStream(enPayLoadType[i], pFile[i], &stStream);
			s32Ret = SAMPLE_COMM_VENC_SaveH264(pFd, pstStream);
						 fwrite(pstStream->pstPack[i].pu8Addr[0],pstStream->pstPack[i].u32Len[0], 1, fpH264File);
             fflush(fpH264File);
s32Ret = HI_MPI_VENC_ReleaseStream(i, &stStream);
}
fclose(pFile[i]);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
获取USB摄像头的1080p的JPEG格式的图片20180608_1806.7z 电脑上的系统:ubuntu14.04 // http://www.linuxidc.com/Linux/2011-03/33020.htm // V4L2摄像头获取单幅图片测试程序(MMAP模式) // [日期:2011-03-06] 来源:Linux社区 作者:aokikyon [字体:大 中 小] // // #加了点注释 // // #Rockie Cheng // printf #include #include // memset #include #include #include #include // close write usleep read #include #include #include #include #include #include // mmap #include #include #include #include // pthread_create pthread_join #include #define CLEAR(x) memset (&(x), 0, sizeof (x)) #define REQ_COUNT 6 #define uchar unsigned char struct buffer { void * start; size_t length; }; static char * dev_name = "/dev/video0";//摄像头设备名 static int fd = -1; struct buffer * buffers = NULL; // static unsigned int n_buffers = 0; // 2012-7-13 11:33 camera flag // static int iFlagCamera = 0; volatile int iFlagCamera = 0; // 函数名称:thread1 // 函数功能:用于接受键盘的输入,之后通知thread2抓图 // 参数列表: // 返回值 : void thread1(void) { char ch; printf("\n !!!!Warning!!!!\n Max 1000 color bmp\n Input the char: \n"); printf("\n !!!!press o an capture 1 frame picture! \n"); printf("\n !!!!press t an capture 10 frame picture! \n"); printf("\n !!!!press h an capture 100 frame picture! \n"); while(1) { while((ch=getchar()) != '\n') { printf("%c\n", ch); if('o'==ch) { iFlagCamera = 1; printf("thread1=%d\n", iFlagCamera); } else if('t'==ch) { iFlagCamera = 10; printf("thread1=%d\n", iFlagCamera); } else if('h'==ch) { iFlagCamera = 101; printf("thread1=%d\n", iFlagCamera); } else if('q'==ch) { iFlagCamera = 10001; printf("thread1=%d\n", iFlagCamera

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值