视频解码 通道 范例

实例:

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!\n",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!\n");
            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!\n", 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 \n");
            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 \n", 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 \n", s32Ret,s32ChnID);
        return s32Ret;
    }

    s32Ret = HI_MPI_VDEC_GetProtocolParam(s32ChnID, &stPrtclParam);     //获取协议相关的内存分配通道参数
    if (HI_SUCCESS != s32Ret)
    {
        SDKPRINTF("HI_MPI_VDEC_GetPrtclParam failed errno 0x%x \n", s32Ret);
        return s32Ret;
    }
    printf("lidaban-------------the vdec type is %d!\n",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 \n", s32Ret);
        return s32Ret;
    }


    s32Ret = HI_MPI_VDEC_GetChnParam(s32ChnID, &stParam);       //获取解码通道参数。
    if (HI_SUCCESS != s32Ret)
    {
        SDKPRINTF("HI_MPI_VDEC_GetChnParam failed errno 0x%x \n", 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 \n", s32Ret);
        return s32Ret;
    }
    
    s32Ret = HI_MPI_VDEC_StartRecvStream(s32ChnID);     //解码器开始接收用户发送的码流。
    if (HI_SUCCESS != s32Ret)
    {
        SDKPRINTF("HI_MPI_VDEC_StartRecvStream failed errno 0x%x \n", s32Ret);
        return s32Ret;
    }

    return HI_SUCCESS;
}

 

posted @ 2020-08-12 11:49  祁峰_1024  阅读(382)  评论(0编辑  收藏  举报