zoukankan      html  css  js  c++  java
  • 视频解码 通道 范例

    实例:

    HI_S32 vdec_create(PAYLOAD_TYPE_E enType, HI_S32 s32Cnt)
    {
        HI_S32 i;
        HI_S32 s32Ret;
        VDEC_CHN VdChn;
        VPSS_GRP VpssGrp;
        SIZE_S stSize;
    
        for(i = 0; i < s32Cnt; i++)
        { 
            VdChn = i;
    
            if(Simulate_IP_mixture_mode)
               {
                if(vi_chn_num == 4)
                {
                    stSize.u32Width  = 1920; //huangwj add 2560
                    stSize.u32Height = 1080; //1944;
                }
                else
                {
                    if( i < 4)
                    {
                        stSize.u32Width = 1920;
                        stSize.u32Height= 1080; 
                    }
                    else
                    {
                        stSize.u32Width = 704;
                        stSize.u32Height= 576;                 
                    }            
                }
               }
            else
               {
                stSize.u32Width  = 1920; //huangwj add 2560
                stSize.u32Height = 1080; //1944;
               }
            printf("the %d ch vdec width is %d, height is %d!
    ",i,major_stream[i].width,major_stream[i].height);
            s32Ret = vdec_create_vdec_chn(VdChn, &stSize, enType, VIDEO_MODE_STREAM);
            if(HI_SUCCESS != s32Ret)
            {
                SDKPRINTF("create vdec chn failed!
    ");
                return HI_FAILURE ;
            }        
            if(net_chn_num == 0)
            {
                if(globalVoDev == VO_DEV_DHD0)
                {
                    VpssGrp = i;
                    s32Ret = vdec_bind_vpss(VdChn, VpssGrp+g_vi_chn_num);
                    if(HI_SUCCESS !=s32Ret)
                    {
                        SDKPRINTF("vdec(vdch=%d) bind vpss(vpssg=%d) failed!
    ", VdChn, VpssGrp);
                        return HI_FAILURE;
                    }
                }
            }
            
        }
        return HI_SUCCESS;
    }

    创建VDEC通道

    static HI_S32 vdec_create_vdec_chn(HI_S32 s32ChnID, SIZE_S *pstSize, PAYLOAD_TYPE_E enType, VIDEO_MODE_E enVdecMode)
    {
        HI_S32 s32Ret;
        VDEC_CHN_ATTR_S stAttr;
        VDEC_PRTCL_PARAM_S stPrtclParam;
    
        VDEC_CHN_PARAM_S stParam;
        
        memset(&stAttr, 0, sizeof(VDEC_CHN_ATTR_S));
        stAttr.enType = enType;
        //stAttr.u32BufSize = pstSize->u32Width * pstSize->u32Height; // *3/4;    
        stAttr.u32BufSize = pstSize->u32Width * pstSize->u32Height *3/4;
        stAttr.u32Priority = 1;
        
        stAttr.u32PicWidth = pstSize->u32Width;
        stAttr.u32PicHeight = pstSize->u32Height;
    
    
        switch (enType)
        {
            case PT_H264:
            {
                stAttr.stVdecVideoAttr.u32RefFrameNum = 1; //2; 
                stAttr.stVdecVideoAttr.enMode = enVdecMode;
                stAttr.stVdecVideoAttr.bTemporalMvpEnable = 0;
            }
            break;
            case PT_H265:      //add by lth 2017.10.10   H.265
            {
                stAttr.stVdecVideoAttr.u32RefFrameNum = 2;
                stAttr.stVdecVideoAttr.enMode = enVdecMode;
                stAttr.stVdecVideoAttr.bTemporalMvpEnable = 1;  //modify by lth 2017.11.19    
            }
            break;
            
            case PT_JPEG:
            {
                stAttr.stVdecJpegAttr.enMode = enVdecMode;
            }
            break;
            case PT_MJPEG:
            {
                stAttr.stVdecJpegAttr.enMode = enVdecMode;
            }
            break;
            default:
            {
                SDKPRINTF("err type 
    ");
                return HI_FAILURE;
            }
        }
        // 设置相应的解码缓冲池
        s32Ret = HI_MPI_VDEC_SetChnVBCnt(s32ChnID, 3);  //3  设置解码通道 PrivateVB 池的 VB 个数
        if (HI_SUCCESS != s32Ret)
        {
            SDKPRINTF("HI_MPI_VDEC_SetChnVBCnt failed errno 0x%x 
    ", s32Ret);
            return s32Ret;
        }
        s32Ret = HI_MPI_VDEC_CreateChn(s32ChnID, &stAttr);      //创建视频解码通道。
        if (HI_SUCCESS != s32Ret)
        {
            SDKPRINTF("HI_MPI_VDEC_CreateChn failed errno 0x%x,chnid:%d 
    ", s32Ret,s32ChnID);
            return s32Ret;
        }
    
        s32Ret = HI_MPI_VDEC_GetProtocolParam(s32ChnID, &stPrtclParam);     //获取协议相关的内存分配通道参数
        if (HI_SUCCESS != s32Ret)
        {
            SDKPRINTF("HI_MPI_VDEC_GetPrtclParam failed errno 0x%x 
    ", s32Ret);
            return s32Ret;
        }
        printf("lidaban-------------the vdec type is %d!
    ",stPrtclParam.enType);
    
    #if 0  //modify by yqf 2018.3.27
        stPrtclParam.stH264PrtclParam.s32MaxPpsNum=16;
         stPrtclParam.stH264PrtclParam.s32MaxSliceNum=100;
         stPrtclParam.stH264PrtclParam.s32MaxSpsNum=16;
    #endif
    
        //add by yqf 2018.3.27
         stPrtclParam.stH265PrtclParam.s32MaxSliceSegmentNum=100;
        stPrtclParam.stH265PrtclParam.s32MaxVpsNum=16;//10;//10
         stPrtclParam.stH265PrtclParam.s32MaxSpsNum=16;//2
        stPrtclParam.stH265PrtclParam.s32MaxPpsNum=55;//55;//55
    
        s32Ret = HI_MPI_VDEC_SetProtocolParam(s32ChnID, &stPrtclParam);     //设置协议相关的内存分配通道参数
        if (HI_SUCCESS != s32Ret)
        {
            SDKPRINTF("HI_MPI_VDEC_SetPrtclParam failed errno 0x%x 
    ", s32Ret);
            return s32Ret;
        }
    
    
        s32Ret = HI_MPI_VDEC_GetChnParam(s32ChnID, &stParam);       //获取解码通道参数。
        if (HI_SUCCESS != s32Ret)
        {
            SDKPRINTF("HI_MPI_VDEC_GetChnParam failed errno 0x%x 
    ", s32Ret);
            return s32Ret;
        }
        stParam.s32DisplayFrameNum = 2; //modify by yqf 2018.3.28
        stParam.s32DecMode= 1;
        stParam.s32ChanErrThr = 0;
        s32Ret =HI_MPI_VDEC_SetChnParam(s32ChnID, &stParam);    //设置解码通道参数
        if (HI_SUCCESS != s32Ret)
        {
            SDKPRINTF("HI_MPI_VDEC_SetPrtclParam failed errno 0x%x 
    ", s32Ret);
            return s32Ret;
        }
        
        s32Ret = HI_MPI_VDEC_StartRecvStream(s32ChnID);     //解码器开始接收用户发送的码流。
        if (HI_SUCCESS != s32Ret)
        {
            SDKPRINTF("HI_MPI_VDEC_StartRecvStream failed errno 0x%x 
    ", s32Ret);
            return s32Ret;
        }
    
        return HI_SUCCESS;
    }
  • 相关阅读:
    .net core 2.0以上版本加载appsettings.json
    BZOJ 2564: 集合的面积
    P3829 [SHOI2012]信用卡凸包
    P2215 [HAOI2007]上升序列
    P2511 [HAOI2008]木棍分割
    P2510 [HAOI2008]下落的圆盘
    P4053 [JSOI2007]建筑抢修
    P4050 [JSOI2007]麻将
    P4049 [JSOI2007]合金
    P4161 [SCOI2009]游戏
  • 原文地址:https://www.cnblogs.com/qifeng1024/p/13489779.html
Copyright © 2011-2022 走看看