jerrylipeng

jerrylipeng

1个粉丝

11

问答

0

专栏

0

资料

jerrylipeng  发布于  2016-04-19 17:06:53
采纳率 0%
11个问答
20322

HI3531 VPSS工作模式

 
我刚开始学习3531,基于sample vdec,写了一个显示jpeg图像到DHD0的程序

程序能正常工作,但是如果我试图调用HI_MPI_VPSS_SetChnMode设置工作模式为VPSS_CHN_MODE_USER,程序不报错,但是显示无图像。

[code]int startVpss() {/*{{{*/
    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 stChnMode;
    HI_S32 s32Ret;

    stGrpAttr.u32MaxW = 2048;
    stGrpAttr.u32MaxH = 2048;
    stGrpAttr.bDrEn = HI_FALSE;
    stGrpAttr.bDbEn = HI_FALSE;
    stGrpAttr.bIeEn = HI_TRUE;
    stGrpAttr.bNrEn = HI_TRUE;
    stGrpAttr.bHistEn = HI_FALSE;
    stGrpAttr.enDieMode = VPSS_DIE_MODE_AUTO;
    stGrpAttr.enPixFmt = SAMPLE_PIXEL_FORMAT;

    vpssGrp = 0;

    /*** create vpss group ***/
    s32Ret = HI_MPI_VPSS_CreateGrp(vpssGrp, &stGrpAttr);
    if (s32Ret != HI_SUCCESS) {
        SAMPLE_PRT("HI_MPI_VPSS_CreateGrp failed with 0x%#x!\n", s32Ret);
        return HI_FAILURE;
    }

    /*** set vpss param ***/
    s32Ret = HI_MPI_VPSS_GetGrpParam(vpssGrp, &stVpssParam);
    if (s32Ret != HI_SUCCESS) {
        SAMPLE_PRT("HI_MPI_VPSS_GetGrpParam failed with 0x%#x!\n", s32Ret);
        return HI_FAILURE;
    }
   
    stVpssParam.u32MotionThresh = 0;
   
    s32Ret = HI_MPI_VPSS_SetGrpParam(vpssGrp, &stVpssParam);
    if (s32Ret != HI_SUCCESS) {
        SAMPLE_PRT("HI_MPI_VPSS_SetGrpParam failed with 0x%#x!\n", s32Ret);
        return HI_FAILURE;
    }

    /*** enable vpss chn, with frame ***/
    vpssChn = 2;
    /* Set Vpss Chn attr */
    stChnAttr.bSpEn = HI_FALSE;
    stChnAttr.bFrameEn = HI_TRUE;
    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);
    if (s32Ret != HI_SUCCESS) {
        SAMPLE_PRT("HI_MPI_VPSS_SetChnAttr failed with 0x%#x\n", s32Ret);
        return HI_FAILURE;
    }

    stChnMode.enChnMode = VPSS_CHN_MODE_USER;
    stChnMode.enPixelFormat = SAMPLE_PIXEL_FORMAT;
    stChnMode.bDouble = HI_FALSE;
    stChnMode.u32Width = 1920;
    stChnMode.u32Height = 1080;
    //s32Ret = HI_MPI_VPSS_SetChnMode(vpssGrp, vpssChn, &stChnMode);             // <---------------------- 调用这个就不显示图像
    //if(s32Ret != HI_SUCCESS) {
    //    SAMPLE_PRT("HI_MPI_VPSS_SetChnMode failed with %#x\n", s32Ret);
    //    return HI_FAILURE;
    //}

    s32Ret = HI_MPI_VPSS_EnableChn(vpssGrp, vpssChn);
    if (s32Ret != HI_SUCCESS) {
        SAMPLE_PRT("HI_MPI_VPSS_EnableChn failed with 0x%#x\n", s32Ret);
        return HI_FAILURE;
    }

    /*** start vpss group ***/
    s32Ret = HI_MPI_VPSS_StartGrp(vpssGrp);
    if (s32Ret != HI_SUCCESS) {
        SAMPLE_PRT("HI_MPI_VPSS_StartGrp failed with 0x%#x\n", s32Ret);
        return HI_FAILURE;
    }

    return HI_SUCCESS;
}/*}}}*/
[/code]


1.默认AUTO模式下,可以正常显示图像。VPSS从哪里自动得到相应的配置?是从绑定到的VO得到的吗?
2.我这里应该如何设置才能正常显示图像呢?

P.S. 我看到文档里说如果要用到虚拟VO,就得设置VPSS的模式为USER,所以我想先在DHD0试试这个API
我来回答
回答24个
时间排序
认可量排序

zhuangweiye

8个粉丝

0

问答

0

专栏

0

资料

zhuangweiye 2016-04-19 17:35:29
认可0
VPSS mode的问题是这样的

VPSS处理图像的尺寸 有输入和输出
不管auto还是user, 输入大小是必须设置的,表示VPSS能处理的最大图像的能力,只要输入图像小于这个尺寸都可以处理,但是VPSS输入的大小越大就要消耗越多的MMZ内存(主要是开了去噪和DIE)

auto和user主要是针对VPSS输出的,对于auto是不需要设置输出大小的,VPSS会跟据绑定的后续模块自动提供合适大小的图像,但是一个channel只能绑定一个后续模块

而uer模式就要设定输出大小, 好处是可以绑定多个后续模块, 这个在3531上很少用到
如果设了user模式,就要保证后续模块需要的图像大小必须和VPSS设的输出大小格式都一样

jerrylipeng

1个粉丝

11

问答

0

专栏

0

资料

jerrylipeng 2016-04-19 17:42:27
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=28732&ptid=11048]zhuangweiye 发表于 2016-4-19 17:35[/url]
VPSS mode的问题是这样的

VPSS处理图像的尺寸 有输入和输出
[/quote]

多谢大神,你这样解释我就明白了。

比较蛋疼的是文档中关于虚拟VO的描述:


我先在就是想不清楚怎么用虚拟VO,sample里也没有讲到

zhuangweiye

8个粉丝

0

问答

0

专栏

0

资料

zhuangweiye 2016-04-20 08:44:10
认可0
虚拟VO, 可以按实际VO来处理, 唯一不同的是vodev号不一样
比如说 vodev=0就是DHD0, 对于3531; vodev=10, 就是vo虚拟设备

楼上红框的内容,个人理解如下:
1. 这个绑定是 VPSS-->虚拟VO, 即虚拟VO是数据接收者
2. 我们知道VPSS-->SD VO时只能使用bypass channel或vpss者使用的channel设为user mode, 也就是说虚拟VO做为数据接收者是和SD vo一样处理的
3. 用处是什么? 对于单路图像处理直接用VPSS就能得到, 而对于多路图像放在一起的多分割处理(比如编码一个9分割画面,9分割整体是1080P)是不是就可以用到了
4. 限制是什么? 红框上一条标明用虚拟VO要考虑TDE的性能

是否可以考虑下面的做法, 来实现4分割录像
VI(4个channel)-->VPSS(4个group, 使用bypass channel)-->虚拟VO(4个channel)-->VPSS(1个group)-->VENC(1个group)

当然也可以考虑下面的做法, 来实现一个VO channel里面显示4分割
VI(4个channel)-->VPSS(4个group, 使用bypass channel)-->虚拟VO(4个channel)-->VPSS(1个group)-->VO(1个channel)

不过,上面只是测试虚拟vo的用法,是否能用或者实用价值在哪里就不清楚了

jerrylipeng

1个粉丝

11

问答

0

专栏

0

资料

jerrylipeng 2016-04-20 09:16:47
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=28764&ptid=11048]zhuangweiye 发表于 2016-4-20 08:44[/url]
虚拟VO, 可以按实际VO来处理, 唯一不同的是vodev号不一样
比如说 vodev=0就是DHD0, 对于3531; vodev=10,  ...[/quote]

我主要想实现的就是多画面拼接。
我的图像来源是H264解码的数据
VDEC(4 channel) -> VPSS(4 group) -> 虚拟VO(4 channel) -> VO

解码来的图像需要缩放,VPSS的bypass channel就不行了吧?所以我想试试user模式
如果是SD VO,要把某个图像源缩小了显示,是怎么实现呢?

虚拟VO可以绑定到VO不?我看文档里的表格好像是可以的

zhuangweiye

8个粉丝

0

问答

0

专栏

0

资料

zhuangweiye 2016-04-20 09:31:55
认可0
多画面拼接一般用不到虚拟VO
两种情况:
VDEC(N个channel)-->VPSS(N个group, 每个用一个channel)-->VO(HD, N个channel, 每个channel要设显示位置大小即可)
这里VPSS只要设VDEC最大输出图像大小即可(海思这点还是很贴心的)

VDEC(N个channel)-->VO(SD, N个channel, 每个channel要设显示位置大小即可)
这里不用VPSS掺和

上面的两种方法sample/vdec都有,只要把chn数改为不是1(比如4),VO输出模式不要设1分割(比如4分割),建议楼主再仔细看看
HI_S32 SAMPLE_VDEC_Process(PIC_SIZE_E enPicSize, PAYLOAD_TYPE_E enType, HI_S32 s32Cnt, VO_DEV VoDev)

另外,虚拟VO不能直接绑VO

jerrylipeng

1个粉丝

11

问答

0

专栏

0

资料

jerrylipeng 2016-04-20 09:39:19
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=28771&ptid=11048]zhuangweiye 发表于 2016-4-20 09:31[/url]
多画面拼接一般用不到虚拟VO
两种情况:
VDEC(N个channel)-->VPSS(N个group, 每个用一个channel)-->VO(HD, ...[/quote]

多谢大神!
我实际用到的情况画面之间有重叠,所以不能直接用HD

按照你的提示,我可能需要
VDEC(N Channel) --> 虚拟VO(N channel) --> VPSS (1 group ) --> HD VO (1 channel)

P.S. 我在另一个帖子里看到虚拟VO是可以支持到1080P的,所以如果虚拟VO跟VO一样大的话,VPSS bypass channel就行了吧

zhuangweiye

8个粉丝

0

问答

0

专栏

0

资料

zhuangweiye 2016-04-20 09:45:05
认可0
重叠的话 不知道虚拟VO能不能支持, 如果重叠只是一个窗口,可以考虑用PIP来实现

另外,如果没有特别需求,VPSS还是用auto, 傻瓜用法

jerrylipeng

1个粉丝

11

问答

0

专栏

0

资料

jerrylipeng 2016-04-20 11:05:16
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=28778&ptid=11048]zhuangweiye 发表于 2016-4-20 09:45[/url]
重叠的话 不知道虚拟VO能不能支持, 如果重叠只是一个窗口,可以考虑用PIP来实现

另外,如果没有特别需求,V ...[/quote]

做了一个实验

VDEC (1 channel) -> VPSS (bypass channel) -> 虚拟VO(1 channel) -> HD VO(1 channel)

发现可以正常显示图像,这说明虚拟VO绑定到VO是可行的?

[code]# cat /proc/umap/sys

[SYS] Version: [Hi3531_MPP_V1.0.D.0 ], Build Time[Feb  6 2015, 20:22:44]

System State: 0 (0: initialized; 1: exiting; 2: exited)

-----MEM TABLE--------------------------------------------------------
   MOD           MODNAME DEV CHN           MMZNAME

-----BIND RELATION TABLE--------------------------------------------------------
  FirMod  FirDev  FirChn  SecMod  SecDev  SecChn  TirMod  TirDev  TirChn SendCnt  rstCnt
    vdec       0       0    vpss       0       4      vo      10       0       1       0
    vpss       0       4      vo      10       0      vo       0       0       1       0
      vo      10       0      vo       0       0    null       0       0    3532       0
[/code]

zhuangweiye

8个粉丝

0

问答

0

专栏

0

资料

zhuangweiye 2016-04-20 11:42:14
认可0

文档上说"禁止调用HI_MPI_SYS_Bind 接口将VO 虚拟设备绑定到VO 设备自身。"

看来我小学语文没学好:lol

jerrylipeng

1个粉丝

11

问答

0

专栏

0

资料

jerrylipeng 2016-04-20 12:39:13
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=28801&ptid=11048]zhuangweiye 发表于 2016-4-20 11:42[/url]
文档上说"禁止调用HI_MPI_SYS_Bind 接口将VO 虚拟设备绑定到VO 设备自身。"

看来我小学语文没学好[/quote]

我也看到这一句了,但觉得跟表格里的描述不相符,就试了一下。。

kennybluezy

0个粉丝

16

问答

0

专栏

0

资料

kennybluezy 2016-06-06 17:40:50
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=28777&ptid=11048]jerrylipeng 发表于 2016-4-20 09:39[/url]
多谢大神!
我实际用到的情况画面之间有重叠,所以不能直接用HD

[/quote]

lz你好,我现在也需要实现类似的功能,就是VDEC(1080P)-->VPSS-->VO(720P)(做一定处理)-->VENC(1080P)。看了下SDK文档,虚拟VO应该是比较好的方法,但文档中说虚拟VO相当于SD,就是分辨率不支持720P。并且实际试验,创建虚拟VO后,不支持720P信号的。不知能否确认你所说的虚拟VO支持1080P?另若要实现将720P的VO数据编码为1080P的数据,是否有其他方法?非常感谢

jerrylipeng

1个粉丝

11

问答

0

专栏

0

资料

jerrylipeng 2016-06-07 13:47:59
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=31226&ptid=11048]kennybluezy 发表于 2016-6-6 17:40[/url]
lz你好,我现在也需要实现类似的功能,就是VDEC(1080P)-->VPSS-->VO(720P)(做一定处理)-->VENC(1080P)。 ...[/quote]

我能确认虚拟VO支持1080P,我在实际板上已经验证过了。

我虚拟VO直接绑定VO就输出显示了,而且两个都是1080P。你需要再进VENC,我想应该没问题吧。
但是你虚拟VO是720P怎么直接进VENC按1080P编码?是不是应该一直才好?
我建议你先一步一步调试?
1.虚拟VO收到数据(绑定到VO输出看看,或者getImage之类的)
2.用1080P的虚拟VO绑定到VENC编码看看行不行
3.看720P给VENC行不行

jerrylipeng

1个粉丝

11

问答

0

专栏

0

资料

jerrylipeng 2016-06-07 13:52:00
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=31226&ptid=11048]kennybluezy 发表于 2016-6-6 17:40[/url]
lz你好,我现在也需要实现类似的功能,就是VDEC(1080P)-->VPSS-->VO(720P)(做一定处理)-->VENC(1080P)。 ...[/quote]

你看文档里这样说了,你用720P直接给VENC(1080P)不行的吧

kennybluezy

0个粉丝

16

问答

0

专栏

0

资料

kennybluezy 2016-06-07 15:01:56
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=31252&ptid=11048]jerrylipeng 发表于 2016-6-7 13:47[/url]
我能确认虚拟VO支持1080P,我在实际板上已经验证过了。

我虚拟VO直接绑定VO就输出显示了,而且两个都 ...[/quote]

嗯,是的,我知道输入VENC的图像不能比设定的分辨率低,所以之前没有说清楚,在虚拟VO和VENC之间有个VPSS的,利用VPSS的放大功能实现匹配。
OK,不知能否告知虚拟VO的主要配置部分,以便我对照查看配置上有什么问题? 非常感谢

jerrylipeng

1个粉丝

11

问答

0

专栏

0

资料

jerrylipeng 2016-06-07 15:29:37
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=31256&ptid=11048]kennybluezy 发表于 2016-6-7 15:01[/url]
嗯,是的,我知道输入VENC的图像不能比设定的分辨率低,所以之前没有说清楚,在虚拟VO和VENC之间有个VPSS ...[/quote]

附件怎么不能上传.c文件啊,好麻烦
这是我的代码,看看对你有帮助吗

[code]// virtual_vo_test.c

// {{{ headers
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

#include "hi_common.h"
#include "hi_comm_sys.h"
#include "hi_comm_vb.h"
#include "hi_comm_vi.h"
#include "hi_comm_vo.h"
#include "hi_comm_venc.h"
#include "hi_comm_vpss.h"
#include "hi_comm_vdec.h"
#include "hi_comm_vda.h"
#include "hi_comm_region.h"
#include "hi_comm_adec.h"
#include "hi_comm_aenc.h"
#include "hi_comm_ai.h"
#include "hi_comm_ao.h"
#include "hi_comm_aio.h"
#include "hi_comm_hdmi.h"
#include "hi_defines.h"

#include "mpi_sys.h"
#include "mpi_vb.h"
#include "mpi_vi.h"
#include "mpi_vo.h"
#include "mpi_venc.h"
#include "mpi_vpss.h"
#include "mpi_vdec.h"
#include "mpi_vda.h"
#include "mpi_region.h"
#include "mpi_adec.h"
#include "mpi_aenc.h"
#include "mpi_ai.h"
#include "mpi_ao.h"
#include "mpi_hdmi.h"
// }}} end of headers

#define VO_DHD0 0
#define VO_VIRT 10
#define WIN_NUM 4

#define SAMPLE_SYS_ALIGN_WIDTH      64
#define SAMPLE_PIXEL_FORMAT         PIXEL_FORMAT_YUV_SEMIPLANAR_420
#define SAMPLE_PRT(fmt...)   \
    do { \
        printf("[%s]-%d: ", __FUNCTION__, __LINE__); \
        printf(fmt); \
    } while(0)


#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* End of #ifdef __cplusplus */

typedef struct {
    pthread_t pid;
    HI_BOOL bRun;
} ThreadParam;

ThreadParam threadParam;

int sysInit();
int memConfig();
int startVoVirtual();
int startVo();
int bindVo();
int startVdec();
int bindVdec();
void decodeProcess();
void* decodeJpeg(void *pParam);
int stopVdec();
int unbindVdec();
int stopVirtualVo();
int stopVo();
int unbindVo();
void sysExit();

int main(int argc, char* argv[]) {/*{{{*/
    if (HI_SUCCESS != sysInit()) {
        return HI_FAILURE;
    }

    if (HI_SUCCESS != memConfig()) {
        return HI_FAILURE;
    }

    if (HI_SUCCESS != startVoVirtual()) {
        return HI_FAILURE;
    }

    if (HI_SUCCESS != startVo()) {
        return HI_FAILURE;
    }

    if (HI_SUCCESS != bindVo()) {
        return HI_FAILURE;
    }

    if (HI_SUCCESS != startVdec()) {
        return HI_FAILURE;
    }

    if (HI_SUCCESS != bindVdec()) {
        return HI_FAILURE;
    }

    decodeProcess();

    if (HI_SUCCESS != stopVdec()) {
        return HI_FAILURE;
    }

    if (HI_SUCCESS != unbindVdec()) {
        return HI_FAILURE;
    }

    if (HI_SUCCESS != stopVirtualVo()) {
        return HI_FAILURE;
    }

    if (HI_SUCCESS != stopVo()) {
        return HI_FAILURE;
    }

    if (HI_SUCCESS != unbindVo()) {
        return HI_FAILURE;
    }

    sysExit();

    return HI_SUCCESS;
}/*}}}*/

int sysInit() {/*{{{*/
    HI_S32 s32Ret;
    MPP_SYS_CONF_S stSysConf;
    VB_CONF_S stVbConf;

    HI_MPI_SYS_Exit();
    HI_MPI_VB_Exit();

    /******************************************
     * vb init
     *****************************************/
    memset(&stVbConf,0,sizeof(VB_CONF_S));
    stVbConf.u32MaxPoolCnt = 128;

    s32Ret = HI_MPI_VB_SetConf(&stVbConf);
    if (HI_SUCCESS != s32Ret) {
        SAMPLE_PRT("HI_MPI_VB_SetConf failed!\n");
        return HI_FAILURE;
    }

    s32Ret = HI_MPI_VB_Init();
    if (HI_SUCCESS != s32Ret) {
        SAMPLE_PRT("HI_MPI_VB_Init failed!\n");
        return HI_FAILURE;
    }

    /******************************************
     * sys init
     *****************************************/
    stSysConf.u32AlignWidth = SAMPLE_SYS_ALIGN_WIDTH;
    s32Ret = HI_MPI_SYS_SetConf(&stSysConf);
    if (HI_SUCCESS != s32Ret) {
        SAMPLE_PRT("HI_MPI_SYS_SetConf failed\n");
        return HI_FAILURE;
    }

    s32Ret = HI_MPI_SYS_Init();
    if (HI_SUCCESS != s32Ret) {
        SAMPLE_PRT("HI_MPI_SYS_Init failed!\n");
        return HI_FAILURE;
    }

    return HI_SUCCESS;
}/*}}}*/

int memConfig() {/*{{{*/
    HI_S32 s32Ret;
    MPP_CHN_S stMppChn;
    HI_CHAR* pcMmzName;
    int i;

    /******************************************
     * vdec mem config
     *****************************************/
    for (i = 0; i < WIN_NUM; i++) {
        stMppChn.enModId = HI_ID_VDEC;
        stMppChn.s32DevId = 0;
        stMppChn.s32ChnId = i;

        pcMmzName = (i%2)? "ddr1" : NULL;
        s32Ret = HI_MPI_SYS_SetMemConf(&stMppChn, pcMmzName);
        if (HI_SUCCESS != s32Ret) {
            SAMPLE_PRT("HI_MPI_SYS_SetMemConf failed!\n");
            return HI_FAILURE;
        }
    }

    /******************************************
     * virtual vo mem config
     *****************************************/
    stMppChn.enModId  = HI_ID_VOU;
    stMppChn.s32DevId = VO_VIRT;
    stMppChn.s32ChnId = 0;
    s32Ret = HI_MPI_SYS_SetMemConf(&stMppChn, NULL);
    if (HI_SUCCESS != s32Ret) {
        SAMPLE_PRT("HI_MPI_SYS_SetMemConf failed!\n");
        return HI_FAILURE;
    }

    /******************************************
     * vo mem config
     *****************************************/
    stMppChn.enModId  = HI_ID_VOU;
    stMppChn.s32DevId = VO_DHD0;
    stMppChn.s32ChnId = 0;
    s32Ret = HI_MPI_SYS_SetMemConf(&stMppChn, NULL);
    if (HI_SUCCESS != s32Ret) {
        SAMPLE_PRT("HI_MPI_SYS_SetMemConf failed!\n");
        return HI_FAILURE;
    }

    return HI_SUCCESS;
}/*}}}*/

int startVoVirtual() {/*{{{*/
    HI_S32 s32Ret;
    VO_DEV voDev = VO_VIRT;
    VO_PUB_ATTR_S stVoPubAttr;
    VO_VIDEO_LAYER_ATTR_S stLayerAttr;
    VO_CHN_ATTR_S stChnAttr;
    HI_U32 u32Width = 1920;
    HI_U32 u32Height = 1080;
    int i;
    VO_CHN chn;

    stVoPubAttr.u32BgColor = 0x000000ff;
    stVoPubAttr.enIntfType = VO_INTF_BT1120;
    stVoPubAttr.enIntfSync = VO_OUTPUT_1080P50;
    stVoPubAttr.bDoubleFrame = HI_FALSE;
    s32Ret = HI_MPI_VO_SetPubAttr(voDev, &stVoPubAttr);
    if (s32Ret != HI_SUCCESS) {
        SAMPLE_PRT("HI_MPI_VO_SetPubAttr failed with 0x%#x!\n", s32Ret);
        return HI_FAILURE;
    }

    s32Ret = HI_MPI_VO_Enable(voDev);
    if (s32Ret != HI_SUCCESS) {
        SAMPLE_PRT("HI_MPI_VO_Enable failed with 0x%#x!\n", s32Ret);
        return HI_FAILURE;
    }

    stLayerAttr.enPixFormat = SAMPLE_PIXEL_FORMAT;
    stLayerAttr.u32DispFrmRt = 25;
    stLayerAttr.stDispRect.s32X       = 0;
    stLayerAttr.stDispRect.s32Y       = 0;
    stLayerAttr.stDispRect.u32Width   = u32Width;
    stLayerAttr.stDispRect.u32Height  = u32Height;
    stLayerAttr.stImageSize.u32Width  = u32Width;
    stLayerAttr.stImageSize.u32Height = u32Height;

    s32Ret = HI_MPI_VO_SetVideoLayerAttr(voDev, &stLayerAttr);
    if (s32Ret != HI_SUCCESS) {
        SAMPLE_PRT("HI_MPI_VO_SetVideoLayerAttr failed with 0x%#x!\n", s32Ret);
        return HI_FAILURE;
    }

    s32Ret = HI_MPI_VO_EnableVideoLayer(voDev);
    if (s32Ret != HI_SUCCESS) {
        SAMPLE_PRT("HI_MPI_VO_EnableVideoLayer failed with 0x%#x!\n", s32Ret);
        return HI_FAILURE;
    }

    for (i = 0; i < WIN_NUM; i++) {
        chn = i;

        //stChnAttr.stRect.s32X       = (i % 2) * u32Width / 2;
        //stChnAttr.stRect.s32Y       = (i / 2) * u32Height / 2;
        stChnAttr.stRect.s32X       = (u32Width / 2 * i / WIN_NUM) / 2 * 2;
        stChnAttr.stRect.s32Y       = (u32Height / 2 * i / WIN_NUM) / 2 * 2;
        stChnAttr.stRect.u32Width   = u32Width / 2;
        stChnAttr.stRect.u32Height  = u32Height / 2;
        stChnAttr.u32Priority       = i;
        stChnAttr.bDeflicker        = HI_FALSE;

        s32Ret = HI_MPI_VO_SetChnAttr(voDev, chn, &stChnAttr);
        if (s32Ret != HI_SUCCESS)
        {
            SAMPLE_PRT("HI_MPI_VO_SetChnAttr failed with %#x!\n", s32Ret);
        }

        s32Ret = HI_MPI_VO_EnableChn(voDev, chn);
        if (s32Ret != HI_SUCCESS)
        {
            SAMPLE_PRT("HI_MPI_VO_EnableChn failed with %#x!\n", s32Ret);
            return HI_FAILURE;
        }
    }

    return HI_SUCCESS;
}/*}}}*/

int startVo() {/*{{{*/
    HI_S32 s32Ret;
    VO_DEV voDev = VO_DHD0;
    VO_PUB_ATTR_S stVoPubAttr;
    VO_VIDEO_LAYER_ATTR_S stLayerAttr;
    VO_CHN_ATTR_S stChnAttr;
    HI_U32 u32Width = 1920;
    HI_U32 u32Height = 1080;

    stVoPubAttr.u32BgColor = 0x000000ff;
    stVoPubAttr.enIntfType = VO_INTF_BT1120;
    stVoPubAttr.enIntfSync = VO_OUTPUT_1080P50;
    stVoPubAttr.bDoubleFrame = HI_FALSE;
    s32Ret = HI_MPI_VO_SetPubAttr(voDev, &stVoPubAttr);
    if (s32Ret != HI_SUCCESS) {
        SAMPLE_PRT("HI_MPI_VO_SetPubAttr failed with 0x%#x!\n", s32Ret);
        return HI_FAILURE;
    }

    s32Ret = HI_MPI_VO_Enable(voDev);
    if (s32Ret != HI_SUCCESS) {
        SAMPLE_PRT("HI_MPI_VO_Enable failed with 0x%#x!\n", s32Ret);
        return HI_FAILURE;
    }

    stLayerAttr.enPixFormat = SAMPLE_PIXEL_FORMAT;
    stLayerAttr.u32DispFrmRt = 25;
    stLayerAttr.stDispRect.s32X       = 0;
    stLayerAttr.stDispRect.s32Y       = 0;
    stLayerAttr.stDispRect.u32Width   = u32Width;
    stLayerAttr.stDispRect.u32Height  = u32Height;
    stLayerAttr.stImageSize.u32Width  = u32Width;
    stLayerAttr.stImageSize.u32Height = u32Height;

    s32Ret = HI_MPI_VO_SetVideoLayerAttr(voDev, &stLayerAttr);
    if (s32Ret != HI_SUCCESS) {
        SAMPLE_PRT("HI_MPI_VO_SetVideoLayerAttr failed with 0x%#x!\n", s32Ret);
        return HI_FAILURE;
    }

    s32Ret = HI_MPI_VO_EnableVideoLayer(voDev);
    if (s32Ret != HI_SUCCESS) {
        SAMPLE_PRT("HI_MPI_VO_EnableVideoLayer failed with 0x%#x!\n", s32Ret);
        return HI_FAILURE;
    }

    stChnAttr.stRect.s32X       = 0;
    stChnAttr.stRect.s32Y       = 0;
    stChnAttr.stRect.u32Width   = u32Width;
    stChnAttr.stRect.u32Height  = u32Height;
    stChnAttr.u32Priority       = 0;
    stChnAttr.bDeflicker        = HI_FALSE;

    s32Ret = HI_MPI_VO_SetChnAttr(voDev, 0, &stChnAttr);
    if (s32Ret != HI_SUCCESS)
    {
        SAMPLE_PRT("HI_MPI_VO_SetChnAttr failed with 0x%#x!\n", s32Ret);
    }

    s32Ret = HI_MPI_VO_EnableChn(voDev, 0);
    if (s32Ret != HI_SUCCESS)
    {
        SAMPLE_PRT("HI_MPI_VO_EnableChn failed with 0x%#x!\n", s32Ret);
        return HI_FAILURE;
    }

    return HI_SUCCESS;
}/*}}}*/

int bindVo() {/*{{{*/
    HI_S32 s32Ret;

    // virtual vo -> vo
    MPP_CHN_S stSrcChn;
    MPP_CHN_S stDestChn;

    stSrcChn.enModId = HI_ID_VOU;
    stSrcChn.s32DevId = VO_VIRT;
    stSrcChn.s32ChnId = 0;

    stDestChn.enModId = HI_ID_VOU;
    stDestChn.s32DevId = VO_DHD0;
    stDestChn.s32ChnId = 0;

    s32Ret = HI_MPI_SYS_Bind(&stSrcChn, &stDestChn);
    if (s32Ret != HI_SUCCESS) {
        SAMPLE_PRT("HI_MPI_SYS_Bind failed with 0x%#x!\n", s32Ret);
        return HI_FAILURE;
    }

    return HI_SUCCESS;
}/*}}}*/

int startVdec() {/*{{{*/
    VDEC_CHN_ATTR_S stAttr;
    VDEC_PRTCL_PARAM_S stPrtclParam;
    HI_S32 s32Ret;
    HI_U32 u32Width = 1920;
    HI_U32 u32Height = 1080;
    HI_S32 s32ChnID = 0;
    int i;

    memset(&stAttr, 0, sizeof(VDEC_CHN_ATTR_S));

    stAttr.enType = PT_JPEG;
    stAttr.u32BufSize = u32Width * u32Height;
    stAttr.u32Priority = 1;//此处必须大于0
    stAttr.u32PicWidth = u32Width;
    stAttr.u32PicHeight = u32Height;
    stAttr.stVdecJpegAttr.enMode = VIDEO_MODE_FRAME;

    for (i = 0; i < WIN_NUM; i++) {
        s32ChnID = i;

        s32Ret = HI_MPI_VDEC_CreateChn(s32ChnID, &stAttr);
        if (HI_SUCCESS != s32Ret) {
            SAMPLE_PRT("HI_MPI_VDEC_CreateChn failed with 0x%#x \n", s32Ret);
            return s32Ret;
        }

        s32Ret = HI_MPI_VDEC_GetPrtclParam(s32ChnID, &stPrtclParam);
        if (HI_SUCCESS != s32Ret) {
            SAMPLE_PRT("HI_MPI_VDEC_GetPrtclParam failed errno 0x%#x \n", s32Ret);
            return s32Ret;
        }

        stPrtclParam.s32MaxSpsNum = 21;
        stPrtclParam.s32MaxPpsNum = 22;
        stPrtclParam.s32MaxSliceNum = 100;
        s32Ret = HI_MPI_VDEC_SetPrtclParam(s32ChnID, &stPrtclParam);
        if (HI_SUCCESS != s32Ret) {
            SAMPLE_PRT("HI_MPI_VDEC_SetPrtclParam failed errno 0x%#x \n", s32Ret);
            return s32Ret;
        }

        s32Ret = HI_MPI_VDEC_StartRecvStream(s32ChnID);
        if (HI_SUCCESS != s32Ret) {
            SAMPLE_PRT("HI_MPI_VDEC_StartRecvStream failed errno 0x%#x \n", s32Ret);
            return s32Ret;
        }
    }

    return HI_SUCCESS;
}/*}}}*/

int bindVdec() {/*{{{*/
    HI_S32 s32Ret;
    int i;

    // vdec -> virtual vo
    MPP_CHN_S stSrcChn;
    MPP_CHN_S stDestChn;

    for (i = 0; i < WIN_NUM; i++) {
        stSrcChn.enModId = HI_ID_VDEC;
        stSrcChn.s32DevId = 0;
        stSrcChn.s32ChnId = i;

        stDestChn.enModId = HI_ID_VOU;
        stDestChn.s32DevId = VO_VIRT;
        stDestChn.s32ChnId = i;

        s32Ret = HI_MPI_SYS_Bind(&stSrcChn, &stDestChn);
        if (s32Ret != HI_SUCCESS) {
            SAMPLE_PRT("HI_MPI_SYS_Bind failed with %#x!\n", s32Ret);
            return HI_FAILURE;
        }
    }

    return HI_SUCCESS;
}/*}}}*/

void decodeProcess() {/*{{{*/
    threadParam.bRun = HI_FALSE;

    // create thread
    pthread_create(&threadParam.pid, NULL, decodeJpeg, &threadParam);

    // join thread
    pthread_join(threadParam.pid, NULL);

    printf("press two enter to quit!\n");
    getchar();
    getchar();
}/*}}}*/

void* decodeJpeg(void *pParam) {/*{{{*/
    //ThreadParam* pThreadParam = (ThreadParam*)pParam;
    FILE* fp = NULL;
    char szFile[] = "test.jpg";
    VDEC_STREAM_S stStream;
    HI_U8 buf[1920*1080*2];
    int readLen;
    HI_S32 s32Ret;
    int i;

    fp = fopen(szFile, "rb");
    if (NULL == fp) {
        SAMPLE_PRT("can't open file %s\n", szFile);
        return (void*)(HI_FAILURE);
    }

    readLen = fread(buf, 1, sizeof(buf), fp);
    fclose(fp);

    if (readLen <= 0) {
        SAMPLE_PRT("can't read file %s\n", szFile);
    }

    stStream.u64PTS  = 0;
    stStream.pu8Addr = buf;
    stStream.u32Len  = readLen;

    for (i = 0; i < WIN_NUM; i++) {
        s32Ret = HI_MPI_VDEC_SendStream(i, &stStream, HI_IO_BLOCK);
        if (s32Ret != HI_SUCCESS) {
            SAMPLE_PRT("HI_MPI_VDEC_SendStream failed with %#x!\n", s32Ret);
            return (void*)(HI_FAILURE);
        }
    }

        fflush(stdout);

    return (void*)(HI_SUCCESS);
}/*}}}*/

int stopVdec() {/*{{{*/
    HI_S32 s32Ret;
    HI_S32 s32ChnID = 0;
    int i;

    for (i = 0; i < WIN_NUM; i++) {
        s32ChnID = i;
        s32Ret = HI_MPI_VDEC_StopRecvStream(s32ChnID);
        if (s32Ret != HI_SUCCESS) {
            SAMPLE_PRT("HI_MPI_VDEC_StopRecvStream failed errno 0x%x\n", s32Ret);
            return HI_FAILURE;
        }

        s32Ret = HI_MPI_VDEC_DestroyChn(s32ChnID);
        if (HI_SUCCESS != s32Ret) {
            SAMPLE_PRT("HI_MPI_VDEC_DestroyChn failed errno 0x%x \n", s32Ret);
            return HI_FAILURE;
        }
    }

    return HI_SUCCESS;
}/*}}}*/

int unbindVdec() {/*{{{*/
    HI_S32 s32Ret;
    int i;

    // vdec -> virtual vo
    MPP_CHN_S stSrcChn;
    MPP_CHN_S stDestChn;

    for (i = 0; i < WIN_NUM; i++) {
        stSrcChn.enModId = HI_ID_VDEC;
        stSrcChn.s32DevId = 0;
        stSrcChn.s32ChnId = i;

        stDestChn.enModId = HI_ID_VOU;
        stDestChn.s32DevId = VO_VIRT;
        stDestChn.s32ChnId = i;

        s32Ret = HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn);
        if (s32Ret != HI_SUCCESS) {
            SAMPLE_PRT("HI_MPI_SYS_UnBind failed with %#x!\n", s32Ret);
            return HI_FAILURE;
        }
    }

    return HI_SUCCESS;
}/*}}}*/

int stopVirtualVo() {/*{{{*/
    HI_S32 s32Ret;
    int i;

    for (i = 0; i < WIN_NUM; i++) {
        s32Ret = HI_MPI_VO_DisableChn(VO_VIRT, i);
        if (s32Ret != HI_SUCCESS) {
            SAMPLE_PRT("HI_MPI_VO_DisableChn failed with %#x!\n", s32Ret);
            return HI_FAILURE;
        }
    }

    return HI_SUCCESS;
}/*}}}*/

int stopVo() {/*{{{*/
    HI_S32 s32Ret;

    s32Ret = HI_MPI_VO_DisableChn(VO_DHD0, 0);
    if (s32Ret != HI_SUCCESS) {
        SAMPLE_PRT("HI_MPI_VO_DisableChn failed with %#x!\n", s32Ret);
        return HI_FAILURE;
    }

    return HI_SUCCESS;
}/*}}}*/

int unbindVo() {/*{{{*/
    HI_S32 s32Ret;
    VO_DEV voDev = VO_VIRT;

    // virtual vo -> vo
    MPP_CHN_S stSrcChn;
    MPP_CHN_S stDestChn;

    stSrcChn.enModId = HI_ID_VOU;
    stSrcChn.s32DevId = VO_VIRT;
    stSrcChn.s32ChnId = 0;

    stDestChn.enModId = HI_ID_VOU;
    stDestChn.s32DevId = VO_DHD0;
    stDestChn.s32ChnId = 0;

    s32Ret = HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn);
    if (s32Ret != HI_SUCCESS) {
        SAMPLE_PRT("HI_MPI_SYS_UnBind failed with 0x%#x!\n", s32Ret);
        return HI_FAILURE;
    }

    return HI_SUCCESS;
}/*}}}*/

void sysExit() {/*{{{*/
    HI_MPI_SYS_Exit();
    HI_MPI_VB_Exit();
    return;
}/*}}}*/


#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */

// vim:set ts=4 sw=4 et fenc=utf-8 fdm=marker:
[/code]

kennybluezy

0个粉丝

16

问答

0

专栏

0

资料

kennybluezy 2016-06-07 15:30:55
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=31257&ptid=11048]jerrylipeng 发表于 2016-6-7 15:29[/url]
附件怎么不能上传.c文件啊,好麻烦
这是我的代码,看看对你有帮助吗[/quote]

OK.非常感谢你的热心帮助!!!

lzx0302564

0个粉丝

1

问答

0

专栏

0

资料

lzx0302564 2016-08-16 21:21:57
认可0
虚拟vo不需要通过vpss与vdec绑定吗?我只能拼接4通道图像,多了就有问题

jerrylipeng

1个粉丝

11

问答

0

专栏

0

资料

jerrylipeng 2016-08-17 08:33:05
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=36205&ptid=11048]lzx0302564 发表于 2016-8-16 21:21[/url]
虚拟vo不需要通过vpss与vdec绑定吗?我只能拼接4通道图像,多了就有问题[/quote]

虚拟VO相当于SD VO,不一定需要过VPSS

我也只实验了4画面,好像虚拟VO的性能也不是很高,多了确实可能有问题吧。

9crk

1个粉丝

34

问答

0

专栏

6

资料

9crk 2016-09-08 12:29:21
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=28732&ptid=11048]zhuangweiye 发表于 2016-4-19 17:35[/url]
VPSS mode的问题是这样的

VPSS处理图像的尺寸 有输入和输出
[/quote]

大神威武!

fishcrane

0个粉丝

9

问答

0

专栏

0

资料

fishcrane 2016-10-28 15:56:14
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=31252&ptid=11048]jerrylipeng 发表于 2016-6-7 13:47[/url]
我能确认虚拟VO支持1080P,我在实际板上已经验证过了。

我虚拟VO直接绑定VO就输出显示了,而且两个都 ...[/quote]

虚拟vo怎么直接绑定到输出的?为什么我绑定的就不能输出显示呢,能否给解惑一下?代码如
HI_S32 s32Ret = HI_SUCCESS;
    MPP_CHN_S stSrcChn;
    MPP_CHN_S stDestChn;

    stSrcChn.enModId = HI_ID_VOU;
    stSrcChn.s32DevId = VirLayer;
    stSrcChn.s32ChnId = VirChn;

    stDestChn.enModId = HI_ID_VOU;
    stDestChn.s32DevId = VoLayer;
    stDestChn.s32ChnId = VoChn;

    s32Ret = HI_MPI_SYS_Bind(&stSrcChn, &stDestChn);
    if (s32Ret != HI_SUCCESS)
    {
        SAMPLE_PRT("failed with %#x!\n", s32Ret);
        return HI_FAILURE;
    }

    return s32Ret;
加载中···
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
+ 添加网盘链接/附件

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
相关问答
无更多相似问答 去提问
举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

易百纳技术社区