/****************************************************************************** Some simple Hisilicon Hi3531 system functions. Copyright (C), 2010-2011, Hisilicon Tech. Co., Ltd. ****************************************************************************** Modification: 2011-2 Created ******************************************************************************/ #ifdef __cplusplus #if __cplusplus extern "C"{ #endif #endif /* End of #ifdef __cplusplus */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "sample_comm.h" /****************************************************************************** * function : get picture size(w*h), according Norm and enPicSize ******************************************************************************/ HI_S32 SAMPLE_COMM_SYS_GetPicSize(VIDEO_NORM_E enNorm, PIC_SIZE_E enPicSize, SIZE_S *pstSize) { switch (enPicSize) { case PIC_QCIF: pstSize->u32Width = D1_WIDTH / 4; pstSize->u32Height = (VIDEO_ENCODING_MODE_PAL==enNorm)?144:120; break; case PIC_CIF: pstSize->u32Width = D1_WIDTH / 2; pstSize->u32Height = (VIDEO_ENCODING_MODE_PAL==enNorm)?288:240; break; case PIC_D1: pstSize->u32Width = D1_WIDTH; pstSize->u32Height = (VIDEO_ENCODING_MODE_PAL==enNorm)?576:480; break; case PIC_960H: pstSize->u32Width = 960; pstSize->u32Height = (VIDEO_ENCODING_MODE_PAL==enNorm)?576:480; break; case PIC_2CIF: pstSize->u32Width = D1_WIDTH / 2; pstSize->u32Height = (VIDEO_ENCODING_MODE_PAL==enNorm)?576:480; break; case PIC_QVGA: /* 320 * 240 */ pstSize->u32Width = 320; pstSize->u32Height = 240; break; case PIC_VGA: /* 640 * 480 */ pstSize->u32Width = 640; pstSize->u32Height = 480; break; case PIC_XGA: /* 1024 * 768 */ pstSize->u32Width = 1024; pstSize->u32Height = 768; break; case PIC_SXGA: /* 1400 * 1050 */ pstSize->u32Width = 1400; pstSize->u32Height = 1050; break; case PIC_UXGA: /* 1600 * 1200 */ pstSize->u32Width = 1600; pstSize->u32Height = 1200; break; case PIC_QXGA: /* 2048 * 1536 */ pstSize->u32Width = 2048; pstSize->u32Height = 1536; break; case PIC_WVGA: /* 854 * 480 */ pstSize->u32Width = 854; pstSize->u32Height = 480; break; case PIC_WSXGA: /* 1680 * 1050 */ pstSize->u32Width = 1680; pstSize->u32Height = 1050; break; case PIC_WUXGA: /* 1920 * 1200 */ pstSize->u32Width = 1920; pstSize->u32Height = 1200; break; case PIC_WQXGA: /* 2560 * 1600 */ pstSize->u32Width = 2560; pstSize->u32Height = 1600; break; case PIC_HD720: /* 1280 * 720 */ pstSize->u32Width = 1280; pstSize->u32Height = 720; break; case PIC_HD1080: /* 1920 * 1080 */ pstSize->u32Width = 1920; pstSize->u32Height = 1080; break; default: return HI_FAILURE; } return HI_SUCCESS; } /****************************************************************************** * function : calculate VB Block size of Histogram. ******************************************************************************/ HI_U32 SAMPLE_COMM_SYS_CalcHistVbBlkSize(VIDEO_NORM_E enNorm, PIC_SIZE_E enPicSize, SIZE_S *pstHistBlkSize, HI_U32 u32AlignWidth) { HI_S32 s32Ret; SIZE_S stPicSize; s32Ret = SAMPLE_COMM_SYS_GetPicSize(enNorm, enPicSize, &stPicSize); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("get picture size[%d] failed!\n", enPicSize); return HI_FAILURE; } SAMPLE_PRT("stPicSize.u32Width%d,pstHistBlkSize->u32Width%d\n,stPicSize.u32Height%d,pstHistBlkSize->u32Height%d\n", stPicSize.u32Width,pstHistBlkSize->u32Width, stPicSize.u32Height,pstHistBlkSize->u32Height ); return (CEILING_2_POWER(44, u32AlignWidth)*CEILING_2_POWER(44, u32AlignWidth)*16*4); return HI_SUCCESS; } /****************************************************************************** * function : calculate VB Block size of picture. ******************************************************************************/ HI_U32 SAMPLE_COMM_SYS_CalcPicVbBlkSize(VIDEO_NORM_E enNorm, PIC_SIZE_E enPicSize, PIXEL_FORMAT_E enPixFmt, HI_U32 u32AlignWidth,COMPRESS_MODE_E enCompFmt) { HI_S32 s32Ret = HI_FAILURE; SIZE_S stSize; HI_U32 u32Width = 0; HI_U32 u32Height = 0; HI_U32 u32BlkSize = 0; HI_U32 u32HeaderSize = 0; s32Ret = SAMPLE_COMM_SYS_GetPicSize(enNorm, enPicSize, &stSize); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("get picture size[%d] failed!\n", enPicSize); return HI_FAILURE; } if (PIXEL_FORMAT_YUV_SEMIPLANAR_422 != enPixFmt && PIXEL_FORMAT_YUV_SEMIPLANAR_420 != enPixFmt) { SAMPLE_PRT("pixel format[%d] input failed!\n", enPixFmt); return HI_FAILURE; } if (16!=u32AlignWidth && 32!=u32AlignWidth && 64!=u32AlignWidth) { SAMPLE_PRT("system align width[%d] input failed!\n",\ u32AlignWidth); return HI_FAILURE; } if (704 == stSize.u32Width) { stSize.u32Width = 720; } //SAMPLE_PRT("w:%d, u32AlignWidth:%d\n", CEILING_2_POWER(stSize.u32Width,u32AlignWidth), u32AlignWidth); u32Width = CEILING_2_POWER(stSize.u32Width, u32AlignWidth); u32Height = CEILING_2_POWER(stSize.u32Height,u32AlignWidth); if (PIXEL_FORMAT_YUV_SEMIPLANAR_422 == enPixFmt) { u32BlkSize = u32Width * u32Height * 2; } else { u32BlkSize = u32Width * u32Height * 3 / 2; } if(COMPRESS_MODE_SEG == enCompFmt) { VB_PIC_HEADER_SIZE(u32Width,u32Height,enPixFmt,u32HeaderSize); } u32BlkSize += u32HeaderSize; return u32BlkSize; } /****************************************************************************** * function : Set system memory location ******************************************************************************/ HI_S32 SAMPLE_COMM_SYS_MemConfig(HI_VOID) { HI_S32 i = 0; HI_S32 s32Ret = HI_SUCCESS; HI_CHAR * pcMmzName = NULL; MPP_CHN_S stMppChnVO; MPP_CHN_S stMppChnVPSS; MPP_CHN_S stMppChnVENC; MPP_CHN_S stMppChnVDEC; /* vdec chn config to mmz 'null' */ for(i=0; i