8098
- 收藏
- 点赞
- 分享
- 举报
【已解决】OSD显示时戳时调用HI_MPI_RGN_AttachToChn返回失败
本帖最后由 uclinux_2016 于 2016-9-11 16:10 编辑
OSD实现时调用HI_MPI_RGN_AttachToChn返回失败,失败返回值是0xa01d8008 (HI_ERR_IVE_NOT_SUPPORT, 不支持的参数或者功能),哪位能指导下,多谢!
下面是实现代码:
#define SAMPLE_VENC_OSD_DEV_MAX 4
#define SAMPLE_VENC_OSD_DEV_NAME_MAXLEN 64
typedef struct sample_osd_ctlcb_s
{
HI_U32 s32DevId;
HI_U32 s32ChnId;
HI_BOOL bOsdEnable;
TTF_Font *pstTtfFont;
VIDEO_NORM_E enNorm;
PIC_SIZE_E enPicSize;
HI_BOOL bUpdateDevName;
HI_CHAR aDevName[SAMPLE_VENC_OSD_DEV_NAME_MAXLEN];
}SAMPLE_OSD_CTLCB_S;
SAMPLE_OSD_CTLCB_S g_astOsdVencCtl[SAMPLE_VENC_OSD_DEV_MAX];
HI_S32 SAMPLE_OSD_VENC_Init(VOID)
{
SAMPLE_OSD_CTLCB_S *pstOsdVencCtl;
HI_U32 uiDev;
if ( TTF_Init() < 0 )
{
fprintf(stderr, "Couldn't initialize TTF: %s\n", SDL_GetError());
SDL_Quit();
return HI_FAILURE;
}
for (uiDev = 0; uiDev < SAMPLE_VENC_OSD_DEV_MAX; uiDev++)
{
pstOsdVencCtl = &g_astOsdVencCtl[uiDev];
memset(pstOsdVencCtl, sizeof(SAMPLE_OSD_CTLCB_S), 0);
snprintf(pstOsdVencCtl->aDevName, SAMPLE_VENC_OSD_DEV_NAME_MAXLEN, "Device%02d", uiDev);
}
return HI_SUCCESS;
}
static HI_S32 SAMPLE_RGN_CreateOverlayForVenc(SAMPLE_OSD_CTLCB_S *pstOsdVencCtl)
{
HI_S32 i;
HI_S32 s32Ret;
RGN_ATTR_S stRgnAttr;
RGN_CHN_ATTR_S stChnAttr;
RGN_HANDLE Handle;
MPP_CHN_S stChn;
HI_S32 w, h;
SIZE_S picSize ;
s32Ret = SAMPLE_COMM_SYS_GetPicSize(pstOsdVencCtl->enNorm, pstOsdVencCtl->enPicSize, &picSize);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("get picture size failed!\ninit osd mudule failed\n");
return s32Ret;
}
/* Add cover to vpss group */
stChn.enModId = HI_ID_VENC;
stChn.s32DevId = pstOsdVencCtl->s32DevId;
stChn.s32ChnId = pstOsdVencCtl->s32ChnId;
for (i = 0; i < 2; i++)
{
Handle = pstOsdVencCtl->s32DevId * 4 + pstOsdVencCtl->s32ChnId * 2+ i;
TTF_SizeUTF8(pstOsdVencCtl->pstTtfFont, pstOsdVencCtl->aDevName, &w, &h);
stRgnAttr.enType = OVERLAY_RGN;
stRgnAttr.unAttr.stOverlay.enPixelFmt = PIXEL_FORMAT_RGB_1555;
stRgnAttr.unAttr.stOverlay.stSize.u32Width = w + w%2 + 16;
stRgnAttr.unAttr.stOverlay.stSize.u32Height = h + h%2;
stRgnAttr.unAttr.stOverlay.u32BgColor = 0x00000000;
if (1 == i % 2)
{
TTF_SizeUTF8(pstOsdVencCtl->pstTtfFont, "2016-07-09 17:23:08", &w, &h);
stRgnAttr.unAttr.stOverlay.stSize.u32Width = w + w%2 + 16;
stRgnAttr.unAttr.stOverlay.stSize.u32Height = h + h%2;
stRgnAttr.unAttr.stOverlay.u32BgColor = 0x00000000;
}
s32Ret = HI_MPI_RGN_Create(Handle, &stRgnAttr);
if (s32Ret != HI_SUCCESS)
{
SAMPLE_PRT("HI_MPI_RGN_Create failed! s32Ret: 0x%x.\n", s32Ret);
return s32Ret;
}
stChnAttr.bShow = HI_TRUE;
stChnAttr.enType = OVERLAY_RGN;
stChnAttr.unChnAttr.stOverlayChn.stPoint.s32X = 8;
stChnAttr.unChnAttr.stOverlayChn.stPoint.s32Y = 18;
stChnAttr.unChnAttr.stOverlayChn.u32BgAlpha = 0;//region bg alpha
stChnAttr.unChnAttr.stOverlayChn.u32FgAlpha = 128;//text bg alpha
stChnAttr.unChnAttr.stOverlayChn.u32Layer = i;
stChnAttr.unChnAttr.stOverlayChn.stQpInfo.bAbsQp = HI_FALSE;
stChnAttr.unChnAttr.stOverlayChn.stQpInfo.s32Qp = 0;
stChnAttr.unChnAttr.stOverlayChn.stInvertColor.stInvColArea.u32Height = 16;
stChnAttr.unChnAttr.stOverlayChn.stInvertColor.stInvColArea.u32Width = 16;
stChnAttr.unChnAttr.stOverlayChn.stInvertColor.u32LumThresh = 128;
stChnAttr.unChnAttr.stOverlayChn.stInvertColor.enChgMod = LESSTHAN_LUM_THRESH;
stChnAttr.unChnAttr.stOverlayChn.stInvertColor.bInvColEn = HI_FALSE;
if (1 == i % 2)
{
stChnAttr.unChnAttr.stOverlayChn.stPoint.s32X = (picSize.u32Width - (w + w%2 +16));
stChnAttr.unChnAttr.stOverlayChn.stPoint.s32Y = 18;
stChnAttr.unChnAttr.stOverlayChn.u32BgAlpha = 0;//region bg alpha
stChnAttr.unChnAttr.stOverlayChn.u32FgAlpha = 128;//text bg alpha
stChnAttr.unChnAttr.stOverlayChn.u32Layer = i;
}
s32Ret = HI_MPI_RGN_AttachToChn(Handle, &stChn, &stChnAttr);
if (s32Ret != HI_SUCCESS)
{
SAMPLE_PRT("rgn attach err\n");
}
}
return HI_SUCCESS;
}
HI_S32 SAMPLE_OSD_VENC_ChanInit(HI_U32 s32DevId, HI_U32 s32ChnId, VIDEO_NORM_E enNorm, PIC_SIZE_E enPicSize)
{
SAMPLE_OSD_CTLCB_S *pstOsdVencCtl = NULL;
HI_S32 s32Ret = HI_SUCCESS;
HI_S32 wordSize;
HI_BOOL isOSDFlg = HI_TRUE;
if (SAMPLE_VENC_OSD_DEV_MAX <= s32DevId)
{
SAMPLE_PRT("invalid dev ID %d\n", s32DevId);
return HI_FAILURE;
}
pstOsdVencCtl = &g_astOsdVencCtl[s32DevId];
pstOsdVencCtl->s32DevId = s32DevId;
pstOsdVencCtl->s32ChnId = s32ChnId;
pstOsdVencCtl->enNorm = enNorm;
pstOsdVencCtl->enPicSize = enPicSize;
pstOsdVencCtl->bOsdEnable = HI_TRUE;
pstOsdVencCtl->bUpdateDevName = HI_TRUE;
switch(enPicSize)
{
case PIC_QVGA:
wordSize = 12;
break;
case PIC_D1:
case PIC_VGA:
wordSize = 16;
break;
case PIC_XGA:
wordSize = 24;
break;
case PIC_HD720:
wordSize = 32;
break;
case PIC_HD1080:
wordSize = 48;
break;
default:
SAMPLE_PRT("video size err,not support osd time\n");
break;
}
pstOsdVencCtl->pstTtfFont = TTF_OpenFont("word.ttf", wordSize);
if (pstOsdVencCtl->pstTtfFont == NULL )
{
SAMPLE_PRT("ttf open err\n");
return HI_FAILURE;
}
s32Ret = SAMPLE_RGN_CreateOverlayForVenc(pstOsdVencCtl);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("SAMPLE_RGN_CreateOverlayForVenc failed! s32Ret: 0x%x.\n", s32Ret);
return s32Ret;
}
return HI_SUCCESS;
}
/******************************************************************************
* function : 4HD H264 encode
******************************************************************************/
HI_S32 SAMPLE_VENC_4HD_H264(HI_VOID)
{
SAMPLE_VI_MODE_E enViMode = SAMPLE_VI_MODE_4_1080P;
HI_U32 u32ViChnCnt = 4;
HI_S32 s32VpssGrpCnt = 4;
PAYLOAD_TYPE_E enPayLoad[2]= {PT_H264, PT_H264};
PIC_SIZE_E enSize[2] = {PIC_HD1080, PIC_D1};
VB_CONF_S stVbConf;
VPSS_GRP VpssGrp;
VPSS_CHN VpssChn;
VPSS_GRP_ATTR_S stGrpAttr;
VENC_GRP VencGrp;
VENC_CHN VencChn;
SAMPLE_RC_E enRcMode;
HI_S32 i;
HI_S32 s32Ret = HI_SUCCESS;
HI_U32 u32BlkSize;
HI_CHAR ch;
SIZE_S stSize;
/******************************************
step 1: init variable
******************************************/
memset(&stVbConf,0,sizeof(VB_CONF_S));
u32BlkSize = SAMPLE_COMM_SYS_CalcPicVbBlkSize(gs_enNorm,\
PIC_HD1080, SAMPLE_PIXEL_FORMAT, SAMPLE_SYS_ALIGN_WIDTH);
stVbConf.u32MaxPoolCnt = 128;
/*ddr0 video buffer*/
stVbConf.astCommPool[0].u32BlkSize = u32BlkSize;
stVbConf.astCommPool[0].u32BlkCnt = u32ViChnCnt * 16;
memset(stVbConf.astCommPool[0].acMmzName,0,
sizeof(stVbConf.astCommPool[0].acMmzName));
/*ddr0 hist buf*/
stVbConf.astCommPool[1].u32BlkSize = (196*4);
stVbConf.astCommPool[1].u32BlkCnt = u32ViChnCnt * 16;
memset(stVbConf.astCommPool[1].acMmzName,0,
sizeof(stVbConf.astCommPool[1].acMmzName));
/*ddr1 video buffer*/
stVbConf.astCommPool[2].u32BlkSize = u32BlkSize;
stVbConf.astCommPool[2].u32BlkCnt = u32ViChnCnt * 16;
strcpy(stVbConf.astCommPool[2].acMmzName,"ddr1");
/*ddr1 hist buf*/
stVbConf.astCommPool[3].u32BlkSize = (196*4);
stVbConf.astCommPool[3].u32BlkCnt = u32ViChnCnt * 16;
strcpy(stVbConf.astCommPool[3].acMmzName,"ddr1");
/******************************************
step 2: mpp system init.
******************************************/
s32Ret = SAMPLE_COMM_SYS_Init(&stVbConf);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("system init failed with %d!\n", s32Ret);
goto END_VENC_4HD_0;
}
s32Ret = SAMPLE_COMM_VI_MemConfig(enViMode);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("SAMPLE_COMM_VI_MemConfig failed with %d!\n", s32Ret);
goto END_VENC_4HD_0;
}
s32Ret = SAMPLE_COMM_VPSS_MemConfig();
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("SAMPLE_COMM_VPSS_MemConfig failed with %d!\n", s32Ret);
goto END_VENC_4HD_0;
}
s32Ret = SAMPLE_COMM_VENC_MemConfig();
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("SAMPLE_COMM_VPSS_MemConfig failed with %d!\n", s32Ret);
goto END_VENC_4HD_0;
}
/******************************************
step 3: start vi dev & chn to capture
******************************************/
s32Ret = SAMPLE_COMM_VI_Start(enViMode, gs_enNorm);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("start vi failed!\n");
goto END_VENC_4HD_0;
}
/******************************************
step 4: start vpss and vi bind vpss
******************************************/
s32Ret = SAMPLE_COMM_SYS_GetPicSize(gs_enNorm, PIC_HD1080, &stSize);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("SAMPLE_COMM_SYS_GetPicSize failed!\n");
goto END_VENC_4HD_0;
}
stGrpAttr.u32MaxW = stSize.u32Width;
stGrpAttr.u32MaxH = stSize.u32Height;
stGrpAttr.bDrEn = HI_FALSE;
stGrpAttr.bDbEn = HI_FALSE;
stGrpAttr.bIeEn = HI_TRUE;
stGrpAttr.bNrEn = HI_TRUE;
stGrpAttr.bHistEn = HI_TRUE;
stGrpAttr.enDieMode = VPSS_DIE_MODE_AUTO;
stGrpAttr.enPixFmt = SAMPLE_PIXEL_FORMAT;
s32Ret = SAMPLE_COMM_VPSS_Start(s32VpssGrpCnt, &stSize, VPSS_MAX_CHN_NUM,NULL);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Start Vpss failed!\n");
goto END_VENC_4HD_1;
}
s32Ret = SAMPLE_COMM_VI_BindVpss(enViMode);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Vi bind Vpss failed!\n");
goto END_VENC_4HD_2;
}
s32Ret = SAMPLE_OSD_VENC_Init();
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Initialize OSD VENC failed!\n");
goto END_VENC_4HD_2;
}
/******************************************
step 5: select rc mode
******************************************/
while(1)
{
printf("please choose rc mode:\n");
printf("\t0) CBR\n");
printf("\t1) VBR\n");
printf("\t2) FIXQP\n");
ch = getchar();
getchar();
if ('0' == ch)
{
enRcMode = SAMPLE_RC_CBR;
break;
}
else if ('1' == ch)
{
enRcMode = SAMPLE_RC_VBR;
break;
}
else if ('2' == ch)
{
enRcMode = SAMPLE_RC_FIXQP;
break;
}
else
{
printf("rc mode invaild! please try again.\n");
continue;
}
}
/******************************************
step 6: start stream venc (big + little)
******************************************/
for (i=0; i
{
/*** main frame **/
VencGrp = i*2;
VencChn = i*2;
VpssGrp = i;
s32Ret = SAMPLE_COMM_VENC_Start(VencGrp, VencChn, enPayLoad[0],\
gs_enNorm, enSize[0], enRcMode);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Start Venc failed!\n");
goto END_VENC_4HD_3;
}
s32Ret = SAMPLE_COMM_VENC_BindVpss(VencGrp, VpssGrp, VPSS_BSTR_CHN);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Start Venc failed!\n");
goto END_VENC_4HD_3;
}
s32Ret = SAMPLE_OSD_VENC_ChanInit(VencGrp, VpssGrp, gs_enNorm, enSize[0]);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Initialize OSD VENC channel failed 0 !\n");
goto END_VENC_4HD_3;
}
/*** Sub frame **/
VencGrp ++;
VencChn ++;
s32Ret = SAMPLE_COMM_VENC_Start(VencGrp, VencChn, enPayLoad[1], \
gs_enNorm, enSize[1], enRcMode);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Start Venc failed!\n");
goto END_VENC_4HD_3;
}
s32Ret = SAMPLE_COMM_VENC_BindVpss(VencChn, VpssGrp, VPSS_LSTR_CHN);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Start Venc failed!\n");
goto END_VENC_4HD_3;
}
s32Ret = SAMPLE_OSD_VENC_ChanInit(VencGrp, VpssGrp, gs_enNorm, enSize[1]);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Initialize OSD VENC channel failed 0 !\n");
goto END_VENC_4HD_3;
}
}
/******************************************
step 7: stream venc process -- get stream, then save it to file.
******************************************/
s32Ret = SAMPLE_COMM_VENC_StartGetStream(u32ViChnCnt*2);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Start Venc failed!\n");
goto END_VENC_4HD_3;
}
printf("please press twice ENTER to exit this sample\n");
getchar();
getchar();
/******************************************
step 8: exit process
******************************************/
SAMPLE_COMM_VENC_StopGetStream();
END_VENC_4HD_3:
for (i=0; i
{
VencGrp = i;
VencChn = i;
VpssGrp = i/2;
VpssChn = (VpssGrp%2)?VPSS_PRE0_CHN:VPSS_BSTR_CHN;
SAMPLE_COMM_VENC_UnBindVpss(VencGrp, VpssGrp, VpssChn);
SAMPLE_COMM_VENC_Stop(VencGrp,VencChn);
}
SAMPLE_COMM_VI_UnBindVpss(enViMode);
END_VENC_4HD_2: //vpss stop
SAMPLE_COMM_VPSS_Stop(s32VpssGrpCnt, VPSS_MAX_CHN_NUM);
END_VENC_4HD_1: //vi stop
SAMPLE_COMM_VI_Stop(enViMode);
END_VENC_4HD_0: //system exit
SAMPLE_COMM_SYS_Exit();
return s32Ret;
}
OSD实现时调用HI_MPI_RGN_AttachToChn返回失败,失败返回值是0xa01d8008 (HI_ERR_IVE_NOT_SUPPORT, 不支持的参数或者功能),哪位能指导下,多谢!
下面是实现代码:
#define SAMPLE_VENC_OSD_DEV_MAX 4
#define SAMPLE_VENC_OSD_DEV_NAME_MAXLEN 64
typedef struct sample_osd_ctlcb_s
{
HI_U32 s32DevId;
HI_U32 s32ChnId;
HI_BOOL bOsdEnable;
TTF_Font *pstTtfFont;
VIDEO_NORM_E enNorm;
PIC_SIZE_E enPicSize;
HI_BOOL bUpdateDevName;
HI_CHAR aDevName[SAMPLE_VENC_OSD_DEV_NAME_MAXLEN];
}SAMPLE_OSD_CTLCB_S;
SAMPLE_OSD_CTLCB_S g_astOsdVencCtl[SAMPLE_VENC_OSD_DEV_MAX];
HI_S32 SAMPLE_OSD_VENC_Init(VOID)
{
SAMPLE_OSD_CTLCB_S *pstOsdVencCtl;
HI_U32 uiDev;
if ( TTF_Init() < 0 )
{
fprintf(stderr, "Couldn't initialize TTF: %s\n", SDL_GetError());
SDL_Quit();
return HI_FAILURE;
}
for (uiDev = 0; uiDev < SAMPLE_VENC_OSD_DEV_MAX; uiDev++)
{
pstOsdVencCtl = &g_astOsdVencCtl[uiDev];
memset(pstOsdVencCtl, sizeof(SAMPLE_OSD_CTLCB_S), 0);
snprintf(pstOsdVencCtl->aDevName, SAMPLE_VENC_OSD_DEV_NAME_MAXLEN, "Device%02d", uiDev);
}
return HI_SUCCESS;
}
static HI_S32 SAMPLE_RGN_CreateOverlayForVenc(SAMPLE_OSD_CTLCB_S *pstOsdVencCtl)
{
HI_S32 i;
HI_S32 s32Ret;
RGN_ATTR_S stRgnAttr;
RGN_CHN_ATTR_S stChnAttr;
RGN_HANDLE Handle;
MPP_CHN_S stChn;
HI_S32 w, h;
SIZE_S picSize ;
s32Ret = SAMPLE_COMM_SYS_GetPicSize(pstOsdVencCtl->enNorm, pstOsdVencCtl->enPicSize, &picSize);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("get picture size failed!\ninit osd mudule failed\n");
return s32Ret;
}
/* Add cover to vpss group */
stChn.enModId = HI_ID_VENC;
stChn.s32DevId = pstOsdVencCtl->s32DevId;
stChn.s32ChnId = pstOsdVencCtl->s32ChnId;
for (i = 0; i < 2; i++)
{
Handle = pstOsdVencCtl->s32DevId * 4 + pstOsdVencCtl->s32ChnId * 2+ i;
TTF_SizeUTF8(pstOsdVencCtl->pstTtfFont, pstOsdVencCtl->aDevName, &w, &h);
stRgnAttr.enType = OVERLAY_RGN;
stRgnAttr.unAttr.stOverlay.enPixelFmt = PIXEL_FORMAT_RGB_1555;
stRgnAttr.unAttr.stOverlay.stSize.u32Width = w + w%2 + 16;
stRgnAttr.unAttr.stOverlay.stSize.u32Height = h + h%2;
stRgnAttr.unAttr.stOverlay.u32BgColor = 0x00000000;
if (1 == i % 2)
{
TTF_SizeUTF8(pstOsdVencCtl->pstTtfFont, "2016-07-09 17:23:08", &w, &h);
stRgnAttr.unAttr.stOverlay.stSize.u32Width = w + w%2 + 16;
stRgnAttr.unAttr.stOverlay.stSize.u32Height = h + h%2;
stRgnAttr.unAttr.stOverlay.u32BgColor = 0x00000000;
}
s32Ret = HI_MPI_RGN_Create(Handle, &stRgnAttr);
if (s32Ret != HI_SUCCESS)
{
SAMPLE_PRT("HI_MPI_RGN_Create failed! s32Ret: 0x%x.\n", s32Ret);
return s32Ret;
}
stChnAttr.bShow = HI_TRUE;
stChnAttr.enType = OVERLAY_RGN;
stChnAttr.unChnAttr.stOverlayChn.stPoint.s32X = 8;
stChnAttr.unChnAttr.stOverlayChn.stPoint.s32Y = 18;
stChnAttr.unChnAttr.stOverlayChn.u32BgAlpha = 0;//region bg alpha
stChnAttr.unChnAttr.stOverlayChn.u32FgAlpha = 128;//text bg alpha
stChnAttr.unChnAttr.stOverlayChn.u32Layer = i;
stChnAttr.unChnAttr.stOverlayChn.stQpInfo.bAbsQp = HI_FALSE;
stChnAttr.unChnAttr.stOverlayChn.stQpInfo.s32Qp = 0;
stChnAttr.unChnAttr.stOverlayChn.stInvertColor.stInvColArea.u32Height = 16;
stChnAttr.unChnAttr.stOverlayChn.stInvertColor.stInvColArea.u32Width = 16;
stChnAttr.unChnAttr.stOverlayChn.stInvertColor.u32LumThresh = 128;
stChnAttr.unChnAttr.stOverlayChn.stInvertColor.enChgMod = LESSTHAN_LUM_THRESH;
stChnAttr.unChnAttr.stOverlayChn.stInvertColor.bInvColEn = HI_FALSE;
if (1 == i % 2)
{
stChnAttr.unChnAttr.stOverlayChn.stPoint.s32X = (picSize.u32Width - (w + w%2 +16));
stChnAttr.unChnAttr.stOverlayChn.stPoint.s32Y = 18;
stChnAttr.unChnAttr.stOverlayChn.u32BgAlpha = 0;//region bg alpha
stChnAttr.unChnAttr.stOverlayChn.u32FgAlpha = 128;//text bg alpha
stChnAttr.unChnAttr.stOverlayChn.u32Layer = i;
}
s32Ret = HI_MPI_RGN_AttachToChn(Handle, &stChn, &stChnAttr);
if (s32Ret != HI_SUCCESS)
{
SAMPLE_PRT("rgn attach err\n");
}
}
return HI_SUCCESS;
}
HI_S32 SAMPLE_OSD_VENC_ChanInit(HI_U32 s32DevId, HI_U32 s32ChnId, VIDEO_NORM_E enNorm, PIC_SIZE_E enPicSize)
{
SAMPLE_OSD_CTLCB_S *pstOsdVencCtl = NULL;
HI_S32 s32Ret = HI_SUCCESS;
HI_S32 wordSize;
HI_BOOL isOSDFlg = HI_TRUE;
if (SAMPLE_VENC_OSD_DEV_MAX <= s32DevId)
{
SAMPLE_PRT("invalid dev ID %d\n", s32DevId);
return HI_FAILURE;
}
pstOsdVencCtl = &g_astOsdVencCtl[s32DevId];
pstOsdVencCtl->s32DevId = s32DevId;
pstOsdVencCtl->s32ChnId = s32ChnId;
pstOsdVencCtl->enNorm = enNorm;
pstOsdVencCtl->enPicSize = enPicSize;
pstOsdVencCtl->bOsdEnable = HI_TRUE;
pstOsdVencCtl->bUpdateDevName = HI_TRUE;
switch(enPicSize)
{
case PIC_QVGA:
wordSize = 12;
break;
case PIC_D1:
case PIC_VGA:
wordSize = 16;
break;
case PIC_XGA:
wordSize = 24;
break;
case PIC_HD720:
wordSize = 32;
break;
case PIC_HD1080:
wordSize = 48;
break;
default:
SAMPLE_PRT("video size err,not support osd time\n");
break;
}
pstOsdVencCtl->pstTtfFont = TTF_OpenFont("word.ttf", wordSize);
if (pstOsdVencCtl->pstTtfFont == NULL )
{
SAMPLE_PRT("ttf open err\n");
return HI_FAILURE;
}
s32Ret = SAMPLE_RGN_CreateOverlayForVenc(pstOsdVencCtl);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("SAMPLE_RGN_CreateOverlayForVenc failed! s32Ret: 0x%x.\n", s32Ret);
return s32Ret;
}
return HI_SUCCESS;
}
/******************************************************************************
* function : 4HD H264 encode
******************************************************************************/
HI_S32 SAMPLE_VENC_4HD_H264(HI_VOID)
{
SAMPLE_VI_MODE_E enViMode = SAMPLE_VI_MODE_4_1080P;
HI_U32 u32ViChnCnt = 4;
HI_S32 s32VpssGrpCnt = 4;
PAYLOAD_TYPE_E enPayLoad[2]= {PT_H264, PT_H264};
PIC_SIZE_E enSize[2] = {PIC_HD1080, PIC_D1};
VB_CONF_S stVbConf;
VPSS_GRP VpssGrp;
VPSS_CHN VpssChn;
VPSS_GRP_ATTR_S stGrpAttr;
VENC_GRP VencGrp;
VENC_CHN VencChn;
SAMPLE_RC_E enRcMode;
HI_S32 i;
HI_S32 s32Ret = HI_SUCCESS;
HI_U32 u32BlkSize;
HI_CHAR ch;
SIZE_S stSize;
/******************************************
step 1: init variable
******************************************/
memset(&stVbConf,0,sizeof(VB_CONF_S));
u32BlkSize = SAMPLE_COMM_SYS_CalcPicVbBlkSize(gs_enNorm,\
PIC_HD1080, SAMPLE_PIXEL_FORMAT, SAMPLE_SYS_ALIGN_WIDTH);
stVbConf.u32MaxPoolCnt = 128;
/*ddr0 video buffer*/
stVbConf.astCommPool[0].u32BlkSize = u32BlkSize;
stVbConf.astCommPool[0].u32BlkCnt = u32ViChnCnt * 16;
memset(stVbConf.astCommPool[0].acMmzName,0,
sizeof(stVbConf.astCommPool[0].acMmzName));
/*ddr0 hist buf*/
stVbConf.astCommPool[1].u32BlkSize = (196*4);
stVbConf.astCommPool[1].u32BlkCnt = u32ViChnCnt * 16;
memset(stVbConf.astCommPool[1].acMmzName,0,
sizeof(stVbConf.astCommPool[1].acMmzName));
/*ddr1 video buffer*/
stVbConf.astCommPool[2].u32BlkSize = u32BlkSize;
stVbConf.astCommPool[2].u32BlkCnt = u32ViChnCnt * 16;
strcpy(stVbConf.astCommPool[2].acMmzName,"ddr1");
/*ddr1 hist buf*/
stVbConf.astCommPool[3].u32BlkSize = (196*4);
stVbConf.astCommPool[3].u32BlkCnt = u32ViChnCnt * 16;
strcpy(stVbConf.astCommPool[3].acMmzName,"ddr1");
/******************************************
step 2: mpp system init.
******************************************/
s32Ret = SAMPLE_COMM_SYS_Init(&stVbConf);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("system init failed with %d!\n", s32Ret);
goto END_VENC_4HD_0;
}
s32Ret = SAMPLE_COMM_VI_MemConfig(enViMode);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("SAMPLE_COMM_VI_MemConfig failed with %d!\n", s32Ret);
goto END_VENC_4HD_0;
}
s32Ret = SAMPLE_COMM_VPSS_MemConfig();
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("SAMPLE_COMM_VPSS_MemConfig failed with %d!\n", s32Ret);
goto END_VENC_4HD_0;
}
s32Ret = SAMPLE_COMM_VENC_MemConfig();
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("SAMPLE_COMM_VPSS_MemConfig failed with %d!\n", s32Ret);
goto END_VENC_4HD_0;
}
/******************************************
step 3: start vi dev & chn to capture
******************************************/
s32Ret = SAMPLE_COMM_VI_Start(enViMode, gs_enNorm);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("start vi failed!\n");
goto END_VENC_4HD_0;
}
/******************************************
step 4: start vpss and vi bind vpss
******************************************/
s32Ret = SAMPLE_COMM_SYS_GetPicSize(gs_enNorm, PIC_HD1080, &stSize);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("SAMPLE_COMM_SYS_GetPicSize failed!\n");
goto END_VENC_4HD_0;
}
stGrpAttr.u32MaxW = stSize.u32Width;
stGrpAttr.u32MaxH = stSize.u32Height;
stGrpAttr.bDrEn = HI_FALSE;
stGrpAttr.bDbEn = HI_FALSE;
stGrpAttr.bIeEn = HI_TRUE;
stGrpAttr.bNrEn = HI_TRUE;
stGrpAttr.bHistEn = HI_TRUE;
stGrpAttr.enDieMode = VPSS_DIE_MODE_AUTO;
stGrpAttr.enPixFmt = SAMPLE_PIXEL_FORMAT;
s32Ret = SAMPLE_COMM_VPSS_Start(s32VpssGrpCnt, &stSize, VPSS_MAX_CHN_NUM,NULL);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Start Vpss failed!\n");
goto END_VENC_4HD_1;
}
s32Ret = SAMPLE_COMM_VI_BindVpss(enViMode);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Vi bind Vpss failed!\n");
goto END_VENC_4HD_2;
}
s32Ret = SAMPLE_OSD_VENC_Init();
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Initialize OSD VENC failed!\n");
goto END_VENC_4HD_2;
}
/******************************************
step 5: select rc mode
******************************************/
while(1)
{
printf("please choose rc mode:\n");
printf("\t0) CBR\n");
printf("\t1) VBR\n");
printf("\t2) FIXQP\n");
ch = getchar();
getchar();
if ('0' == ch)
{
enRcMode = SAMPLE_RC_CBR;
break;
}
else if ('1' == ch)
{
enRcMode = SAMPLE_RC_VBR;
break;
}
else if ('2' == ch)
{
enRcMode = SAMPLE_RC_FIXQP;
break;
}
else
{
printf("rc mode invaild! please try again.\n");
continue;
}
}
/******************************************
step 6: start stream venc (big + little)
******************************************/
for (i=0; i
/*** main frame **/
VencGrp = i*2;
VencChn = i*2;
VpssGrp = i;
s32Ret = SAMPLE_COMM_VENC_Start(VencGrp, VencChn, enPayLoad[0],\
gs_enNorm, enSize[0], enRcMode);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Start Venc failed!\n");
goto END_VENC_4HD_3;
}
s32Ret = SAMPLE_COMM_VENC_BindVpss(VencGrp, VpssGrp, VPSS_BSTR_CHN);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Start Venc failed!\n");
goto END_VENC_4HD_3;
}
s32Ret = SAMPLE_OSD_VENC_ChanInit(VencGrp, VpssGrp, gs_enNorm, enSize[0]);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Initialize OSD VENC channel failed 0 !\n");
goto END_VENC_4HD_3;
}
/*** Sub frame **/
VencGrp ++;
VencChn ++;
s32Ret = SAMPLE_COMM_VENC_Start(VencGrp, VencChn, enPayLoad[1], \
gs_enNorm, enSize[1], enRcMode);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Start Venc failed!\n");
goto END_VENC_4HD_3;
}
s32Ret = SAMPLE_COMM_VENC_BindVpss(VencChn, VpssGrp, VPSS_LSTR_CHN);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Start Venc failed!\n");
goto END_VENC_4HD_3;
}
s32Ret = SAMPLE_OSD_VENC_ChanInit(VencGrp, VpssGrp, gs_enNorm, enSize[1]);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Initialize OSD VENC channel failed 0 !\n");
goto END_VENC_4HD_3;
}
}
/******************************************
step 7: stream venc process -- get stream, then save it to file.
******************************************/
s32Ret = SAMPLE_COMM_VENC_StartGetStream(u32ViChnCnt*2);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Start Venc failed!\n");
goto END_VENC_4HD_3;
}
printf("please press twice ENTER to exit this sample\n");
getchar();
getchar();
/******************************************
step 8: exit process
******************************************/
SAMPLE_COMM_VENC_StopGetStream();
END_VENC_4HD_3:
for (i=0; i
VencGrp = i;
VencChn = i;
VpssGrp = i/2;
VpssChn = (VpssGrp%2)?VPSS_PRE0_CHN:VPSS_BSTR_CHN;
SAMPLE_COMM_VENC_UnBindVpss(VencGrp, VpssGrp, VpssChn);
SAMPLE_COMM_VENC_Stop(VencGrp,VencChn);
}
SAMPLE_COMM_VI_UnBindVpss(enViMode);
END_VENC_4HD_2: //vpss stop
SAMPLE_COMM_VPSS_Stop(s32VpssGrpCnt, VPSS_MAX_CHN_NUM);
END_VENC_4HD_1: //vi stop
SAMPLE_COMM_VI_Stop(enViMode);
END_VENC_4HD_0: //system exit
SAMPLE_COMM_SYS_Exit();
return s32Ret;
}
我来回答
回答16个
时间排序
认可量排序
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2017-08-18 15:19:16
-
2019-06-11 20:53:21
-
2016-01-27 15:42:38
-
2020-03-20 08:45:34
-
2019-01-12 11:27:38
-
2016-05-13 17:38:29
-
52019-04-01 17:59:14
-
2016-03-17 00:21:44
-
42020-09-09 08:15:40
-
2019-04-10 10:31:16
-
2016-04-05 11:29:44
-
2016-06-02 11:16:39
-
2017-05-26 18:28:29
-
2014-10-16 17:05:38
-
2016-10-26 11:55:21
-
2017-03-22 11:36:38
-
2019-09-20 16:32:04
-
2017-08-21 12:10:12
-
2020-11-11 11:37:56
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
5Hi3516CV610 如何使用SD卡升级固件
-
5cat /dev/logmpp 报错 <3>[ vi] [func]:vi_send_frame_node [line]:99 [info]:vi pic queue is full!
-
50如何获取vpss chn的图像修改后发送至vo
-
5FPGA通过Bt1120传YUV422数据过来,vi接收不到数据——3516dv500
-
50SS928 运行PQtools 拼接 推到设备里有一半画面会异常
-
53536AV100的sample_vdec输出到CVBS显示
-
10海思板子mpp怎么在vi阶段改变视频数据尺寸
-
10HI3559AV100 多摄像头同步模式
-
9海思ss928单路摄像头vio中加入opencv处理并显示
-
10EB-RV1126-BC-191板子运行自己编码的程序
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认