海思3531A SDK编码部分之sample

海思3531A SDK编码部分之sample,第1张

海思3531A SDK编码部分之sample Hi3531A

本文主要是看 注释

1.main函数

sample_venc.c文件最后部分是main函数开始的部分,本文注释case=‘0’时的SAMPLE_VENC_720p_CLASSIC()函数。

int main(int argc, char *argv[])
{
    HI_S32 s32Ret;
    if ( (argc < 2) || (1 != strlen(argv[1])))
    {
        SAMPLE_VENC_Usage(argv[0]);
        return HI_FAILURE;
    }

    signal(SIGINT, SAMPLE_VENC_HandleSig);
    signal(SIGTERM, SAMPLE_VENC_HandleSig);
    
    switch (*argv[1])
    {
        case '0':
            s32Ret = SAMPLE_VENC_720p_CLASSIC();
            break;
        case '1':
            s32Ret = SAMPLE_VENC_SVC_T_H264();
            break;
        case '2':
            s32Ret = SAMPLE_VENC_PSKIP_H264();
            break;
        case '3':
            s32Ret = SAMPLE_VENC_ROIBG_CLASSIC();
            break;
        default:
            printf("the index is invaild!n");
            SAMPLE_VENC_Usage(argv[0]);
            return HI_FAILURE;
    }
    
    if (HI_SUCCESS == s32Ret)
        printf("program exit normally!n");
    else
        printf("program exit abnormally!n");
    exit(s32Ret);
}
2.SAMPLE_VENC_Usage()打印信息


#ifdef __cplusplus 
#if __cplusplus    
extern "C"{
#endif
#endif 

#include 
#include 
#include 
#include 
#include 
#include 

#include "sample_comm.h"

VIDEO_NORM_E gs_enNorm = VIDEO_ENCODING_MODE_PAL;          //PAL(德国制@25帧),中国主要也是使用这种。
#define SAMPLE_YUV_D1_FILEPATH         "SAMPLE_420_D1.yuv"
#define VPSS_BSTR_CHN     		0
#define VPSS_LSTR_CHN     		1


void SAMPLE_VENC_Usage(char *sPrgNm)              //接收的字符串为argv[0]
{
    printf("Usage : %s n", sPrgNm);       //string program number
    printf("index:n");
    printf("t 0) 8*720p H264/JPEG encode.n");
    printf("t 1) 8*720p H264 svc-t encode.n");
    printf("t 2) 8*720p pskip encode.n");
    printf("t 3) 8*roi background framerate.n");

    return;
}


void SAMPLE_VENC_HandleSig(HI_S32 signo)
{
    if (SIGINT == signo || SIGTSTP == signo)
    {
        SAMPLE_COMM_SYS_Exit();
        printf("33[0;31mprogram termination abnormally!33[0;39mn");
    }
    exit(-1);
}


void SAMPLE_VENC_StreamHandleSig(HI_S32 signo)
{

    if (SIGINT == signo || SIGTSTP == signo)
    {
        SAMPLE_COMM_SYS_Exit();
        printf("33[0;31mprogram exit abnormally!33[0;39mn");
    }

    exit(0);
}
3.SAMPLE_VENC_720p_CLASSIC

HI_S32 SAMPLE_VENC_720p_CLASSIC(HI_VOID)                      
{
    SAMPLE_VI_MODE_E enViMode = SAMPLE_VI_MODE_8_720P;

    HI_S32 s32VpssGrpCnt = 8;
    PAYLOAD_TYPE_E enPayLoad[3]= {PT_H264, PT_JPEG,PT_H264};  
    PIC_SIZE_E enSize[3] = {PIC_HD720, PIC_HD720,PIC_CIF};    
    HI_U32 u32Profile = 1;                                    
    
	VB_CONF_S stVbConf;       
    VPSS_GRP VpssGrp;          
    VPSS_CHN VpssChn;         
    VENC_CHN VencChn;         
    SAMPLE_RC_E enRcMode;
	VPSS_CHN_MODE_S stVpssChnMode;
    
    HI_S32 i;
    HI_S32 s32Ret = HI_SUCCESS;
    HI_U32 u32BlkSize;
    HI_CHAR ch = '';
    SIZE_S stSize;

    
    memset(&stVbConf,0,sizeof(VB_CONF_S));        
     
	 
	 
	 
    u32BlkSize = SAMPLE_COMM_SYS_CalcPicVbBlkSize(gs_enNorm,
                PIC_HD720, SAMPLE_PIXEL_FORMAT, SAMPLE_SYS_ALIGN_WIDTH,COMPRESS_MODE_SEG);
    stVbConf.u32MaxPoolCnt = 64;                  
    
    stVbConf.astCommPool[0].u32BlkSize = u32BlkSize;
    //stVbConf.astCommPool[0].u32BlkCnt = u32ViChnCnt * 6;
    stVbConf.astCommPool[0].u32BlkCnt = s32VpssGrpCnt * 12;
    memset(stVbConf.astCommPool[0].acMmzName,0,
        sizeof(stVbConf.astCommPool[0].acMmzName));

    
    u32BlkSize = SAMPLE_COMM_SYS_CalcPicVbBlkSize(gs_enNorm,
                PIC_CIF, SAMPLE_PIXEL_FORMAT, SAMPLE_SYS_ALIGN_WIDTH,COMPRESS_MODE_SEG);
    
    memset(stVbConf.astCommPool[1].acMmzName,0,
        sizeof(stVbConf.astCommPool[1].acMmzName));
    stVbConf.astCommPool[1].u32BlkSize = u32BlkSize;
    stVbConf.astCommPool[1].u32BlkCnt = s32VpssGrpCnt * 6;
    memset(stVbConf.astCommPool[1].acMmzName,0,
        sizeof(stVbConf.astCommPool[1].acMmzName));

    
    s32Ret = SAMPLE_COMM_SYS_Init(&stVbConf);
    if (HI_SUCCESS != s32Ret)
    {
        SAMPLE_PRT("system init failed with %d!n", s32Ret);
        goto END_VENC_8_720p_0;       
    }

    
    s32Ret = SAMPLE_COMM_VI_Start(enViMode, gs_enNorm);
    if (HI_SUCCESS != s32Ret)
    {
        SAMPLE_PRT("start vi failed!n");
        goto END_VENC_8_720p_0;
    }
    
    
    s32Ret = SAMPLE_COMM_SYS_GetPicSize(gs_enNorm, PIC_HD720, &stSize);
    if (HI_SUCCESS != s32Ret)
    {
        SAMPLE_PRT("SAMPLE_COMM_SYS_GetPicSize failed!n");
        goto END_VENC_8_720p_0;
    }
    
    //stGrpAttr.u32MaxW = stSize.u32Width;
    //stGrpAttr.u32MaxH = stSize.u32Height;
    //stGrpAttr.bDrEn = HI_FALSE;
    //stGrpAttr.bDbEn = HI_FALSE;
    //stGrpAttr.bIeEn = HI_TRUE;
    //stGrpAttr.bNrEn = HI_TRUE;
    //stGrpAttr.bHistEn = HI_TRUE;
    //stGrpAttr.enDieMode = VPSS_DIE_MODE_AUTO;
    //stGrpAttr.enPixFmt = SAMPLE_PIXEL_FORMAT;

    s32Ret = SAMPLE_COMM_VPSS_Start(s32VpssGrpCnt, &stSize, s32VpssGrpCnt/4,NULL);
    if (HI_SUCCESS != s32Ret)
    {
        SAMPLE_PRT("Start Vpss failed!n");
        goto END_VENC_8_720p_1;
    }
	
	for (i=0; i 
4.hi_comm_video.h 
typedef enum hiVIDEO_NORM_E
{
    VIDEO_ENCODING_MODE_PAL=0,
    VIDEO_ENCODING_MODE_NTSC,
    VIDEO_ENCODING_MODE_AUTO, 
    VIDEO_ENCODING_MODE_BUTT
} VIDEO_NORM_E;
5.hi_common.h
typedef enum hiROTATE_E
{
    ROTATE_NONE = 0,               
    ROTATE_90   = 1,               
    ROTATE_180  = 2,               
    ROTATE_270  = 3,               
    ROTATE_BUTT
} ROTATE_E;

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5702848.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存