HI_VOID *SAMPLE_MISC_VpssDump(VPSS_GRP Grp,VPSS_CHN Chn,HI_U32 u32FrameCnt,HI_U32 u32Width,HI_U32 u32Height,HI_U32 u32PixelFormat) { VIDEO_FRAME_INFO_S stFrame; HI_CHAR szYuvName[128]; HI_CHAR szPixFrm[10]; FILE *pfd; VPSS_GRP VpssGrp = Grp; VPSS_CHN VpssChn = Chn; HI_U32 u32Cnt = u32FrameCnt; HI_U32 u32Depth = 1; VPSS_CHN_MODE_S stOrigVpssMode, stVpssMode; if (HI_MPI_VPSS_GetChnMode(VpssGrp,VpssChn,&stOrigVpssMode) != HI_SUCCESS) { printf("get mode error!!!\n"); return (HI_VOID *)-1; } stVpssMode.enChnMode = VPSS_CHN_MODE_USER; if (u32PixelFormat == 0) { stVpssMode.enPixelFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420; } else { stVpssMode.enPixelFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_422; } stVpssMode.u32Width = u32Width; stVpssMode.u32Height = u32Height; if (HI_MPI_VPSS_SetChnMode(VpssGrp,VpssChn,&stVpssMode) != HI_SUCCESS) { printf("set mode error!!!\n"); return (HI_VOID *)-1; } if (HI_MPI_VPSS_SetDepth(VpssGrp,VpssChn,u32Depth)!=HI_SUCCESS) { printf("set depth error!!!\n"); return (HI_VOID *)-1; } memset(&stFrame,0,sizeof(stFrame)); while ((HI_MPI_VPSS_UserGetFrame(VpssGrp, VpssChn, &stFrame)!=HI_SUCCESS)) { printf("get frame error!!!\n"); sleep(1); } /* make file name */ strcpy(szPixFrm, (PIXEL_FORMAT_YUV_SEMIPLANAR_420 == stFrame.stVFrame.enPixelFormat)?"p420":"p422"); sprintf(szYuvName, "./vpss_grp%d_chn%d_w%d_h%d_%s_%d.yuv", VpssGrp, VpssChn, stFrame.stVFrame.u32Width, stFrame.stVFrame.u32Height,szPixFrm,u32Cnt); printf("Dump YUV frame of vi chn %d to file: \"%s\"\n", VpssChn, szYuvName); fflush(stdout); HI_MPI_VPSS_UserReleaseFrame(VpssGrp, VpssChn, &stFrame); /* open file */ pfd = fopen(szYuvName, "wb"); if (NULL == pfd) { return (HI_VOID *)-1; } /* get frame */ while (u32Cnt--) { if (HI_MPI_VPSS_UserGetFrame(VpssGrp, VpssChn, &stFrame) != HI_SUCCESS) { printf("Get frame fail \n"); usleep(1000); continue; } sample_yuv_dump(&stFrame.stVFrame, pfd); printf("Get VpssGrp %d frame %d!!\n", VpssGrp,u32Cnt); /* release frame after using */ HI_MPI_VPSS_UserReleaseFrame(VpssGrp, VpssChn, &stFrame); } fclose(pfd); HI_MPI_VPSS_SetChnMode(VpssGrp,VpssChn,&stOrigVpssMode); return (HI_VOID *)0; }
HI_S32 SAMPLE_MISC_VoDump(VO_DEV VoDev, HI_U32 u32Cnt) { HI_S32 i, s32Ret; VIDEO_FRAME_INFO_S stFrame; //VIDEO_FRAME_INFO_S astFrame[256]; HI_CHAR szYuvName[128]; HI_CHAR szPixFrm[10]; FILE *pfd; printf("\nNOTICE: This tool only can be used for TESTING !!!\n"); printf("usage: ./vo_screen_dump [vodev] [frmcnt]. sample: ./vo_screen_dump 0 1\n\n"); /* Get Frame to make file name*/ s32Ret = HI_MPI_VO_GetScreenFrame(VoDev, &stFrame); if (HI_SUCCESS != s32Ret) { printf("HI_MPI_VO(%d)_GetScreenFrame errno %#x\n", VoDev, s32Ret); return -1; } /* make file name */ strcpy(szPixFrm, (PIXEL_FORMAT_YUV_SEMIPLANAR_420 == stFrame.stVFrame.enPixelFormat)?"p420":"p422"); sprintf(szYuvName, "./vo(%d)_%d_%d_%s_%d.yuv",VoDev, stFrame.stVFrame.u32Width, stFrame.stVFrame.u32Height,szPixFrm,u32Cnt); printf("Dump YUV frame of vo(%d) to file: \"%s\"\n",VoDev, szYuvName); HI_MPI_VO_ReleaseScreenFrame(VoDev, &stFrame); /* open file */ pfd = fopen(szYuvName, "wb"); if (NULL == pfd) { return -1; } memopen(); /* get VO frame */ for (i=0; i<u32Cnt; i++) { s32Ret = HI_MPI_VO_GetScreenFrame(VoDev, &stFrame); if (HI_SUCCESS != s32Ret) { printf("get vo(%d) frame err\n", VoDev); printf("only get %d frame\n", i); break; } printf("addr 0x%x\n", stFrame.stVFrame.u32PhyAddr[0]); /* save VO frame to file */ sample_yuv_dump(&stFrame.stVFrame, pfd); /* release frame after using */ s32Ret = HI_MPI_VO_ReleaseScreenFrame(VoDev, &stFrame); if (HI_SUCCESS != s32Ret) { printf("Release vo(%d) frame err\n", VoDev); printf("only get %d frame\n", i); break; } } memclose(); fclose(pfd); return 0; }