1. 摄像头通道设置:Hi3559AV100_SDK_V2.0.1.0/mpp/sample/svp/multi-core/common/sample_comm_ive.c
/******************************************************************************
* function : Start Vi/Vpss/Venc/Vo
******************************************************************************/
HI_S32 SAMPLE_COMM_IVE_StartViVpssVencVo(SAMPLE_VI_CONFIG_S *pstViConfig,
SAMPLE_IVE_SWITCH_S *pstSwitch,PIC_SIZE_E *penExtPicSize)
{
SIZE_S astSize[VPSS_CHN_NUM];
PIC_SIZE_E aenSize[VPSS_CHN_NUM];
VI_CHN_ATTR_S stViChnAttr;
SAMPLE_RC_E enRcMode = SAMPLE_RC_CBR;
PAYLOAD_TYPE_E enStreamType = PT_H264;
VENC_GOP_ATTR_S stGopAttr;
VI_DEV ViDev0 = 2;//modify by llx 2019-12-06 0
VI_PIPE ViPipe0 = 1;//modify by llx 2019-12-06 0
VI_CHN ViChn = 0;
HI_S32 s32ViCnt = 1;
HI_S32 s32WorkSnsId = 0;
VPSS_GRP VpssGrp = 0;
HI_S32 s32Ret = HI_SUCCESS;
VENC_CHN VeH264Chn = 0;
WDR_MODE_E enWDRMode = WDR_MODE_NONE;
DYNAMIC_RANGE_E enDynamicRange = DYNAMIC_RANGE_SDR8;
PIXEL_FORMAT_E enPixFormat = PIXEL_FORMAT_YVU_SEMIPLANAR_420;
VIDEO_FORMAT_E enVideoFormat = VIDEO_FORMAT_LINEAR;
COMPRESS_MODE_E enCompressMode = COMPRESS_MODE_NONE;
VI_VPSS_MODE_E enMastPipeMode = VI_OFFLINE_VPSS_OFFLINE;//modify by llx 2019-12-06 VI_ONLINE_VPSS_OFFLINE;
memset(pstViConfig,0,sizeof(*pstViConfig));
SAMPLE_COMM_VI_GetSensorInfo(pstViConfig);
pstViConfig->s32WorkingViNum = s32ViCnt;
pstViConfig->as32WorkingViId[0] = 0;
pstViConfig->astViInfo[0].stSnsInfo.MipiDev = SAMPLE_COMM_VI_GetComboDevBySensor(pstViConfig->astViInfo[0].stSnsInfo.enSnsType, 1/*modify by llx 2019-12-25 0*/);
pstViConfig->astViInfo[0].stSnsInfo.s32BusId = 0;
pstViConfig->astViInfo[0].stDevInfo.ViDev = ViDev0;
pstViConfig->astViInfo[0].stDevInfo.enWDRMode = enWDRMode;
pstViConfig->astViInfo[0].stPipeInfo.enMastPipeMode = enMastPipeMode;
pstViConfig->astViInfo[0].stPipeInfo.aPipe[0] = ViPipe0;
pstViConfig->astViInfo[0].stPipeInfo.aPipe[1] = -1;
pstViConfig->astViInfo[0].stPipeInfo.aPipe[2] = -1;
pstViConfig->astViInfo[0].stPipeInfo.aPipe[3] = -1;
pstViConfig->astViInfo[0].stChnInfo.ViChn = ViChn;
pstViConfig->astViInfo[0].stChnInfo.enPixFormat = enPixFormat;
pstViConfig->astViInfo[0].stChnInfo.enDynamicRange = enDynamicRange;
pstViConfig->astViInfo[0].stChnInfo.enVideoFormat = enVideoFormat;
pstViConfig->astViInfo[0].stChnInfo.enCompressMode = enCompressMode;
s32Ret = SAMPLE_COMM_VI_GetSizeBySensor(pstViConfig->astViInfo[s32WorkSnsId].stSnsInfo.enSnsType, &aenSize[0]);
s32Ret = SAMPLE_COMM_VI_GetSizeBySensor(pstViConfig->astViInfo[s32WorkSnsId].stSnsInfo.enSnsType, &aenSize[2]);
SAMPLE_CHECK_EXPR_GOTO(HI_SUCCESS != s32Ret, END_INIT_0,
"Error(%#x),SAMPLE_COMM_VI_GetSizeBySensor failed!\n",s32Ret);
aenSize[1] = *penExtPicSize;
/******************************************
step 1: Init vb
******************************************/
s32Ret = SAMPLE_COMM_IVE_VbInit(aenSize,astSize,VPSS_CHN_NUM);
SAMPLE_CHECK_EXPR_GOTO(HI_SUCCESS != s32Ret, END_INIT_0,
"Error(%#x),SAMPLE_COMM_IVE_VbInit failed!\n",s32Ret);
/******************************************
step 2: Start vi
******************************************/
s32Ret = SAMPLE_COMM_VI_SetParam(pstViConfig);
SAMPLE_CHECK_EXPR_GOTO(HI_SUCCESS != s32Ret, END_INIT_1,
"Error(%#x),SAMPLE_COMM_VI_SetParam failed!\n",s32Ret);
s32Ret = SAMPLE_COMM_VI_StartVi(pstViConfig);
SAMPLE_CHECK_EXPR_GOTO(HI_SUCCESS != s32Ret, END_INIT_1,
"Error(%#x),SAMPLE_COMM_VI_StartVi failed!\n",s32Ret);
/******************************************
step 3: Start vpss
******************************************/
s32Ret = SAMPLE_COMM_IVE_StartVpss(astSize,VPSS_CHN_NUM);
s32Ret = SAMPLE_COMM_IVE_StartVpss1(astSize, VPSS_CHN_NUM);
SAMPLE_CHECK_EXPR_GOTO(HI_SUCCESS != s32Ret, END_INIT_2,
"Error(%#x),SAMPLE_IVS_StartVpss failed!\n",s32Ret);
/******************************************
step 4: Bind vpss to vi
******************************************/
s32Ret = SAMPLE_COMM_VI_Bind_VPSS(ViPipe0, ViChn, VpssGrp);
SAMPLE_CHECK_EXPR_GOTO(HI_SUCCESS != s32Ret, END_INIT_3,
"Error(%#x),SAMPLE_COMM_VI_BindVpss failed!\n",s32Ret);
//Set vi frame
s32Ret = HI_MPI_VI_GetChnAttr(ViPipe0, ViChn,&stViChnAttr);
SAMPLE_CHECK_EXPR_GOTO(HI_SUCCESS != s32Ret, END_INIT_4,
"Error(%#x),HI_MPI_VI_GetChnAttr failed!\n",s32Ret);
s32Ret = HI_MPI_VI_SetChnAttr(ViPipe0, ViChn,&stViChnAttr);
SAMPLE_CHECK_EXPR_GOTO(HI_SUCCESS != s32Ret, END_INIT_4,
"Error(%#x),HI_MPI_VI_SetChnAttr failed!\n",s32Ret);
/******************************************
step 5: Start Vo
******************************************/
if (HI_TRUE == pstSwitch->bVo)
{
s32Ret = SAMPLE_COMM_IVE_StartVo();
SAMPLE_CHECK_EXPR_GOTO(HI_SUCCESS != s32Ret, END_INIT_4,
"Error(%#x),SAMPLE_COMM_IVE_StartVo failed!\n", s32Ret);
}
/******************************************
step 6: Start Venc
******************************************/
if (HI_TRUE == pstSwitch->bVenc)
{
s32Ret = SAMPLE_COMM_VENC_GetGopAttr(VENC_GOPMODE_NORMALP,&stGopAttr);
SAMPLE_CHECK_EXPR_GOTO(HI_SUCCESS != s32Ret, END_INIT_5,
"Error(%#x),SAMPLE_COMM_VENC_GetGopAttr failed!\n",s32Ret);
s32Ret = SAMPLE_COMM_VENC_Start(VeH264Chn, enStreamType,aenSize[0],enRcMode,0,&stGopAttr);
SAMPLE_CHECK_EXPR_GOTO(HI_SUCCESS != s32Ret, END_INIT_5,
"Error(%#x),SAMPLE_COMM_VENC_Start failed!\n",s32Ret);
s32Ret = SAMPLE_COMM_VENC_StartGetStream(&VeH264Chn, 1);
SAMPLE_CHECK_EXPR_GOTO(HI_SUCCESS != s32Ret, END_INIT_6,
"Error(%#x),SAMPLE_COMM_VENC_StartGetStream failed!\n",s32Ret);
}
return HI_SUCCESS;
END_INIT_6:
if (HI_TRUE == pstSwitch->bVenc)
{
SAMPLE_COMM_VENC_Stop(VeH264Chn);
}
END_INIT_5:
if (HI_TRUE == pstSwitch->bVo)
{
SAMPLE_COMM_IVE_StopVo();
}
END_INIT_4:
SAMPLE_COMM_VI_UnBind_VPSS(ViPipe0, ViChn, VpssGrp);
END_INIT_3:
SAMPLE_COMM_IVE_StopVpss(VPSS_CHN_NUM);
END_INIT_2:
SAMPLE_COMM_VI_StopVi(pstViConfig);
END_INIT_1: //system exit
SAMPLE_COMM_SYS_Exit();
memset(pstViConfig,0,sizeof(*pstViConfig));
END_INIT_0:
return s32Ret;
}
2. 图像格式设置:Hi3559AV100_SDK_V2.0.1.0/mpp/sample/common/sample_comm.h !112
#define SAMPLE_PIXEL_FORMAT PIXEL_FORMAT_YVU_SEMIPLANAR_422 //modify by llx 2019-12-06 PIXEL_FORMAT_YVU_SEMIPLANAR_420