hi3519 bt1120输出1080p30
时间: 2023-11-18 15:05:21 浏览: 298
HI3519是海思半导体推出的一款高性能视频处理器,支持多种数字视频接口标准,包括BT1120。下面是一段示例代码,用于在HI3519上输出1080p30分辨率的视频数据:
```c
#include "hi_comm_video.h"
#include "hi_common.h"
#include "hi_comm_sys.h"
#include "mpi_sys.h"
#include "mpi_vb.h"
#include "mpi_vb2.h"
#include "mpi_vi.h"
#include "mpi_isp.h"
#include "mpi_venc.h"
#define FRAME_WIDTH 1920
#define FRAME_HEIGHT 1080
#define FRAME_RATE 30
int main(int argc, char *argv[]) {
// 初始化系统
HI_S32 s32Ret = HI_MPI_SYS_Init();
if (HI_SUCCESS != s32Ret) {
printf("HI_MPI_SYS_Init failed with error code %#x.\n", s32Ret);
return -1;
}
// 初始化视频缓存
VB_CONFIG_S stVbConf;
memset(&stVbConf, 0, sizeof(VB_CONFIG_S));
stVbConf.u32MaxPoolCnt = 128;
HI_MPI_VB_SetConf(&stVbConf);
HI_MPI_VB_Init();
// 初始化视频输入
VI_DEV ViDev = 0;
VI_CHN ViChn = 0;
VI_ATTR_S stViAttr;
memset(&stViAttr, 0, sizeof(VI_ATTR_S));
stViAttr.enIntfMode = VI_MODE_BT1120_1080P;
stViAttr.enScanMode = VI_SCAN_PROGRESSIVE;
stViAttr.enDataPath = VI_PATH_ISP;
stViAttr.enInputDataType = VI_DATA_TYPE_YUV;
stViAttr.stSynCfg.stTiming.u32Pck = 1;
stViAttr.stSynCfg.stTiming.u32Vs = 5;
stViAttr.stSynCfg.stTiming.u32Hs = 200;
stViAttr.stSynCfg.stTiming.u32Vact = 1080;
stViAttr.stSynCfg.stTiming.u32Hact = 1920;
stViAttr.stSynCfg.stTiming.u32Vb = 5;
stViAttr.stSynCfg.stTiming.u32Hb = 44;
stViAttr.stSynCfg.stTiming.u32Vfb = 5;
stViAttr.stSynCfg.stTiming.u32Hfb = 44;
stViAttr.stSynCfg.stTiming.u32Phase = 0;
s32Ret = HI_MPI_VI_SetDevAttr(ViDev, &stViAttr);
if (HI_SUCCESS != s32Ret) {
printf("HI_MPI_VI_SetDevAttr failed with error code %#x.\n", s32Ret);
return -1;
}
s32Ret = HI_MPI_VI_EnableDev(ViDev);
if (HI_SUCCESS != s32Ret) {
printf("HI_MPI_VI_EnableDev failed with error code %#x.\n", s32Ret);
return -1;
}
s32Ret = HI_MPI_VI_SetChnAttr(ViChn, &stViAttr);
if (HI_SUCCESS != s32Ret) {
printf("HI_MPI_VI_SetChnAttr failed with error code %#x.\n", s32Ret);
return -1;
}
s32Ret = HI_MPI_VI_EnableChn(ViChn);
if (HI_SUCCESS != s32Ret) {
printf("HI_MPI_VI_EnableChn failed with error code %#x.\n", s32Ret);
return -1;
}
// 初始化视频输出
VO_DEV VoDev = 0;
VO_CHN VoChn = 0;
VO_PUB_ATTR_S stVoPubAttr;
memset(&stVoPubAttr, 0, sizeof(VO_PUB_ATTR_S));
stVoPubAttr.u32BgColor = 0x00000000;
stVoPubAttr.enIntfType = VO_INTF_BT1120;
stVoPubAttr.enIntfSync = VO_OUTPUT_1080P30;
stVoPubAttr.enIntfMode = VO_MODE_MASTER;
stVoPubAttr.stSyncInfo.enVpssSync = VO_OUTPUT_1080P30;
stVoPubAttr.stSyncInfo.enIntfSync = VO_OUTPUT_1080P30;
s32Ret = HI_MPI_VO_SetPubAttr(VoDev, &stVoPubAttr);
if (HI_SUCCESS != s32Ret) {
printf("HI_MPI_VO_SetPubAttr failed with error code %#x.\n", s32Ret);
return -1;
}
s32Ret = HI_MPI_VO_Enable(VoDev);
if (HI_SUCCESS != s32Ret) {
printf("HI_MPI_VO_Enable failed with error code %#x.\n", s32Ret);
return -1;
}
VO_CHN_ATTR_S stVoChnAttr;
memset(&stVoChnAttr, 0, sizeof(VO_CHN_ATTR_S));
stVoChnAttr.stDispRect.s32X = 0;
stVoChnAttr.stDispRect.s32Y = 0;
stVoChnAttr.stDispRect.u32Width = FRAME_WIDTH;
stVoChnAttr.stDispRect.u32Height = FRAME_HEIGHT;
stVoChnAttr.u32Priority = 0;
stVoChnAttr.bDeflicker = HI_FALSE;
s32Ret = HI_MPI_VO_SetChnAttr(VoChn, &stVoChnAttr);
if (HI_SUCCESS != s32Ret) {
printf("HI_MPI_VO_SetChnAttr failed with error code %#x.\n", s32Ret);
return -1;
}
s32Ret = HI_MPI_VO_EnableChn(VoChn);
if (HI_SUCCESS != s32Ret) {
printf("HI_MPI_VO_EnableChn failed with error code %#x.\n", s32Ret);
return -1;
}
// 开启视频输入
s32Ret = HI_MPI_VI_EnableChn(ViChn);
if (HI_SUCCESS != s32Ret) {
printf("HI_MPI_VI_EnableChn failed with error code %#x.\n", s32Ret);
return -1;
}
// 开启视频输出
s32Ret = HI_MPI_VO_EnableChn(VoChn);
if (HI_SUCCESS != s32Ret) {
printf("HI_MPI_VO_EnableChn failed with error code %#x.\n", s32Ret);
return -1;
}
// 开启视频处理
while (1) {
HI_MPI_SYS_MmzAlloc_Cached(&pUserPageAddr[0], &pUserPhyAddr[0], "User", NULL, FRAME_WIDTH * FRAME_HEIGHT * 2);
s32Ret = HI_MPI_VI_GetFrame(ViChn, &stViFrameInfo, HI_TRUE);
if (HI_SUCCESS != s32Ret) {
printf("HI_MPI_VI_GetFrame failed with error code %#x.\n", s32Ret);
break;
}
s32Ret = HI_MPI_VO_SendFrame(VoChn, &stViFrameInfo);
if (HI_SUCCESS != s32Ret) {
printf("HI_MPI_VO_SendFrame failed with error code %#x.\n", s32Ret);
break;
}
HI_MPI_VI_ReleaseFrame(ViChn, &stViFrameInfo);
}
// 关闭视频处理
HI_MPI_VO_DisableChn(VoChn);
HI_MPI_VI_DisableChn(ViChn);
HI_MPI_VO_Disable(VoDev);
HI_MPI_VI_DisableDev(ViDev);
HI_MPI_VB_Exit();
HI_MPI_SYS_Exit();
return 0;
}
```
这段代码假设视频输入采用BT1120接口,分辨率为1080p30,输出采用BT1120接口,分辨率为1080p30,输出画面不做任何处理直接传输。注意,这只是一个示例,实际的代码可能需要根据具体的硬件平台和应用场景进行调整。
阅读全文