HI_S32 hi_vpss_CheckInfo(VO_CHN_ATTR_S *stChnAttr, VPSS_CROP_INFO_S *stCropInfo, SIZE_S *stSize) { HI_S32 s32X, s32Y, s32W, s32H; HI_S32 s32CropX, s32CropY, s32CropW, s32CropH; s32X = stChnAttr->stRect.s32X; s32Y = stChnAttr->stRect.s32Y; s32W = stChnAttr->stRect.u32Width; s32H = stChnAttr->stRect.u32Height; s32CropX = stCropInfo->stCropRect.s32X; s32CropY = stCropInfo->stCropRect.s32Y; s32CropW = stCropInfo->stCropRect.u32Width; s32CropH = stCropInfo->stCropRect.u32Height; /*vo 屏幕坐标 转 换图像实际坐标*/ s32X = (s32CropX - s32X); s32Y = (s32CropY - s32Y); /*vo 图像坐标转化成vpss 图像坐标*/ s32CropX = (s32X * stSize->u32Width)/s32W; s32CropY = (s32Y * stSize->u32Height)/s32H; s32CropW = (s32CropW * stSize->u32Width)/s32W; s32CropH = (s32CropH * stSize->u32Height)/s32H; /*对齐*/ stCropInfo->stCropRect.s32X = ALIGN_BACK(s32CropX, 4); stCropInfo->stCropRect.s32Y = ALIGN_BACK(s32CropY, 4); stCropInfo->stCropRect.u32Width = ALIGN_BACK(s32CropW, 8); stCropInfo->stCropRect.u32Height = ALIGN_BACK(s32CropH, 8); if(stCropInfo->stCropRect.u32Width < 64 || stCropInfo->stCropRect.u32Height < 64) { Printf("Crop Width*Height < 64*64 \n"); return HI_FAILURE; } return HI_SUCCESS; }
HI_S32 SAMPLE_COMM_VO_StartChn(VO_DEV VoDev,VO_PUB_ATTR_S *pstPubAttr,SAMPLE_VO_MODE_E enMode) { HI_S32 i; HI_S32 s32Ret = HI_SUCCESS; HI_U32 u32WndNum = 0; HI_U32 u32Square = 0; HI_U32 u32Width = 0; HI_U32 u32Height = 0; HI_U32 u32Frm = 0; VO_CHN_ATTR_S stChnAttr; switch (enMode) { case VO_MODE_1MUX: u32WndNum = 1; u32Square = 1; break; case VO_MODE_4MUX: u32WndNum = 4; u32Square = 2; break; case VO_MODE_9MUX: u32WndNum = 9; u32Square = 3; break; case VO_MODE_16MUX: u32WndNum = 16; u32Square = 4; break; default: SAMPLE_PRT("failed with %#x!\n", s32Ret); return HI_FAILURE; } ///根据输出属性获取当前输出的分辨率的参数 s32Ret = SAMPLE_COMM_VO_GetWH(pstPubAttr->enIntfSync, &u32Width,&u32Height,&u32Frm); if (s32Ret != HI_SUCCESS) { SAMPLE_PRT("failed with %#x!\n", s32Ret); return HI_FAILURE; } printf("u32Width:%d, u32Square:%d\n", u32Width, u32Square); for (i=0; i<u32WndNum; i++) { ///设置输出的区域大小及坐标 stChnAttr.stRect.s32X = ALIGN_BACK((u32Width/u32Square) * (i%u32Square), 2); stChnAttr.stRect.s32Y = ALIGN_BACK((u32Height/u32Square) * (i/u32Square), 2); stChnAttr.stRect.u32Width = ALIGN_BACK(u32Width/u32Square, 2); stChnAttr.stRect.u32Height = ALIGN_BACK(u32Height/u32Square, 2); ///优先级 stChnAttr.u32Priority = 0; ///是否开启抗闪烁 stChnAttr.bDeflicker = HI_FALSE; s32Ret = HI_MPI_VO_SetChnAttr(VoDev, i, &stChnAttr); if (s32Ret != HI_SUCCESS) { printf("%s(%d):failed with %#x!\n",\ __FUNCTION__,__LINE__, s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VO_EnableChn(VoDev, i ); if (s32Ret != HI_SUCCESS) { SAMPLE_PRT("failed with %#x!\n", s32Ret); return HI_FAILURE; } } return HI_SUCCESS; }
HI_S32 SAMPLE_COMM_VO_StartChn(VO_LAYER VoLayer, SAMPLE_VO_MODE_E enMode) { HI_S32 i; HI_S32 s32Ret = HI_SUCCESS; HI_U32 u32WndNum = 0; HI_U32 u32Square = 0; HI_U32 u32Width = 0; HI_U32 u32Height = 0; VO_CHN_ATTR_S stChnAttr; VO_VIDEO_LAYER_ATTR_S stLayerAttr; switch (enMode) { case VO_MODE_1MUX: u32WndNum = 1; u32Square = 1; break; case VO_MODE_2MUX: u32WndNum = 2; u32Square = 2; break; default: SAMPLE_PRT("failed with %#x!\n", s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VO_GetVideoLayerAttr(VoLayer, &stLayerAttr); if (s32Ret != HI_SUCCESS) { SAMPLE_PRT("failed with %#x!\n", s32Ret); return HI_FAILURE; } u32Width = stLayerAttr.stImageSize.u32Width; u32Height = stLayerAttr.stImageSize.u32Height; printf("u32Width:%d, u32Square:%d\n", u32Width, u32Square); for (i=0; i<u32WndNum; i++) { stChnAttr.stRect.s32X = ALIGN_BACK((u32Width/u32Square) * (i%u32Square), 2); stChnAttr.stRect.s32Y = ALIGN_BACK((u32Height/u32Square) * (i/u32Square), 2); stChnAttr.stRect.u32Width = ALIGN_BACK(u32Width/u32Square, 2); stChnAttr.stRect.u32Height = ALIGN_BACK(u32Height/u32Square, 2); stChnAttr.u32Priority = 0; stChnAttr.bDeflicker = HI_FALSE; s32Ret = HI_MPI_VO_SetChnAttr(VoLayer, i, &stChnAttr); if (s32Ret != HI_SUCCESS) { printf("%s(%d):failed with %#x!\n",\ __FUNCTION__,__LINE__, s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VO_EnableChn(VoLayer, i); if (s32Ret != HI_SUCCESS) { SAMPLE_PRT("failed with %#x!\n", s32Ret); return HI_FAILURE; } } return HI_SUCCESS; }