bing

bing

5个粉丝

4

问答

0

专栏

0

资料

bing  发布于  2023-10-12 17:38:05
采纳率 0%
4个问答
405

HI_MPI_IVE_DMA 裁剪颜色为绿色

   

从HI_MPI_VPSS_GetGrpFrame获取数据帧,图像格式为PIXEL_FORMAT_YVU_SEMIPLANAR_420,进行dma拷贝后,图像为绿色
HI_S32 s32Ret;

VIDEO_FRAME_INFO_S pstVideoFrame;

s32Ret = HI_MPI_VPSS_GetGrpFrame(pFrame->VpssChn, 0, &pstVideoFrame);
if (HI_SUCCESS != s32Ret) {
    SAMPLE_PRT("HI_MPI_VPSS_GetGrpFrame failed. s32Ret: 0x%x !\n", s32Ret);
}
SAMPLE_PRT("pstVideoFrame enPixelFormat : %d , poolID : %d, enModId :%d, stVFrame.enVideoFormat : %d , enCompressMode: %d\n", pstVideoFrame.stVFrame.enPixelFormat, pstVideoFrame.u32PoolId, pstVideoFrame.enModId, pstVideoFrame.stVFrame.enVideoFormat, pstVideoFrame.stVFrame.enCompressMode);
SAMPLE_PRT("pstVideoFrame width : %d, height : %d, stride:%d, stride1 : %d , stride2 : %d\n", pstVideoFrame.stVFrame.u32Width, pstVideoFrame.stVFrame.u32Height, pstVideoFrame.stVFrame.u32Stride[0], pstVideoFrame.stVFrame.u32Stride[1],pstVideoFrame.stVFrame.u32Stride[2]);
// ExtVirAddr = (HI_U8 *)HI_MPI_SYS_Mmap(pstVideoFrame.stVFrame.u64PhyAddr[0], 1920 * 1080 * 3 / 2);
IVE_HANDLE hIve;
IVE_SRC_DATA_S stSrcData;
IVE_DST_DATA_S stDstData;
IVE_SRC_DATA_S stSrcData1;
IVE_DST_DATA_S stDstData1;
IVE_DMA_CTRL_S stDmaCtrl = { IVE_DMA_MODE_DIRECT_COPY, 0 };
VGS_TASK_ATTR_S stTask;
memset(&stTask, 0, sizeof(stTask));
memcpy(&stTask.stImgIn, &pstVideoFrame.stVFrame, sizeof(VIDEO_FRAME_INFO_S));
memcpy(&stTask.stImgOut, &pstVideoFrame.stVFrame, sizeof(VIDEO_FRAME_INFO_S));
#if 1
VB_POOL ourpool;
VB_POOL poolId;
VB_BLK ourblock;
VB_POOL_CONFIG_S ourVBconfig;
HI_U64* ourPhyAddr;
HI_U8 *ourVirAddr;
HI_U32      u32BlkSize;
u32BlkSize = COMMON_GetPicBufferSize(3840, 2160, SAMPLE_PIXEL_FORMAT, DATA_BITWIDTH_8, COMPRESS_MODE_SEG, DEFAULT_ALIGN);
(hi_void)memset_s(&ourVBconfig, sizeof(VB_POOL_CONFIG_S), 0, sizeof(VB_POOL_CONFIG_S));
ourVBconfig.u32BlkCnt = 1;
ourVBconfig.u64BlkSize = u32BlkSize;
ourVBconfig.enRemapMode = VB_REMAP_MODE_NONE;

ourblock = HI_MPI_VB_GetBlock(ourpool, u32BlkSize, "ourspace");
ourPhyAddr = HI_MPI_VB_Handle2PhysAddr(ourblock);
ourVirAddr = (HI_U8 *)HI_MPI_SYS_MmapCache(ourPhyAddr, u32BlkSize);

stSrcData.u64PhyAddr = pstVideoFrame.stVFrame.u64PhyAddr[0];
stSrcData.u64VirAddr = pstVideoFrame.stVFrame.u64VirAddr[0];
stSrcData.u32Width = pstVideoFrame.stVFrame.u32Width/2;
stSrcData.u32Height = pstVideoFrame.stVFrame.u32Height/2;
stSrcData.u32Stride = pstVideoFrame.stVFrame.u32Stride[0]/2;

stDstData.u64PhyAddr = ourPhyAddr;
stDstData.u64VirAddr = ourVirAddr;
stDstData.u32Width = 1920;
stDstData.u32Height = 1080;
stDstData.u32Stride = 1920;
HI_BOOL bInstant = HI_FALSE;
s32Ret = HI_MPI_IVE_DMA(&hIve, &stSrcData, &stDstData, &stDmaCtrl, bInstant);
if (s32Ret != HI_SUCCESS) {
    SAMPLE_PRT("000 HI_MPI_IVE_DMA failed with error code: %#x , bInstant : %d\n", s32Ret, bInstant);
}
stSrcData.u64PhyAddr = pstVideoFrame.stVFrame.u64PhyAddr[1] ;
stSrcData.u64VirAddr = pstVideoFrame.stVFrame.u64VirAddr[1] ;
stSrcData.u32Width = pstVideoFrame.stVFrame.u32Width/2;
stSrcData.u32Height = pstVideoFrame.stVFrame.u32Height/4;
stSrcData.u32Stride = pstVideoFrame.stVFrame.u32Stride[1]/2;

stDstData.u64PhyAddr = ourPhyAddr+ 1920 * 1080;
stDstData.u64VirAddr = ourVirAddr+ 1920 * 1080;
stDstData.u32Width = 1920;
stDstData.u32Height = 1080/2;
stDstData.u32Stride = 1920;
SAMPLE_PRT("stDstData u32Stride : %d , width :%d , height : %d\n", stDstData.u32Stride, stDstData.u32Width, stDstData.u32Height);
s32Ret = HI_MPI_IVE_DMA(&hIve, &stSrcData, &stDstData, &stDmaCtrl, bInstant);
if (s32Ret != HI_SUCCESS) {
    SAMPLE_PRT("111 HI_MPI_IVE_DMA failed with error code: %#x , bInstant : %d\n", s32Ret, bInstant);
}

// s32Ret = HI_MPI_VPSS_ReleaseGrpFrame(pFrame->VpssGrpVenc, 0, &pstVideoFrame);
// if (s32Ret != HI_SUCCESS) {
//     SAMPLE_PRT("HI_MPI_VPSS_ReleaseGrpFrame failed with error code: %#x\n", s32Ret);
// }

stTask.stImgIn.stVFrame.u32Width = 1920;
stTask.stImgIn.stVFrame.u32Height = 1080;
stTask.stImgIn.stVFrame.u32Stride[0] = 1920;
stTask.stImgIn.stVFrame.u64PhyAddr[0] = ourPhyAddr;
stTask.stImgIn.stVFrame.u64VirAddr[0] = (HI_U64)(HI_UINTPTR_T)ourVirAddr;
stTask.stImgIn.stVFrame.u64PhyAddr[1] = ourPhyAddr + 1920 * 1080;
stTask.stImgIn.stVFrame.u64VirAddr[1] = stTask.stImgIn.stVFrame.u64VirAddr[0] + 1920 * 1080;
stTask.stImgIn.stVFrame.u32Stride[1] = 1920;
stTask.stImgIn.stVFrame.enPixelFormat = PIXEL_FORMAT_YVU_SEMIPLANAR_420;
stTask.stImgIn.stVFrame.enVideoFormat = VIDEO_FORMAT_LINEAR;
stTask.stImgIn.u32PoolId = ourpool;

我来回答
回答3个
时间排序
认可量排序

Godgod

2个粉丝

0

问答

0

专栏

1

资料

Godgod 2023-10-14 15:42:23 已获得 1.00 E币
认可0

1.可能是vu数据在拷贝中丢失,建议检查一下

bing
bing   回复   Godgod  2023-10-16 13:46:31
0

PIXEL_FORMAT_YVU_SEMIPLANAR_420 这个格式的数据,他的内存块信息不是这样的么,我按块去拷贝的,这块不太懂,您能详细说下吗

QQ851800214

5个粉丝

6

问答

0

专栏

7

资料

QQ851800214 2023-10-16 07:12:03
认可0

YUV 顺序反了

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

Markdown 语法

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

Markdown 语法

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

举报类型

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

详细说明

易百纳技术社区