• 视频处理子系统 创建组/通道 范例


    文档范例:

    /*********************************
    *函数功能:创建组/通道
    *输出参数:
    *返回值:成功为0 失败非0
    *********************************/
    HI_S32 create_VPSS_Group()
    {
        VPSS_GRP_ATTR_S stGrpVpssAttr;     //group静态属性
        VPSS_CHN_ATTR_S stChnAttr; 
        VPSS_CROP_INFO_S stCropInfo; 
        HI_S32 s32Ret = HI_SUCCESS;     //返回值
        VPSS_GRP VpssGrp;                 //组号
        VPSS_CHN VpssChn;                 //通道号
    
        VpssGrp = 0;
        VpssChn = 0;
    
        stGrpVpssAttr.u32MaxW = 1920;         //最大图像宽高
        stGrpVpssAttr.u32MaxH = 1080; 
        stGrpVpssAttr.bIeEn = HI_FALSE;     //下面这几个都是使能开关
        stGrpVpssAttr.bDciEn = HI_FALSE; 
        stGrpVpssAttr.bNrEn = HI_FALSE; 
        stGrpVpssAttr.bHistEn = HI_FALSE; 
        stGrpVpssAttr.enDieMode = VPSS_DIE_MODE_NODIE; 
        stGrpVpssAttr.bEsEn = HI_FALSE; 
        stGrpVpssAttr.enPixFmt = PIXEL_FORMAT_YUV_SEMIPLANAR_422;     //像素格式
        s32Ret = HI_MPI_VPSS_CreateGrp(VpssGrp, &stGrpVpssAttr);     //创建组
        if(s32Ret != HI_SUCCESS) 
        { 
            return s32Ret; 
        }
    
        s32Ret = HI_MPI_VPSS_GetGrpAttr(VpssGrp, &stGrpVpssAttr);     //获取组属性
        if(s32Ret != HI_SUCCESS) 
        { 
            return s32Ret; 
        } 
    
        stGrpVpssAttr.bDciEn = HI_TRUE; 
        stGrpVpssAttr.bNrEn = HI_TRUE; 
        s32Ret = HI_MPI_VPSS_SetGrpAttr(VpssGrp, &stGrpVpssAttr);     //设置组属性
        if(s32Ret != HI_SUCCESS) 
        { 
            return s32Ret; 
        } 
    
        s32Ret = HI_MPI_VPSS_GetGrpCrop(VpssGrp, &stCropInfo);        //获取 VPSS CROP 功能属性
        if(s32Ret != HI_SUCCESS) 
        { 
            return s32Ret; 
        } 
    
        stCropInfo.bEnable = 1;                                     //crop使能开关
        stCropInfo.enCropCoordinate = VPSS_CROP_ABS_COOR;             //crop起始点坐标模式
        stCropInfo.stCropRect.s32X = 100;                             //crop矩形区域 顶点坐标和宽高
        stCropInfo.stCropRect.s32Y = 200; 
        stCropInfo.stCropRect.u32Width = 1280; 
        stCropInfo.stCropRect.u32Height = 720; 
        s32Ret = HI_MPI_VPSS_SetGrpCrop(VpssGrp, &stCropInfo);        //设置组crop属性
        if(s32Ret != HI_SUCCESS) 
        { 
            return s32Ret; 
        } 
    
        s32Ret = HI_MPI_VPSS_GetChnAttr(VpssGrp, VpssChn,&stChnAttr);     //获取通道属性
        if(s32Ret != HI_SUCCESS) 
        { 
            return s32Ret; 
        } 
    
        stChnAttr.bUVInvert = 0; 
        stChnAttr.bSpEn = 1; 
        s32Ret = HI_MPI_VPSS_SetChnAttr(VpssGrp, VpssChn,&stChnAttr);     //设置VPSS通道属性
        if(s32Ret != HI_SUCCESS) 
        {
            return s32Ret; 
        } 
    
        s32Ret = HI_MPI_VPSS_EnableChn(VpssGrp, VpssChn);                 //使能通道
        if(s32Ret != HI_SUCCESS) 
        { 
            return s32Ret; 
        } 
    
        s32Ret = HI_MPI_VPSS_StartGrp (VpssGrp);                         //启用组
        if(s32Ret != HI_SUCCESS) 
        { 
            return s32Ret; 
        } 
    
     /*****************************/ 
     /* call sys bind interface */ 
     /*****************************/ 
    
        s32Ret = HI_MPI_VPSS_StopGrp (VpssGrp);                         //禁用组
        if(s32Ret != HI_SUCCESS) 
        { 
            return s32Ret; 
        } 
    
        s32Ret = HI_MPI_VPSS_DisableChn(VpssGrp, VpssChn);                 //关闭通道
        if(s32Ret != HI_SUCCESS) 
        { 
            return s32Ret; 
        } 
    
     /*****************************/ 
     /* call sys unbind interface */ 
     /*****************************/ 
        s32Ret = HI_MPI_VPSS_DestroyGrp(VpssGrp);                         //销毁组 先禁用才能销毁
        if(s32Ret != HI_SUCCESS) 
        { 
            return s32Ret; 
        }
    }

    实例:

    HI_S32 vpss_create_vpss(HI_S32 s32GrpCnt, HI_S32 s32ChnCnt)
    {
        VPSS_GRP VpssGrp;
        VPSS_CHN VpssChn;
        VPSS_GRP_ATTR_S stGrpAttr;
        VPSS_CHN_ATTR_S stChnAttr;
        VPSS_GRP_PARAM_S stVpssParam;
        VPSS_CHN_MODE_S stVpssChnMode;
        HI_S32 s32Ret;
        HI_S32 i, j;
        SIZE_S stPicSize;
    
        VPSS_PRESCALE_INFO_S stPreScaleInfo;
    
        memset(&stGrpAttr,0,sizeof(VPSS_GRP_ATTR_S));
        stGrpAttr.bIeEn = HI_FALSE;
        stGrpAttr.bNrEn = HI_FALSE;
        stGrpAttr.bDciEn = HI_FALSE;
        stGrpAttr.bHistEn = HI_FALSE;
        stGrpAttr.bEsEn  = HI_FALSE;
        stGrpAttr.enDieMode = VPSS_DIE_MODE_NODIE;
        stGrpAttr.enPixFmt = PIXEL_FORMAT_YUV_SEMIPLANAR_420;
        //stGrpAttr.enPixFmt = PIXEL_FORMAT_YUV_SEMIPLANAR_422;
        
    
        for(i = 0; i < s32GrpCnt; i++)
        {
            VpssGrp = i;
            
            if(VpssGrp<vi_chn_num)
            {
                stGrpAttr.bNrEn = HI_TRUE;
                //stGrpAttr.bNrEn = HI_FALSE;
    
                if(Simulate_IP_mixture_mode)
                {
    
                     /* if((VpssGrp>=vi_chn_num*2))
                      {
                            stGrpAttr.bNrEn = HI_FALSE;
                      }
                      else*/
                     {
                            //stGrpAttr.bNrEn = HI_FALSE;
                     }
                    stGrpAttr.u32MaxW = 1920;//2048;  
                    stGrpAttr.u32MaxH = 1080;//1536; 
                   }
                   else
                  {    
                      /*if((VpssGrp>=vi_chn_num*2))
                      {
                          stGrpAttr.bNrEn = HI_FALSE;
                      }
                      else*/
                     {
                           //stGrpAttr.bNrEn = HI_TRUE;
                            //stGrpAttr.bNrEn = HI_FALSE;
                     }
                    stGrpAttr.u32MaxW = 1920;  
                    stGrpAttr.u32MaxH = 1080; //1944;
                  }
            }
            else
            {
    
                if(i == 13)
                {
                    stGrpAttr.bNrEn = HI_TRUE;
                }
                else
                {
                    stGrpAttr.bNrEn = HI_FALSE;
                }
                
                if(Simulate_IP_mixture_mode)
                {
                    stGrpAttr.u32MaxW = 1920;  
                    stGrpAttr.u32MaxH = 1080;
                }
                else
                {
                    stGrpAttr.u32MaxW = 1920;  
                    stGrpAttr.u32MaxH = 1080;            
                }
            }
            
            
            //stGrpAttr.u32MaxW = 2560;  
            //stGrpAttr.u32MaxH = 1944; 
    
            s32Ret = HI_MPI_VPSS_CreateGrp(VpssGrp, &stGrpAttr);    //创建一个 VPSS GROUP。
            if (s32Ret != HI_SUCCESS)
            {
                SDKPRINTF("HI_MPI_VPSS_CreateGrp %d failed with %#x!
    ",i,s32Ret);
                return HI_FAILURE;
            }
            
            s32Ret = HI_MPI_VPSS_GetGrpParam(VpssGrp, &stVpssParam);    //获取 VPSS GROUP 参数
            if (s32Ret != HI_SUCCESS)
            {
                SDKPRINTF("failed with %#x!
    ", s32Ret);
                return HI_FAILURE;
            }
    
        #if 0
            stVpssParam.u32Contrast   = 13; // 13 
            stVpssParam.u32SfStrength = 24;//36; //亮度空域去噪 26 
            stVpssParam.u32TfStrength = 18;//13; //18;//亮度时域去噪 6
            stVpssParam.u32CfStrength = 12; //色度空域去噪 12
            stVpssParam.u32CTfStrength= 10;//6;  //色度时域去噪 6
            stVpssParam.u32IeStrength = 4;//3;  // 7
            stVpssParam.u32CvbsStrength=24;
        #else
            // yqf modify 2017.7.24
            stVpssParam.u32Contrast   = 13; // 13 
            stVpssParam.u32SfStrength = 26; //亮度空域去噪 26 
            stVpssParam.u32TfStrength = 18;//亮度时域去噪 6
            stVpssParam.u32CfStrength = 12; //色度空域去噪 12
            stVpssParam.u32CTfStrength= 6;  //色度时域去噪 6
            stVpssParam.u32IeStrength = 7;  // 7
        #endif
    /*
                stVpssParam.u32CfStrength = 12; //5
            stVpssParam.u32SfStrength = 26; //20
            stVpssParam.u32TfStrength = 18;  //5
             stVpssParam.u32CTfStrength =6; //5
             stVpssParam.u32Contrast =13;    //8
    */    
            s32Ret = HI_MPI_VPSS_SetGrpParam(VpssGrp, &stVpssParam);    //设置 VPSS GRUOP 参数。
            if (s32Ret != HI_SUCCESS)
            {
                SDKPRINTF("failed with %#x!
    ", s32Ret);
                return HI_FAILURE;
            }
    
    
            //modify by yqf 2018.4.3
            if(vi_chn_num > VpssGrp)
            {
                s32Ret = HI_MPI_VPSS_DisableBackupFrame(VpssGrp);
                if (s32Ret != HI_SUCCESS)
                {
                    SDKPRINTF("HI_MPI_VPSS_DisableBackupFrame %d failed with %#x!
    ",i,s32Ret);
                    return HI_FAILURE;
                }
            }
            
            for(j = 0; j < s32ChnCnt; j++)
            {
                if(vi_chn_num != 8)
                {
                    if(i >=vi_chn_num )
                    {
                        if(i <=g_vi_chn_num )
                        {
                            if(j>1)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            if(j>0)
                            {
                                continue;
                            }
                        }
                    }
                }
                else
                {
                    if(i >=vi_chn_num )
                    {        
                        if(j>0)
                        {
                            continue;
                        }
                    }    
                }
                VpssChn = j;
                stChnAttr.bSpEn = HI_FALSE;
                stChnAttr.bUVInvert = HI_FALSE;
                stChnAttr.bBorderEn = HI_TRUE;
                
                stChnAttr.stBorder.u32BottomWidth=2;
                stChnAttr.stBorder.u32Color=0x0000;
                stChnAttr.stBorder.u32LeftWidth=2;
                stChnAttr.stBorder.u32RightWidth=2;
                stChnAttr.stBorder.u32TopWidth=2;
                
                
                //stChnAttr.bSpEn = HI_FALSE;
                //stChnAttr.bFrameEn = HI_FALSE;
                //stChnAttr.stFrame.u32Color[VPSS_FRAME_WORK_LEFT] = 0xff00;
                //stChnAttr.stFrame.u32Color[VPSS_FRAME_WORK_RIGHT] = 0xff00;
                //stChnAttr.stFrame.u32Color[VPSS_FRAME_WORK_BOTTOM] = 0xff00;
                //stChnAttr.stFrame.u32Color[VPSS_FRAME_WORK_TOP] = 0xff00;
                //stChnAttr.stFrame.u32Width[VPSS_FRAME_WORK_LEFT] = 2;
                //stChnAttr.stFrame.u32Width[VPSS_FRAME_WORK_RIGHT] = 2;
                //stChnAttr.stFrame.u32Width[VPSS_FRAME_WORK_TOP] = 2;
                //stChnAttr.stFrame.u32Width[VPSS_FRAME_WORK_BOTTOM] = 2;
                
                s32Ret = HI_MPI_VPSS_SetChnAttr(VpssGrp, VpssChn, &stChnAttr);      //设置 VPSS 通道属性。
                if (s32Ret != HI_SUCCESS)
                {
                    SDKPRINTF("HI_MPI_VPSS_SetChnAttr failed with %#x grp is %d ,chn is %d 
    ", s32Ret,VpssGrp,VpssChn);
                    return HI_FAILURE;
                }
    
    
                
    #if 1
                //if (3 != VpssChn)
                {
                    VPSS_CHN_MODE_S stVpssMode;
                    s32Ret = HI_MPI_VPSS_GetChnMode(VpssGrp,VpssChn,&stVpssMode);       //获取 VPSS 通道工作模式
                    if(s32Ret != HI_SUCCESS) 
                    {         
                        printf("HI_MPI_VPSS_GetChnMode:0x%x
    ", s32Ret);
                        return s32Ret;  
                    } 
    
                    //modify by yqf 2018.3.7
                    stVpssMode.enPixelFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420;
    
                    stVpssMode.enCompressMode =COMPRESS_MODE_NONE;
                    /*
                    if((VpssGrp>=g_vi_chn_num)&&(VpssGrp<g_vi_chn_num *2))
                    {
                        if(VpssChn == 0) 
                        {
                            stVpssMode.enCompressMode =COMPRESS_MODE_NONE;
                            stVpssMode.u32Width = 1920; 
                            stVpssMode.u32Height = 1080; 
                            stVpssMode.enChnMode = VPSS_CHN_MODE_USER; 
                        }
                    }
                    */
                    s32Ret = HI_MPI_VPSS_SetChnMode(VpssGrp,VpssChn,&stVpssMode);       //设置 VPSS 通道工作模式
                    if(s32Ret != HI_SUCCESS) 
                    { 
                        printf("HI_MPI_VPSS_SetChnMode:0x%x
    ", s32Ret);
                        return s32Ret;  
                    } 
                }
    #endif
                s32Ret = HI_MPI_VPSS_EnableChn(VpssGrp, VpssChn);       //启用 VPSS 通道
                if (s32Ret != HI_SUCCESS)
                {
                    SDKPRINTF("HI_MPI_VPSS_EnableChn failed with %#x
    ", s32Ret);
                    return HI_FAILURE;
                }
            }
    
            s32Ret = HI_MPI_VPSS_StartGrp(VpssGrp);     //启用 VPSS GROUP。
            if (s32Ret != HI_SUCCESS)
            {
                SDKPRINTF("HI_MPI_VPSS_StartGrp failed with %#x
    ", s32Ret);
                return HI_FAILURE;
            }
        }
    
        return HI_SUCCESS;
    }
  • 相关阅读:
    生活是把锋利的剪刀,看你怎么持有
    稚晖君已经很强了,我们怎么能追逐强人的步伐呢?一些自己的思考
    分享自己做的一个指定进程以及线程长时间cpu监控的工具
    Centos7下配置网卡网桥
    Smokeping安装和配置(Shell一键安装)
    18.jvm调优工具及案例分析
    处理mac不能使用rz和sz的问题
    16.彻底解决Jmap在mac版本无法使用的问题
    17.mac安装homebrew及异常处理
    15. mac安装多版本jdk
  • 原文地址:https://www.cnblogs.com/qifeng1024/p/13476326.html
Copyright © 2020-2023  润新知