myearth

myearth

0个粉丝

3

问答

0

专栏

3

资料

myearth  发布于  2020-09-07 10:29:51
采纳率 0%
3个问答
2561

视频解码输出显示和UI叠加问题(QT)

   
我现在用VDEC和hifb的demo结合起来的demo;让视频解码输出和QT图像叠加起来;叠加没问题;一运行QT;解码就停止了,请大师帮指点一下,非常感谢!
代码如下:

static VO_DEV VoDev = SAMPLE_VO_DEV_DHD0;
static HI_CHAR gs_cExitFlag = 0;


static struct fb_bitfield s_a32 = {24,8,0};
static struct fb_bitfield s_r32 = {16,8,0};
static struct fb_bitfield s_g32 = {8,8,0};
static struct fb_bitfield s_b32 = {0,8,0};

#define WIDTH                  1280
#define HEIGHT                 800


#define GRAPHICS_LAYER_HC0 2
#define GRAPHICS_LAYER_G0  0
#define GRAPHICS_LAYER_G1  1

typedef struct hiPTHREAD_HIFB_SAMPLE
{
    HI_S32 fd;
    HI_S32 layer;
    HI_S32 ctrlkey;
}PTHREAD_HIFB_SAMPLE_INFO;


VdecThreadParam stVdecSend[VDEC_MAX_CHN_NUM];
HI_S32 SAMPLE_HIFB_OneBufMode(HI_VOID)
{
    HI_S32 i,s32Ret = HI_SUCCESS;

    PTHREAD_HIFB_SAMPLE_INFO stInfo0;
    SIZE_S  stSize;

    VO_LAYER VoLayer = 0;
    VO_PUB_ATTR_S stPubAttr;
    VO_VIDEO_LAYER_ATTR_S stLayerAttr;
    HI_U32 u32VoFrmRate;
    HI_CHAR file[12] = "/dev/fb0";
    VB_CONF_S       stVbConf;

    HIFB_ALPHA_S stAlpha;
    HIFB_COLORKEY_S stColorKey;
    VO_DEV VoDev;

    VoDev = SAMPLE_VO_DEV_DHD0;
    HI_BOOL bShow;
    HIFB_POINT_S stPoint = {0};
    HIFB_LAYER_INFO_S stLayerInfo = {0};
    struct fb_var_screeninfo stVarInfo;
//=====================================

    VB_CONF_S  stModVbConf;
    VDEC_CHN_ATTR_S stVdecChnAttr[VDEC_MAX_CHN_NUM];
    VdecThreadParam stVdecSend[VDEC_MAX_CHN_NUM];
    VPSS_GRP_ATTR_S stVpssGrpAttr[VDEC_MAX_CHN_NUM];
    SIZE_S  stRotateSize;

    HI_U32 u32VdCnt = 1, u32GrpCnt = 1;
    pthread_t   VdecThread[2*VDEC_MAX_CHN_NUM];

    stSize.u32Width = 1280;
    stSize.u32Height = 800;
    /************************************************
       step1:  init SYS and common VB
    *************************************************/
    SAMPLE_COMM_VDEC_Sysconf(&stVbConf, &stSize);
    s32Ret = SAMPLE_COMM_SYS_Init(&stVbConf);
    if(s32Ret != HI_SUCCESS)
    {
        SAMPLE_PRT("init sys fail for %#x!\n", s32Ret);
        goto SAMPLE_HIFB_OneBufMode_0;
    }

    /************************************************
       step2:  init mod common VB
    *************************************************/
    SAMPLE_COMM_VDEC_ModCommPoolConf(&stModVbConf, PT_H264, &stSize, u32VdCnt);
    s32Ret = SAMPLE_COMM_VDEC_InitModCommVb(&stModVbConf);
    if(s32Ret != HI_SUCCESS)
    {
        SAMPLE_PRT("init mod common vb fail for %#x!\n", s32Ret);
        goto SAMPLE_HIFB_OneBufMode_0;
    }

    /************************************************
    step3:  start VDEC
    *************************************************/
    SAMPLE_COMM_VDEC_ChnAttr(u32VdCnt, &stVdecChnAttr[0], PT_H264, &stSize);
    s32Ret = SAMPLE_COMM_VDEC_Start(u32VdCnt, &stVdecChnAttr[0]);
    if(s32Ret != HI_SUCCESS)
    {
        SAMPLE_PRT("start VDEC fail for %#x!\n", s32Ret);
        goto SAMPLE_HIFB_OneBufMode_0;
    }

    /************************************************
    step4:  start VPSS
    *************************************************/
    stRotateSize.u32Width = stRotateSize.u32Height = MAX2(stSize.u32Width, stSize.u32Height);
    SAMPLE_COMM_VDEC_VpssGrpAttr(u32GrpCnt, &stVpssGrpAttr[0], &stRotateSize);
    s32Ret = SAMPLE_COMM_VPSS_Start(u32GrpCnt, &stRotateSize, 1, &stVpssGrpAttr[0]);
    if(s32Ret != HI_SUCCESS)
    {
        SAMPLE_PRT("start VPSS fail for %#x!\n", s32Ret);
        goto SAMPLE_HIFB_OneBufMode_0;
    }

    /******************************************
     step 3:  start vo hd0.
    *****************************************/

    s32Ret = HI_MPI_VO_UnBindGraphicLayer(GRAPHICS_LAYER_HC0, VoDev);
    if (HI_SUCCESS != s32Ret)
    {
        SAMPLE_PRT("UnBindGraphicLayer failed with %d!\n", s32Ret);
         return HI_NULL;
    }

    s32Ret = HI_MPI_VO_BindGraphicLayer(GRAPHICS_LAYER_HC0, VoDev);
    if (HI_SUCCESS != s32Ret)
    {
        SAMPLE_PRT("BindGraphicLayer failed with %d!\n", s32Ret);
         return HI_NULL;
    }

    /******************************************
     step 3:  start vo hd0.
    *****************************************/
    stPubAttr.enIntfSync = VO_OUTPUT_1280x800_60;
    stPubAttr.enIntfType = VO_INTF_VGA;
    stPubAttr.u32BgColor = 0xff000000;

    s32Ret = SAMPLE_COMM_VO_GetWH(stPubAttr.enIntfSync,&stSize.u32Width,\
        &stSize.u32Height,&u32VoFrmRate);
    if (HI_SUCCESS != s32Ret)
    {
        SAMPLE_PRT("get vo wh failed with %d!\n", s32Ret);
        goto SAMPLE_HIFB_OneBufMode_0;
    }
    memcpy(&stLayerAttr.stImageSize,&stSize,sizeof(stSize));
    stLayerAttr.bClusterMode = HI_FALSE;
    stLayerAttr.bDoubleFrame = HI_FALSE;
    stLayerAttr.enPixFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420;
    stLayerAttr.u32DispFrmRt = 25 ;
    stLayerAttr.stDispRect.s32X = 0;
    stLayerAttr.stDispRect.s32Y = 0;
    stLayerAttr.stDispRect.u32Width = stSize.u32Width;
    stLayerAttr.stDispRect.u32Height = stSize.u32Height;
    VoDev = SAMPLE_VO_DEV_DHD0;
    VoLayer = SAMPLE_VO_LAYER_VHD0;

    s32Ret = SAMPLE_COMM_VO_StartDev(VoDev, &stPubAttr);
    if (HI_SUCCESS != s32Ret)
    {
        SAMPLE_PRT("start vo dev failed with %d!\n", s32Ret);
        goto SAMPLE_HIFB_OneBufMode_0;
    }

    s32Ret = SAMPLE_COMM_VO_GetWH(stPubAttr.enIntfSync, \
        &stLayerAttr.stDispRect.u32Width, &stLayerAttr.stDispRect.u32Height, &stLayerAttr.u32DispFrmRt);
    if (s32Ret != HI_SUCCESS)
    {
        SAMPLE_PRT("failed with %#x!\n", s32Ret);
        goto  SAMPLE_HIFB_OneBufMode_0;
    }

    s32Ret = SAMPLE_COMM_VO_StartLayer(VoLayer, &stLayerAttr);
    if(s32Ret != HI_SUCCESS)
    {
        SAMPLE_PRT("SAMPLE_COMM_VO_StartLayer fail for %#x!\n", s32Ret);
        goto SAMPLE_HIFB_OneBufMode_0;
    }

    s32Ret = SAMPLE_COMM_VO_StartChn(VoLayer, VO_MODE_1MUX);
    if(s32Ret != HI_SUCCESS)
    {
        SAMPLE_PRT("vdec bind vpss fail for %#x!\n", s32Ret);
        goto SAMPLE_HIFB_OneBufMode_0;
    }

    /************************************************
    step6:  VDEC bind VPSS
    *************************************************/
    for(i=0; i     {
        s32Ret = SAMPLE_COMM_VDEC_BindVpss(i, i);
        if(s32Ret != HI_SUCCESS)
        {
            SAMPLE_PRT("vdec bind vpss fail for %#x!\n", s32Ret);
            goto SAMPLE_HIFB_OneBufMode_0;
        }
    }

    /************************************************
    step7:  VPSS bind VO
    *************************************************/
    for(i=0; i     {
        s32Ret = SAMPLE_COMM_VO_BindVpss(VoLayer, i, i, VPSS_CHN0);
        if(s32Ret != HI_SUCCESS)
        {
            SAMPLE_PRT("vpss bind vo fail for %#x!\n", s32Ret);
            goto SAMPLE_HIFB_OneBufMode_0;
        }
    }

    /************************************************
    step8:  send stream to VDEC
    *************************************************/
    SAMPLE_COMM_VDEC_ThreadParam(u32VdCnt, &stVdecSend[0], &stVdecChnAttr[0], SAMPLE_1080P_H264_PATH);
    SAMPLE_COMM_VDEC_StartSendStream(u32VdCnt, &stVdecSend[0], &VdecThread[0]);

    /******************************************
     step 4:  start hifb.
    *****************************************/
    stInfo0.layer   =  0;
    stInfo0.fd      = -1;
    stInfo0.ctrlkey =  0;

    switch (stInfo0.layer)
    {
        case GRAPHICS_LAYER_G0:
            strcpy(file, "/dev/fb0");
            break;
        default:
            strcpy(file, "/dev/fb0");
            break;
    }

    /* 1. open framebuffer device overlay 0 */
    stInfo0.fd = open(file, O_RDWR, 0);
    if(stInfo0.fd < 0)
    {
        SAMPLE_PRT("open %s failed!\n",file);
        return HI_NULL;
    }
    /* 3.set alpha */
    stAlpha.bAlphaEnable = HI_TRUE;
    stAlpha.bAlphaChannel = HI_TRUE;
    stAlpha.u8Alpha0 = 0xff;
    stAlpha.u8Alpha1 = 0xff;
    stAlpha.u8GlobalAlpha = 0xff;

    if (ioctl(stInfo0.fd, FBIOPUT_ALPHA_HIFB,  &stAlpha) < 0)
    {
        printf("Set alpha failed!\n");
        close(stInfo0.fd);
        return HI_FALSE;
    }
    /*all layer surport colorkey*/
    stColorKey.bKeyEnable = HI_TRUE;
    stColorKey.u32Key = 0x0;
    if (ioctl(stInfo0.fd, FBIOPUT_COLORKEY_HIFB, &stColorKey) < 0)
    {
        SAMPLE_PRT("FBIOPUT_COLORKEY_HIFB!\n");
        close(stInfo0.fd);
        return HI_NULL;
    }
    s32Ret = ioctl(stInfo0.fd, FBIOGET_VSCREENINFO, &stVarInfo);
    if(s32Ret < 0)
    {
        SAMPLE_PRT("GET_VSCREENINFO failed!\n");
        close(stInfo0.fd);
        return HI_NULL;
    }

    if (ioctl(stInfo0.fd, FBIOPUT_SCREEN_ORIGIN_HIFB, &stPoint) < 0)
    {
        SAMPLE_PRT("set screen original show position failed!\n");
        close(stInfo0.fd);
        return HI_NULL;
    }

    stVarInfo.red = s_r32;
    stVarInfo.green = s_g32;
    stVarInfo.blue = s_b32;
    stVarInfo.transp = s_a32;
    stVarInfo.bits_per_pixel = 32;
    stVarInfo.xres=WIDTH;
    stVarInfo.yres=HEIGHT;
    stVarInfo.activate=FB_ACTIVATE_NOW;
    stVarInfo.xres_virtual=WIDTH;
    stVarInfo.yres_virtual = HEIGHT;
    stVarInfo.xoffset=0;
    stVarInfo.yoffset=0;

    s32Ret = ioctl(stInfo0.fd, FBIOPUT_VSCREENINFO, &stVarInfo);
    if(s32Ret < 0)
    {
        SAMPLE_PRT("PUT_VSCREENINFO failed!\n");
        close(stInfo0.fd);
        return HI_NULL;
    }
    switch (stInfo0.ctrlkey)
    {
        case 0 :
        {
            stLayerInfo.BufMode = HIFB_LAYER_BUF_ONE;
            stLayerInfo.u32Mask = HIFB_LAYERMASK_BUFMODE;
            break;
        }

        case 1 :
        {
            stLayerInfo.BufMode = HIFB_LAYER_BUF_DOUBLE;
            stLayerInfo.u32Mask = HIFB_LAYERMASK_BUFMODE;
            break;
        }

        default:
        {
            stLayerInfo.BufMode = HIFB_LAYER_BUF_NONE;
            stLayerInfo.u32Mask = HIFB_LAYERMASK_BUFMODE;
        }
    }
    s32Ret = ioctl(stInfo0.fd, FBIOPUT_LAYER_INFO, &stLayerInfo);
    if(s32Ret < 0)
    {
        SAMPLE_PRT("PUT_LAYER_INFO failed!\n");
        close(stInfo0.fd);
        return HI_NULL;
    }
    bShow = HI_TRUE;
    if (ioctl(stInfo0.fd, FBIOPUT_SHOW_HIFB, &bShow) < 0)
    {
        SAMPLE_PRT("FBIOPUT_SHOW_HIFB failed!\n");
        close(stInfo0.fd);
        return HI_NULL;
    }



     return s32Ret;

SAMPLE_HIFB_OneBufMode_2:
    HI_MPI_VO_DisableVideoLayer(VoLayer);
SAMPLE_HIFB_OneBufMode_1:
    HI_MPI_VO_Disable(VoDev);
SAMPLE_HIFB_OneBufMode_0:

    return s32Ret;
}
我来回答
回答0个
时间排序
认可量排序
易百纳技术社区暂无数据
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币

Markdown 语法

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

Markdown 语法

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

举报类型

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

详细说明

易百纳技术社区