HI_S32 PCIV_Slave_StartVo(PCIV_MSGHEAD_S *pMsg) { HI_S32 s32Ret, s32CurPos; VO_CHN voChn = -1; PCIV_VOCMD_CREATE_S *pCmd = (PCIV_VOCMD_CREATE_S *)pMsg->cMsgBody; PCIV_VOCMD_ECHO_S *pCmdEcho = (PCIV_VOCMD_ECHO_S *)pMsg->cMsgBody; s32CurPos = 0; while(s32CurPos < pMsg->u32MsgLen) { voChn = pCmd->voChn; s32Ret = HI_MPI_VO_SetChnAttr(voChn, &pCmd->stAttr); HI_ASSERT(HI_SUCCESS == s32Ret); s32Ret = HI_MPI_VO_EnableChn(voChn); HI_ASSERT(HI_SUCCESS == s32Ret); pCmd++; s32CurPos += sizeof(*pCmd); } pMsg->enMsgType = PCIV_MSGTYPE_CMDECHO; pMsg->enDevType = PCIV_DEVTYPE_VOCHN; pMsg->u32Target = 0; pMsg->u32MsgLen = sizeof(PCIV_VOCMD_ECHO_S); pCmdEcho->s32Echo = HI_SUCCESS; pCmdEcho->voChn = voChn; s32Ret = PCIV_SendMsg(0, PCIV_MSGPORT_USERCMD, pMsg); HI_ASSERT(HI_FAILURE != s32Ret); return HI_SUCCESS; }
HI_S32 SampleSetVochnMscreen(HI_U32 u32Cnt) { HI_U32 i,div,offset; VO_CHN_ATTR_S VoChnAttr[u32Cnt]; div = sqrt(u32Cnt); if (9 == u32Cnt) { offset = 16; } else { offset = 0; } for (i = 0; i < u32Cnt; i++) { VoChnAttr[i].bZoomEnable = HI_TRUE; VoChnAttr[i].u32Priority = 1; VoChnAttr[i].stRect.s32X = ((g_u32ScreenWidth + offset)*(i%div))/div ; VoChnAttr[i].stRect.u32Width = (g_u32ScreenWidth + offset)/div; VoChnAttr[i].stRect.s32Y = (g_u32ScreenHeight*(i/div))/div ; VoChnAttr[i].stRect.u32Height = g_u32ScreenHeight/div; CHECK(HI_MPI_VO_SetChnAttr(i, &VoChnAttr[i]),"HI_MPI_VO_SetChnAttr"); } return HI_SUCCESS; }
HI_S32 SampleSetVochnMscreen(HI_U32 u32Cnt) { HI_U32 i,div; VO_CHN_ATTR_S VoChnAttr[9]; div = sqrt(u32Cnt); for (i=0; i<u32Cnt; i++) { VoChnAttr[i].bZoomEnable = HI_TRUE; VoChnAttr[i].u32Priority = 1; if(u32Cnt!=9) { VoChnAttr[i].stRect.s32X = (704*(i%div))/div ; VoChnAttr[i].stRect.u32Width = 704/div; } else { VoChnAttr[i].stRect.s32X = (720*(i%div))/div ; VoChnAttr[i].stRect.u32Width = 720/div; } VoChnAttr[i].stRect.s32Y = (576*(i/div))/div ; VoChnAttr[i].stRect.u32Height = 576/div; VoChnAttr[i].u32Priority = 1; if(HI_SUCCESS!=HI_MPI_VO_SetChnAttr(i, &VoChnAttr[i])) { printf("HI_MPI_VO_SetChnAttr faild!\n"); return HI_FAILURE; } } return HI_SUCCESS; }
HI_S32 SampleEnableVo(VO_CHN VoChn, VO_PUB_ATTR_S *pVoPubAttr, VO_CHN_ATTR_S *pVoChnAttr) { HI_S32 s32Ret; s32Ret = HI_MPI_VO_SetPubAttr(pVoPubAttr); if (HI_SUCCESS != s32Ret) { printf("set VO attribute failed 0x%x!\n",s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VO_SetChnAttr(VoChn, pVoChnAttr); if (HI_SUCCESS != s32Ret) { printf("set VO Chn attribute failed !\n"); return HI_FAILURE; } s32Ret = HI_MPI_VO_Enable(); if (HI_SUCCESS != s32Ret) { printf("set VO enable failed 0x%x!\n",s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VO_EnableChn(VoChn); if (HI_SUCCESS != s32Ret) { printf("set VO Chn enable failed 0x%x!\n",s32Ret); return HI_FAILURE; } return HI_SUCCESS; }
HI_S32 SampleVoInitChn(VO_CHN VoChn, VO_CHN_ATTR_S *pstVoChnAttr) { if (HI_SUCCESS!=HI_MPI_VO_SetChnAttr(VoChn, pstVoChnAttr)) { Printf("set VO 0 Chn attribute failed !\n"); return HI_FAILURE; } if(HI_SUCCESS!=HI_MPI_VO_EnableChn(VoChn)) { Printf("enable vo channel failed !\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; }
static void video_Division(int nVoDev, int nScrWidth, int nScrHeight, int nDiv, int nPage, unsigned char bD1) { int i = 0; int nGrid = 1; VO_CHN_ATTR_S stVoChnAttr; int nLocate = 0; int nChWidth = 0; int nChHeight = 0; int nOffsetX = (VO_ORIGIN_WIDTH - nScrWidth) / 2; int nOffsetY = (VO_ORIGIN_HEIGHT - nScrHeight) / 2; int nBlankW = 0; int nBlankH = 0; if(-1 == nDiv){ nDiv = VIDEO_GetMaxDiv(); } switch(nDiv) { case 1: nGrid = 1; break; case 4: nGrid = 2; break; case 9: nGrid = 3; break; case 16: nGrid = 4; break; case 25: nGrid = 5; break; default: return; } if(nVoDev == VO_CVBS_DEVICE) { nOffsetX = s_stVideo.ScrnEdges[1].nEdgeX; nOffsetY = s_stVideo.ScrnEdges[1].nEdgeY; nScrWidth = s_stVideo.ScrnEdges[1].nEdgeW; nScrHeight = s_stVideo.ScrnEdges[1].nEdgeH; } nChWidth = nScrWidth / nGrid; nChHeight = nScrHeight / nGrid; nChWidth &= ~(2-1); // 2 alignment nChHeight &= ~(2-1); // 2 alignment nBlankW = nScrWidth % nChWidth; nBlankH = nScrHeight % nChHeight; for(i = 0, nLocate = 0; i < VIDEO_GetMaxDiv(); ++i){ stVoChnAttr.stRect.s32X = nOffsetX + (((nLocate % nDiv) % nGrid) * nChWidth) & ~(2-1); // 2 alignment stVoChnAttr.stRect.s32Y = nOffsetY + (((nLocate % nDiv) / nGrid) * nChHeight) & ~(2-1); // 2 alignment //VIDEO_TRACE("vo(%d,%d) (x,y)=%d,%d, [w,h]=%d,%d", nVoDev, i, stVoChnAttr.stRect.s32X, stVoChnAttr.stRect.s32Y, stVoChnAttr.stRect.u32Width, stVoChnAttr.stRect.u32Height); if((nGrid - 1) == (nLocate % nGrid)){ // the right side stVoChnAttr.stRect.u32Width = nChWidth + nBlankW; }else{ // for osd bar stVoChnAttr.stRect.u32Width = nChWidth - 2; } if((nGrid - 1) == (nLocate / nGrid)){ stVoChnAttr.stRect.u32Height = nChHeight + nBlankH; }else{ // for osd bar stVoChnAttr.stRect.u32Height = nChHeight - 2; } stVoChnAttr.u32Priority = 1; stVoChnAttr.bZoomEnable = HI_TRUE; stVoChnAttr.bDeflicker = (0 == nVoDev) ? HI_FALSE : HI_TRUE; DVR_ASSERT(HI_MPI_VO_SetChnAttr(nVoDev, i, &stVoChnAttr)); if(VO_CHN_IS_ONTOP(nDiv, nPage, i)){ ++nLocate; DVR_ASSERT(HI_MPI_VO_ChnShow(nVoDev, i)); }else{ DVR_ASSERT(HI_MPI_VO_ChnHide(nVoDev, i)); } } }
static void video_Division(int nVoDev, int nScrWidth, int nScrHeight, int nDiv, int nPage, unsigned char bLive) { int i = 0; int nGrid = 1; VO_CHN_ATTR_S stVoChnAttr; int nLocate = 0; int nChWidth = 0; int nChHeight = 0; int nOffsetX = (VO_ORIGIN_WIDTH - nScrWidth) / 2; int nOffsetY = (VO_ORIGIN_HEIGHT - nScrHeight) / 2; int nBlankW = 0; int nBlankH = 0; int nBeginCh = nDiv * nPage; int nEndCh = MAX_CAM_CH >= (nBeginCh + nDiv) ? MAX_CAM_CH : (nBeginCh + nDiv); // if(!bD1 && 1 == nDiv){ // // full screen is ready all the time at this solution // return; // } switch(nDiv) { case 1: nGrid = 1; break; case 4: nGrid = 2; break; case 9: nGrid = 3; break; case 16: nGrid = 4; break; case 25: nGrid = 5; break; default: return; } if(nVoDev == VO_CVBS_DEVICE) { nOffsetX = s_stVideo.ScrnEdges[1].nEdgeX; nOffsetY = s_stVideo.ScrnEdges[1].nEdgeY; nScrWidth = s_stVideo.ScrnEdges[1].nEdgeW; nScrHeight = s_stVideo.ScrnEdges[1].nEdgeH; } // full d1 for live only stVoChnAttr.stRect.s32X = nOffsetX; stVoChnAttr.stRect.s32Y = nOffsetY; stVoChnAttr.stRect.u32Width = nScrWidth; stVoChnAttr.stRect.u32Height = nScrHeight; stVoChnAttr.u32Priority = 1; stVoChnAttr.bZoomEnable = HI_TRUE; stVoChnAttr.bDeflicker = HI_FALSE; DVR_ASSERT(HI_MPI_VO_SetChnAttr(nVoDev, MAX_CAM_CH, &stVoChnAttr)); if(1 == nDiv && bLive){ DVR_ASSERT(HI_MPI_VO_ChnShow(nVoDev, MAX_CAM_CH)); }else{ DVR_ASSERT(HI_MPI_VO_ChnHide(nVoDev, MAX_CAM_CH)); } nChWidth = nScrWidth / nGrid; nChHeight = nScrHeight / nGrid; nChWidth &= ~(2-1); // 2 alignment nChHeight &= ~(2-1); // 2 alignment nBlankW = nScrWidth % nChWidth; nBlankH = nScrHeight % nChHeight; for(i = 0, nLocate = 0; i < nEndCh; ++i){ int const nChn = i % MAX_CAM_CH; unsigned char bShow = FALSE; if(i >= nBeginCh && i < (nBeginCh + nDiv) && (nDiv > 1 || !bLive)){ // need to show bShow = TRUE; // live not full division mode // playback all the mode stVoChnAttr.stRect.s32X = (nOffsetX + (((nLocate % nDiv) % nGrid) * nChWidth)) & ~(2-1); // 2 alignment stVoChnAttr.stRect.s32Y = (nOffsetY + (((nLocate % nDiv) / nGrid) * nChHeight)) & ~(2-1); // 2 alignment if((nGrid - 1) == (nLocate % nGrid)){ // the right side stVoChnAttr.stRect.u32Width = nChWidth + nBlankW; }else{ // for osd bar stVoChnAttr.stRect.u32Width = nChWidth - 2; } if((nGrid - 1) == (nLocate / nGrid)){ // the bottom stVoChnAttr.stRect.u32Height = nChHeight + nBlankH; }else{ // for osd bar stVoChnAttr.stRect.u32Height = nChHeight - 2; } stVoChnAttr.u32Priority = 0; stVoChnAttr.bZoomEnable = HI_TRUE; stVoChnAttr.bDeflicker = (0 == nVoDev) ? HI_FALSE : HI_TRUE; ++nLocate; }else{ bShow = FALSE; stVoChnAttr.stRect.s32X = 0; stVoChnAttr.stRect.s32Y = 0; stVoChnAttr.stRect.u32Width = VI_CIF_WIDTH; stVoChnAttr.stRect.u32Height = VI_CIF_HEIGHT; stVoChnAttr.u32Priority = 0; stVoChnAttr.bZoomEnable = HI_FALSE; stVoChnAttr.bDeflicker = HI_FALSE; } // VIDEO_TRACE("vo(%d,%d) (x,y)=%d,%d, [w,h]=%d,%d", nVoDev, i, stVoChnAttr.stRect.s32X, stVoChnAttr.stRect.s32Y, stVoChnAttr.stRect.u32Width, stVoChnAttr.stRect.u32Height); DVR_ASSERT(HI_MPI_VO_SetChnAttr(nVoDev, nChn, &stVoChnAttr)); if(bShow){ DVR_ASSERT(HI_MPI_VO_ChnShow(nVoDev, nChn)); }else{ DVR_ASSERT(HI_MPI_VO_ChnHide(nVoDev, nChn)); } } }
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; }