Will

Will

0个粉丝

3

问答

0

专栏

0

资料

Will  发布于  2021-08-25 21:03:31
采纳率 34%
3个问答
2885

海思3559AV100 插入用户图片HI_MPI_VI_SetUserPic报错0xa0108003

   

在调试海思3559AV100,VI,VPSS工作在离线模式,当没有视频源输入时,插入一张显示没有输入的yuv420p用户图片,代码如下,在调用HI_MPI_VI_SetUserPic()时报错误码0xa0108003(视频输入参数设置无效),应该是这个结构体VI_USERPIC_ATTR配置错了,有经验的帮忙看下,我哪里配置错了,该怎么改?

HI_S32 insert_usr_pic(SAMPLE_VI_CONFIG_S* pstViConfig)
{
    HI_S32              s32Ret = HI_SUCCESS;
    HI_S32              i, j;
    HI_S32              s32ViNum;
    SAMPLE_SNS_TYPE_E    enSnsType;
    SAMPLE_VI_INFO_S    *pstViInfo = HI_NULL;
    VI_USERPIC_ATTR_S *pstVFrameInfo;
    HI_U32 u32LStride = 0;
    HI_U32 u32CStride = 0;
    HI_U32 u32LumaSize = 0;
    HI_U32 u32ChrmSize = 0;
    HI_U32 u32Size = 0;
    VB_BLK VbBlk;
    HI_U64 u64PhyAddr;
    HI_VOID *ppVirAddr;
    HI_U8  *p, *puv, *pu, *pv;
    FILE *fpic = NULL;
    HI_U32 u32Width = 1280;
    HI_U32 u32Height = 720;
    VI_PIPE_FRAME_SOURCE_E penSource;

    s32ViNum  = pstViConfig->as32WorkingViId[0];
    pstViInfo = &pstViConfig->astViInfo[s32ViNum];
    enSnsType    = pstViInfo->stSnsInfo.enSnsType;

    pstVFrameInfo = (VI_USERPIC_ATTR_S*)calloc(1, sizeof(VI_USERPIC_ATTR_S));

    if (SAMPLE_SNS_TYPE_BUTT == enSnsType)
    {
        u32LStride = (u32Width + 15) & ( ~(15) );
        u32LumaSize = (u32LStride * u32Height);
        u32ChrmSize = (u32CStride * u32Height) >> 2;/* 420*/
        u32Size = u32LumaSize + (u32ChrmSize << 1);

        /* get video buffer block form common pool */
        VbBlk = HI_MPI_VB_GetBlock(VB_INVALID_POOLID, u32Size, NULL);
        if (VB_INVALID_HANDLE == VbBlk)
        {
            SAMPLE_PRT("get YUV vb block failed\n");
            return HI_FAILURE;
        }

        /* get physical address*/
        u64PhyAddr = HI_MPI_VB_Handle2PhysAddr(VbBlk);
        if (0 == u64PhyAddr)
        {
            SAMPLE_PRT("get YUV vb block phy addr failed\n");
            return HI_FAILURE;
        }
        SAMPLE_PRT("u64PhyAddr: %#x\n", u64PhyAddr);

        /* get pool id */
        pstVFrameInfo->unUsrPic.stUsrPicFrm.u32PoolId = HI_MPI_VB_Handle2PoolId(VbBlk);
        if (VB_INVALID_POOLID == pstVFrameInfo->unUsrPic.stUsrPicFrm.u32PoolId)
        {
            SAMPLE_PRT("get YUV vb pool id failed\n");
            return HI_FAILURE;
        }
        SAMPLE_PRT("u32PoolId: %d\n", pstVFrameInfo->unUsrPic.stUsrPicFrm.u32PoolId);

        /* mmap physical address to virtual address*/
        s32Ret = HI_MPI_VB_MmapPool(pstVFrameInfo->unUsrPic.stUsrPicFrm.u32PoolId);
        if(s32Ret != HI_SUCCESS)
        {
            SAMPLE_PRT("get YUV vb pool id failed with: 0x%x\n", s32Ret);
            return HI_FAILURE;
        }

        s32Ret = HI_MPI_VB_GetBlockVirAddr(pstVFrameInfo->unUsrPic.stUsrPicFrm.u32PoolId, u64PhyAddr, (void **)&ppVirAddr);
        if(s32Ret != HI_SUCCESS)
        {
            HI_MPI_VB_ReleaseBlock(VbBlk);
            HI_MPI_VB_MunmapPool(pstVFrameInfo->unUsrPic.stUsrPicFrm.u32PoolId);

            SAMPLE_PRT("HI_MPI_VB_GetBlkVirAddr failed with: %#x", s32Ret);
            return HI_FAILURE;
        }
        //SAMPLE_PRT("ppVirAddr: %#x", ppVirAddr);

        /* now you need get YUV Semi Palnar Data ,fill them to the virtual address */
        puv = malloc(u32Size);
        if(puv == NULL)
        {
            SAMPLE_PRT("pyuv malloc failed");
            return HI_FAILURE;
        }

        p = ppVirAddr;
        fpic = fopen(pUserpicName,"rb");
        if (fpic == NULL)
        {
            SAMPLE_PRT("can't open file %s", pUserpicName);
            return HI_FAILURE;
        }

        /* read the data of Y component*/
        fread(p, 1, u32Height * u32LStride, fpic);

        /* read the data of UV component*/
        fread(puv, 1, (u32Height * u32LStride) >> 1, fpic);
        pu = puv;
        pv = puv + ((u32Height * u32LStride) >> 2);

        p = ppVirAddr + (u32Height * u32LStride);

        for (i = 0; i < (u32Height >> 1); i++)
        {
            for (j=0; j<(u32Width >> 1); j++)
            {
                p[j*2+1] = pu[j];
                p[j*2+0] = pv[j];
            }

            pu += u32LStride >> 1; //u32YStride
            pv += u32LStride >> 1;
            p  += u32LStride;
        }

        free(puv);
        puv = HI_NULL;
        fclose(fpic);

        pstVFrameInfo->enUsrPicMode = VI_USERPIC_MODE_PIC;
        pstVFrameInfo->unUsrPic.stUsrPicFrm.stVFrame.u64PhyAddr[0] = u64PhyAddr;
        pstVFrameInfo->unUsrPic.stUsrPicFrm.stVFrame.u64PhyAddr[1] = pstVFrameInfo->unUsrPic.stUsrPicFrm.stVFrame.u64PhyAddr[0] + u32LumaSize;
        pstVFrameInfo->unUsrPic.stUsrPicFrm.stVFrame.u64PhyAddr[2] = pstVFrameInfo->unUsrPic.stUsrPicFrm.stVFrame.u64PhyAddr[1] + u32ChrmSize;
        pstVFrameInfo->unUsrPic.stUsrPicFrm.stVFrame.u64VirAddr[0] = ppVirAddr;
        pstVFrameInfo->unUsrPic.stUsrPicFrm.stVFrame.u64VirAddr[1] = pstVFrameInfo->unUsrPic.stUsrPicFrm.stVFrame.u64VirAddr[0] + u32LumaSize;
        pstVFrameInfo->unUsrPic.stUsrPicFrm.stVFrame.u64VirAddr[2] = pstVFrameInfo->unUsrPic.stUsrPicFrm.stVFrame.u64VirAddr[1] + u32ChrmSize;
        pstVFrameInfo->unUsrPic.stUsrPicFrm.stVFrame.u32Width = u32Width;
        pstVFrameInfo->unUsrPic.stUsrPicFrm.stVFrame.u32Height = u32Height;
        pstVFrameInfo->unUsrPic.stUsrPicFrm.stVFrame.u32Stride[0] = u32LStride;
        pstVFrameInfo->unUsrPic.stUsrPicFrm.stVFrame.u32Stride[1] = u32LStride;
        pstVFrameInfo->unUsrPic.stUsrPicFrm.stVFrame.u32Stride[2] = u32LStride;
        pstVFrameInfo->unUsrPic.stUsrPicFrm.stVFrame.enCompressMode = COMPRESS_MODE_NONE;
        pstVFrameInfo->unUsrPic.stUsrPicFrm.stVFrame.enVideoFormat = VIDEO_FORMAT_LINEAR;
        pstVFrameInfo->unUsrPic.stUsrPicFrm.stVFrame.enField = VIDEO_FIELD_FRAME;
        pstVFrameInfo->unUsrPic.stUsrPicFrm.stVFrame.enPixelFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420;

        HI_MPI_VI_GetPipeFrameSource(0, &penSource);
        SAMPLE_PRT("PIPE_FRAME_SOURCE: %d\n", penSource);

        s32Ret = HI_MPI_VI_SetPipeFrameSource(0, VI_PIPE_FRAME_SOURCE_DEV);
        if (HI_SUCCESS != s32Ret)
        {
            SAMPLE_PRT("HI_MPI_VI_SetPipeFrameSource failed with: 0x%x\n", s32Ret);
            return HI_FAILURE;
        }        

        /* first set user pic info*/
        s32Ret = HI_MPI_VI_SetUserPic(0, pstVFrameInfo);
        if (HI_SUCCESS != s32Ret)
        {
            SAMPLE_PRT("HI_MPI_VI_SetUserPic failed with: 0x%x\n", s32Ret);
            return HI_FAILURE;
        }

        /* enable insert user pic if you need */
        s32Ret = HI_MPI_VI_EnableUserPic(0);
        if (HI_SUCCESS != s32Ret)
        {
            SAMPLE_PRT("HI_MPI_VI_EnableUserPic failed with: 0x%x\n", s32Ret);
            return HI_FAILURE;
        }
    }
    else
    {
        /* disable insert user pic if you don't need */
        s32Ret = HI_MPI_VI_DisableUserPic(0);
        if (HI_SUCCESS != s32Ret)
        {
            SAMPLE_PRT("HI_MPI_VI_DisableUserPic failed with: 0x%x\n", s32Ret);
            return HI_FAILURE;
        }
    }

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

Will

0个粉丝

3

问答

0

专栏

0

资料

Will 2021-08-25 21:16:35
认可0

补充下信息,查看logmpp,发现有报错[func]:vi_check_user_pic [line]:594 [info]:pixel_format invalid, only support sp420/sp422/single;但是我设置的格式是420,是我数据给错了?

Will

0个粉丝

3

问答

0

专栏

0

资料

Will 2021-08-26 09:00:52
认可0

问题是出在VI_USERPIC_ATTR结构体配置么?

Tracy_9216

1个粉丝

6

问答

79

专栏

29

资料

Tracy_9216 2021-08-26 09:02:28
认可0

cat /dev/logmpp看一下,里面会有报错原因和需要修改的方式,做针对的修改就可以了

Will

0个粉丝

3

问答

0

专栏

0

资料

Will 2021-08-26 09:15:04
认可0

cat /dev/logmpp看一下,里面会有报错原因和需要修改的方式,做针对的修改就可以了

logmpp只报了这个信息: [func]:vi_check_user_pic [line]:594 [info]:pixel_format invalid, only support sp420/sp422/single

Will

0个粉丝

3

问答

0

专栏

0

资料

Will 2021-08-26 11:13:37
认可0

真是没有头绪

Will

0个粉丝

3

问答

0

专栏

0

资料

Will 2021-08-26 13:56:53
认可0
易百纳技术社区该回答已被题主采纳为最佳答案

定位了,图片格式需要设置为PIXEL_FORMAT_YVU_SEMIPLANAR_420。
遇到此问题的同学可以参考。

横贯八方

4个粉丝

34

问答

0

专栏

3

资料

横贯八方 2021-08-30 15:31:18
认可0

感谢楼主分享

横贯八方

4个粉丝

34

问答

0

专栏

3

资料

横贯八方 2021-08-30 15:32:11
认可0

楼主居然还有3559av100的货

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

Markdown 语法

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

Markdown 语法

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

举报类型

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

详细说明

易百纳技术社区