永清

永清

0个粉丝

2

问答

0

专栏

0

资料

永清  发布于  2021-06-16 13:43:20
采纳率 0%
2个问答
2799

程序运行不报错,osd贴的图片不显示

   

哪位大神帮忙给瞅瞅,看是哪里出错了。程序运行也不报错,就是osd贴的图片就是不显示。

HI_S32 SampleVoLoadRgnBmp(const char *filename, BITMAP_S *pstBitmap, HI_BOOL bFil, HI_U32 u16FilColor)
{
    OSD_SURFACE_S Surface;
    OSD_BITMAPFILEHEADER bmpFileHeader;
    OSD_BITMAPINFO bmpInfo;

    if (GetBmpInfo(filename, &bmpFileHeader, &bmpInfo) < 0)
    {
        printf("GetBmpInfo err!\n");
        return HI_FAILURE;
    }

    Surface.enColorFmt = OSD_COLOR_FMT_RGB1555;

    pstBitmap->pData = malloc(2 * (bmpInfo.bmiHeader.biWidth) * (bmpInfo.bmiHeader.biHeight));

    if (NULL == pstBitmap->pData)
    {
        printf("malloc osd memroy err!\n");
        return HI_FAILURE;
    }
    CreateSurfaceByBitMap(filename, &Surface, (HI_U8 *)(pstBitmap->pData));

    pstBitmap->u32Width = Surface.u16Width;
    pstBitmap->u32Height = Surface.u16Height;
    pstBitmap->enPixelFormat = PIXEL_FORMAT_ARGB_1555;

    int i, j;
    HI_U16 *pu16Temp;
    pu16Temp = (HI_U16 *)pstBitmap->pData;

    if (bFil)
    {
        for (i = 0; i < pstBitmap->u32Height; i++)
        {
            for (j = 0; j < pstBitmap->u32Width; j++)
            {
                if (u16FilColor == *pu16Temp)
                {
                    *pu16Temp &= 0x7FFF;
                }
                pu16Temp++;
            }
        }
    }

    return HI_SUCCESS;
}

HI_S32 SampleVoChnCreateRegion(HI_S32 Chn)
{
    HI_S32 s32Ret;
    MPP_CHN_S stChn;
    RGN_ATTR_S stRgnAttr;
    RGN_CHN_ATTR_S stChnAttr;
    BITMAP_S stBitmap;

    /* creat region*/
    stRgnAttr.enType = OVERLAYEX_RGN;
    stRgnAttr.unAttr.stOverlayEx.enPixelFmt = PIXEL_FORMAT_ARGB_1555;
    stRgnAttr.unAttr.stOverlayEx.stSize.u32Width = 64;  //128;
    stRgnAttr.unAttr.stOverlayEx.stSize.u32Height = 64; //128;
    stRgnAttr.unAttr.stOverlayEx.u32BgColor = 0x0000ffff;
    stRgnAttr.unAttr.stOverlayEx.u32CanvasNum = 2;

    RGN_HANDLE Handle = 0;
    s32Ret = HI_MPI_RGN_Create(Handle, &stRgnAttr);
    if (s32Ret != HI_SUCCESS)
    {
        printf("region of chn %d create fail. value=0x%x.", Handle, s32Ret);
        return s32Ret;
    }

    /*attach region to chn*/
    stChn.enModId = HI_ID_VPSS;
    stChn.s32DevId = 1;
    stChn.s32ChnId = Chn;

    memset(&stChnAttr, 0, sizeof(stChnAttr));
    stChnAttr.bShow = HI_TRUE;
    stChnAttr.enType = OVERLAYEX_RGN;
    stChnAttr.unChnAttr.stOverlayExChn.stPoint.s32X = 0; //128;
    stChnAttr.unChnAttr.stOverlayExChn.stPoint.s32Y = 0; //128;
    stChnAttr.unChnAttr.stOverlayExChn.u32BgAlpha = 64;
    stChnAttr.unChnAttr.stOverlayExChn.u32FgAlpha = 64;
    stChnAttr.unChnAttr.stOverlayExChn.u32Layer = 0;

    s32Ret = HI_MPI_RGN_AttachToChn(Handle, &stChn, &stChnAttr);
    if (s32Ret != HI_SUCCESS)
    {
        printf("region attach to chn %d fail. value=0x%x.", Chn, s32Ret);
        return s32Ret;
    }

    /* load bitmap*/
    s32Ret = SampleVoLoadRgnBmp("/nfsroot/res/mm2.bmp", &stBitmap, HI_FALSE, 0);
    if (s32Ret != HI_SUCCESS)
    {
        return s32Ret;
    }

    s32Ret = HI_MPI_RGN_SetBitMap(Chn, &stBitmap);
    if (s32Ret != HI_SUCCESS)
    {
        printf("region set bitmap to  chn %d fail. value=0x%x.", Chn, s32Ret);
        free(stBitmap.pData);
        return s32Ret;
    }
    // free(stBitmap.pData);

    s32Ret = HI_MPI_RGN_SetDisplayAttr(Handle, &stChn, &stChnAttr);
    if (s32Ret != HI_SUCCESS)
    {
        printf("HI_MPI_RGN_SetDisplayAttr fail.\n");
        return s32Ret;
    }

    return HI_SUCCESS;
}

HI_S32 SAMPLE_H265_VDEC_VPSS_VO(HI_VOID)
{
    VB_CONFIG_S stVbConfig;
    HI_S32 i, s32Ret = HI_SUCCESS;
    VDEC_THREAD_PARAM_S stVdecSend[VDEC_MAX_CHN_NUM];
    SIZE_S stDispSize;
    VO_LAYER VoLayer;
    HI_U32 u32VdecChnNum, VpssGrpNum;
    VPSS_GRP VpssGrp;
    pthread_t VdecThread[2 * VDEC_MAX_CHN_NUM];
    PIC_SIZE_E enDispPicSize;
    SAMPLE_VDEC_ATTR astSampleVdec[VDEC_MAX_CHN_NUM];
    VPSS_CHN_ATTR_S astVpssChnAttr[VPSS_MAX_CHN_NUM];
    SAMPLE_VO_CONFIG_S stVoConfig;
    VPSS_GRP_ATTR_S stVpssGrpAttr;
    HI_BOOL abChnEnable[VPSS_MAX_CHN_NUM];
    VO_INTF_SYNC_E enIntfSync;
    VPSS_MOD_PARAM_S stModParam;

    u32VdecChnNum = 1;
    VpssGrpNum = u32VdecChnNum;
    /************************************************
    step1:  init SYS, init common VB(for VPSS and VO)
    *************************************************/

    if (VO_OUTPUT_3840x2160_30 == g_enIntfSync)
    {
        enDispPicSize = PIC_3840x2160;
        enIntfSync = VO_OUTPUT_3840x2160_30;
    }
    else
    {
        enDispPicSize = PIC_1080P;
        enIntfSync = VO_OUTPUT_1080P60;
    }

    s32Ret = SAMPLE_COMM_SYS_GetPicSize(enDispPicSize, &stDispSize);
    if (s32Ret != HI_SUCCESS)
    {
        SAMPLE_PRT("sys get pic size fail for %#x!\n", s32Ret);
        goto END1;
    }

    memset(&stVbConfig, 0, sizeof(VB_CONFIG_S));
    stVbConfig.u32MaxPoolCnt = 1;
    stVbConfig.astCommPool[0].u32BlkCnt = 10 * u32VdecChnNum;
    stVbConfig.astCommPool[0].u64BlkSize = COMMON_GetPicBufferSize(stDispSize.u32Width, stDispSize.u32Height,
                                                                   PIXEL_FORMAT_YVU_SEMIPLANAR_420, DATA_BITWIDTH_10, COMPRESS_MODE_SEG, 0);
    s32Ret = SAMPLE_COMM_SYS_Init(&stVbConfig);
    if (s32Ret != HI_SUCCESS)
    {
        SAMPLE_PRT("init sys fail for %#x!\n", s32Ret);
        goto END1;
    }

    /************************************************
    step2:  init module VB or user VB(for VDEC)
    *************************************************/
    for (i = 0; i < u32VdecChnNum; i++)
    {
        astSampleVdec[i].enType = PT_H265;
        astSampleVdec[i].u32Width = 3840;
        astSampleVdec[i].u32Height = 2160;
        astSampleVdec[i].enMode = VIDEO_MODE_FRAME;
        astSampleVdec[i].stSapmleVdecVideo.enDecMode = VIDEO_DEC_MODE_IP;
        astSampleVdec[i].stSapmleVdecVideo.enBitWidth = DATA_BITWIDTH_10;
        astSampleVdec[i].stSapmleVdecVideo.u32RefFrameNum = 3;
        astSampleVdec[i].u32DisplayFrameNum = 2;
        astSampleVdec[i].u32FrameBufCnt = astSampleVdec[i].stSapmleVdecVideo.u32RefFrameNum + astSampleVdec[i].u32DisplayFrameNum + 1;
    }
    s32Ret = SAMPLE_COMM_VDEC_InitVBPool(u32VdecChnNum, &astSampleVdec[0]);
    if (s32Ret != HI_SUCCESS)
    {
        SAMPLE_PRT("init mod common vb fail for %#x!\n", s32Ret);
        goto END2;
    }

    /************************************************
    step3:  start VDEC
    *************************************************/
    s32Ret = SAMPLE_COMM_VDEC_Start(u32VdecChnNum, &astSampleVdec[0]);
    if (s32Ret != HI_SUCCESS)
    {
        SAMPLE_PRT("start VDEC fail for %#x!\n", s32Ret);
        goto END3;
    }

    /************************************************
    step4:  start VPSS
    *************************************************/
    s32Ret = HI_MPI_VPSS_GetModParam(&stModParam);
    if (s32Ret != HI_SUCCESS)
    {
        SAMPLE_PRT("Get VPSS module param fali %#x!\n", s32Ret);
        goto END4;
    }

    stModParam.bHdrSupport = HI_TRUE;

    s32Ret = HI_MPI_VPSS_SetModParam(&stModParam);
    if (s32Ret != HI_SUCCESS)
    {
        SAMPLE_PRT("Set VPSS module param fali %#x!\n", s32Ret);
        goto END4;
    }

    stVpssGrpAttr.u32MaxW = 3840;
    stVpssGrpAttr.u32MaxH = 2160;
    stVpssGrpAttr.stFrameRate.s32SrcFrameRate = -1;
    stVpssGrpAttr.stFrameRate.s32DstFrameRate = -1;
    stVpssGrpAttr.enDynamicRange = DYNAMIC_RANGE_HDR10;
    stVpssGrpAttr.enPixelFormat = PIXEL_FORMAT_YVU_SEMIPLANAR_420;
    stVpssGrpAttr.bNrEn = HI_FALSE;
    memset(abChnEnable, 0, sizeof(abChnEnable));
    abChnEnable[0] = HI_TRUE;
    astVpssChnAttr[0].u32Width = stDispSize.u32Width;
    astVpssChnAttr[0].u32Height = stDispSize.u32Height;
    astVpssChnAttr[0].enChnMode = VPSS_CHN_MODE_AUTO;
    astVpssChnAttr[0].enCompressMode = COMPRESS_MODE_SEG;
    astVpssChnAttr[0].enDynamicRange = DYNAMIC_RANGE_HDR10;
    astVpssChnAttr[0].enPixelFormat = PIXEL_FORMAT_YVU_SEMIPLANAR_420;
    astVpssChnAttr[0].stFrameRate.s32SrcFrameRate = -1;
    astVpssChnAttr[0].stFrameRate.s32DstFrameRate = -1;
    astVpssChnAttr[0].u32Depth = 0;
    astVpssChnAttr[0].bMirror = HI_FALSE;
    astVpssChnAttr[0].bFlip = HI_FALSE;
    astVpssChnAttr[0].stAspectRatio.enMode = ASPECT_RATIO_NONE;
    astVpssChnAttr[0].enVideoFormat = VIDEO_FORMAT_LINEAR;
    for (i = 0; i < u32VdecChnNum; i++)
    {
        VpssGrp = i;
        s32Ret = SAMPLE_COMM_VPSS_Start(VpssGrp, &abChnEnable[0], &stVpssGrpAttr, &astVpssChnAttr[0]);

        if (s32Ret != HI_SUCCESS)
        {
            SAMPLE_PRT("start VPSS fail for %#x!\n", s32Ret);
            goto END4;
        }
    }

    /************************************************
    step5:  start VO
    *************************************************/
    stVoConfig.VoDev = SAMPLE_VO_DEV_UHD;
    stVoConfig.enVoIntfType = VO_INTF_HDMI;
    stVoConfig.enIntfSync = enIntfSync;
    stVoConfig.enPicSize = enDispPicSize;
    stVoConfig.u32BgColor = COLOR_RGB_BLUE;
    stVoConfig.u32DisBufLen = 3;
    stVoConfig.enDstDynamicRange = DYNAMIC_RANGE_HDR10;
    stVoConfig.enVoMode = VO_MODE_1MUX;
    stVoConfig.enPixFormat = PIXEL_FORMAT_YVU_SEMIPLANAR_420;
    stVoConfig.stDispRect.s32X = 0;
    stVoConfig.stDispRect.s32Y = 0;
    stVoConfig.stDispRect.u32Width = stDispSize.u32Width;
    stVoConfig.stDispRect.u32Height = stDispSize.u32Height;
    stVoConfig.stImageSize.u32Width = stDispSize.u32Width;
    stVoConfig.stImageSize.u32Height = stDispSize.u32Height;
    stVoConfig.enVoPartMode = VO_PART_MODE_SINGLE;

    s32Ret = SAMPLE_COMM_VO_StartVO(&stVoConfig);
    if (s32Ret != HI_SUCCESS)
    {
        SAMPLE_PRT("start VO fail for %#x!\n", s32Ret);
        goto END5;
    }

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

    /************************************************
    step7:  VPSS bind VO
    *************************************************/
    VoLayer = stVoConfig.VoDev;
    for (i = 0; i < VpssGrpNum; i++)
    {
        s32Ret = SAMPLE_COMM_VPSS_Bind_VO(i, 0, VoLayer, i);
        if (s32Ret != HI_SUCCESS)
        {
            SAMPLE_PRT("vpss bind vo fail for %#x!\n", s32Ret);
            goto END7;
        }
    }

    /************************************************
    step8:  send stream to VDEC
    *************************************************/
    for (i = 0; i < u32VdecChnNum; i++)
    {
        snprintf(stVdecSend[i].cFileName, sizeof(stVdecSend[i].cFileName), "3840x2160_10bit.h265");
        snprintf(stVdecSend[i].cFilePath, sizeof(stVdecSend[i].cFilePath), "%s", SAMPLE_STREAM_PATH);
        stVdecSend[i].enType = astSampleVdec[i].enType;
        stVdecSend[i].s32StreamMode = astSampleVdec[i].enMode;
        stVdecSend[i].s32ChnId = i;
        stVdecSend[i].s32IntervalTime = 1000;
        stVdecSend[i].u64PtsInit = 0;
        stVdecSend[i].u64PtsIncrease = 0;
        stVdecSend[i].eThreadCtrl = THREAD_CTRL_START;
        stVdecSend[i].bCircleSend = HI_TRUE;
        stVdecSend[i].s32MilliSec = 0;
        stVdecSend[i].s32MinBufSize = (astSampleVdec[i].u32Width * astSampleVdec[i].u32Height * 3) >> 1;
    }
    SAMPLE_COMM_VDEC_StartSendStream(u32VdecChnNum, &stVdecSend[0], &VdecThread[0]);

    /************************************************
    step9:  add OSD to VO chan
    *************************************************/

    printf("OSD starting ... \n");

    HI_S32 Chn = 0;
    s32Ret = SampleVoChnCreateRegion(Chn);
    if (s32Ret != HI_SUCCESS)
    {
        printf("chn %d SampleVoChnCreateRegion err, value = 0x%x. \n", Chn, s32Ret);
        goto END7;
    }

    /************************************************
    step10:  wait command to stop the stream
    *************************************************/

    SAMPLE_COMM_VDEC_CmdCtrl(u32VdecChnNum, &stVdecSend[0], &VdecThread[0]);

    SAMPLE_COMM_VDEC_StopSendStream(u32VdecChnNum, &stVdecSend[0], &VdecThread[0]);

END7:
    for (i = 0; i < VpssGrpNum; i++)
    {
        s32Ret = SAMPLE_COMM_VPSS_UnBind_VO(i, 0, VoLayer, i);
        if (s32Ret != HI_SUCCESS)
        {
            SAMPLE_PRT("vpss unbind vo fail for %#x!\n", s32Ret);
        }
    }
    printf("OSD ending ... ");

END6:
    for (i = 0; i < u32VdecChnNum; i++)
    {
        s32Ret = SAMPLE_COMM_VDEC_UnBind_VPSS(i, i);
        if (s32Ret != HI_SUCCESS)
        {
            SAMPLE_PRT("vdec unbind vpss fail for %#x!\n", s32Ret);
        }
    }

END5:
    SAMPLE_COMM_VO_StopVO(&stVoConfig);

END4:
    for (i = VpssGrp; i >= 0; i--)
    {
        VpssGrp = i;
        SAMPLE_COMM_VPSS_Stop(VpssGrp, &abChnEnable[0]);
    }
END3:
    SAMPLE_COMM_VDEC_Stop(u32VdecChnNum);

END2:
    SAMPLE_COMM_VDEC_ExitVBPool();

END1:
    SAMPLE_COMM_SYS_Exit();

    return s32Ret;
}
我来回答
回答4个
时间排序
认可量排序

永清

0个粉丝

2

问答

0

专栏

0

资料

永清 2021-06-16 14:46:44
认可0

板子是Hi3559aV100

永清

0个粉丝

2

问答

0

专栏

0

资料

永清 2021-06-17 07:33:06
认可0

venc_sample可以正常加,但是vdec_sample就出问题了。大致定位了问题:通道Chn或者deviceId给的不对,或者是VO绑定的通道加不了,后面有时间再来还愿。。。

永清

0个粉丝

2

问答

0

专栏

0

资料

永清 2021-06-17 07:34:22
认可0

醉藻

33个粉丝

0

问答

2

专栏

128

资料

醉藻 2023-01-30 23:10:53
认可0

VDEC->VPSS->VO

或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币

Markdown 语法

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

Markdown 语法

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

举报类型

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

详细说明

易百纳技术社区