各位,
我想在我的视频上叠加logo, logo我使用的是IPNC自带的默认数组,代码如下:
1. Init:
if(SWOSD_init()!=0) /* Run SW OSD*/
[
printf(" SWOSD: SWOSD_init Failure................. n");
return FAIL;
]
iconBuff160_Y = (char *)OSD_CMEM_ALLOC((SWOSD_CHARWIDTH tiLOGO_160_64*SWOSD_CHARHEIGHTTILOGO_160_64), 32) ;
iconBuff160_UV = (char *)OSD_CMEM_ALLOC(((SWOSD_CHARWIDTHTILOGO_160_64*SWOSD_CHARHEIGHTTILOGO_160_64)/2), 32);
swosdSetLogoPrm();
for(i=0; i<2; i++)
[
if(SWOSD_createHandle(&osdHndl, &idxHndl ) != GS_SUCCESS)
[
printf("Handle Creation Failed in SWOSD(%d).............", i);
return FAIL;
]
else
[
//Setting for 32 BMP windows currently
if(SWOSD_setNumWindows(osdHndl, SWOSD_WINMAX)!=0) /* Run SW OSD*/
[
printf(" SWOSD: SWOSD_setNumWindows Failure................. n");
return FAIL;
]
swosdSetWinParam(height, width);
//swosdMakeFixWinString(i);
]
algSwosdHndl = osdHndl;
]
static inline void swosdSetLogoPrm(void)
[
OSD_MEMCPY(iconBuff160_Y, TILogo_Y_160_64, SWOSD_CHARWIDTHTILOGO_160_64*SWOSD_CHARHEIGHTTILOGO_160_64);
OSD_MEMCPY(iconBuff160_UV, TILogo_UV_160_64, (SWOSD_CHARWIDTHTILOGO_160_64*SWOSD_CHARHEIGHTTILOGO_160_64)/2);
]
static int swosdSetWinParam(int height, int width)
[
SWOSD_BmpWinPrm bmpWinPrm;
int i = 0;
#ifdef SWOSD_USER_TRANSPARANCY_ON
bmpWinPrm.userTransparancy = SWOSD_RBOOLTRUE;
#else
bmpWinPrm.userTransparancy = SWOSD_RBOOLFALSE;
#endif
//for window 1
bmpWinPrm.enable = SWOSD_RBOOLFALSE;
bmpWinPrm.format = SWOSD_FORMATYUV420p;
bmpWinPrm.startX = 0;
bmpWinPrm.startY = 0;
bmpWinPrm.width = SWOSD_CHARWIDTHTILOGO_160_64;
bmpWinPrm.height = SWOSD_CHARHEIGHTTILOGO_160_64;
bmpWinPrm.lineOffset = SWOSD_CHARWIDTHTILOGO_160_64;
bmpWinPrm.transperencyVal = SWOSD_OSDWHITETRANSVAL;
bmpWinPrm.transperencyRange = SWOSD_OSDWHITETRANSRANGE;
bmpWinPrm.transperencyEnable = SWOSD_BMPTRANSDISABLE;
bmpWinPrm.resizeEnable = 0;
bmpWinPrm.bmpWinAddr = iconBuff160_Y;
bmpWinPrm.bmpWinAddrUV = iconBuff160_UV;
if(SWOSD_setBmpWinPrm(osdHndl, SWOSD_WINDOW_ONE, &bmpWinPrm)!=0)
[
printf(" SWOSD: SWOSD_setBmpWinPrm Failure................. n");
return FAIL;
]
return SUCCESS;
]
2. Then call this function VIDEO_swosdTskRun() in the while loop of CAPTURE_ThrFxn():
int VIDEO_swosdTskRun(int streamId,int width, int height, int frameRate,void *pBufInfo)
[
int startX = 0;
int startY = 0;
SWOSD_MainWinPrm mainWinPrm;
static int osd_count[AVSERVER_MAX_STREAMS] = [0, 0, 0, 0];
//if(gAVSERVER_config.captureConfig[streamId].swosdConfig.swosdEnable)
[
osdHndl = (SWOSD_Hndl *)algSwosdHndl[streamId];
mainWinPrm.format = SWOSD_FORMATYUV420p;
mainWinPrm.lineOffset = width;
mainWinPrm.width = width;
mainWinPrm.height = height - OSA_floor(startY, 2 )/2;
/*OSD does not take care of Vertical offset, therefore care is needed to read UV data*/
if(SWOSD_setMainWinPrm(osdHndl, &mainWinPrm)!=0)
[
printf(" SWOSD: SWOSD_setMainWinPrm Failure................. n");
return FAIL;
]
if(osd_count[streamId]>=(frameRate/1000))
[
swosdDisplay(streamId, osdHndl);
osd_count[streamId] = 0;
]
else
osd_count[streamId]++;
SWOSD_MsgRecvHandler();
if(SWOSD_winDrawHandle(osdHndl, (short*)(pBufInfo))!=0)
[
printf(" SWOSD: SWOSD_winDrawHandle Failure................. n");
return FAIL;
]
]
return SUCCESS;
]
static int swosdDisplay(int streamId, SWOSD_Hndl *osdHndl )
[
int i = 0;
swosdMakeWinString(streamId);
//swosdChangeXYPARMDetail(streamId, osdHndl);
if(SWOSD_setBmpWinEnable(osdHndl, SWOSD_WINDOW_ONE, SWOSD_BMPWINENABLE)!=0)
[
printf(" SWOSD: SWOSD_setBmpWinEnable Failure................. n");
return FAIL;
]
return SUCCESS;
]
static int swosdMakeWinString(int streamId)
[
if(SWOSD_setBmpchangeWinXYPrm(osdHndl, SWOSD_WINDOW_ONE, 0, 0)!=0)
[
printf(" SWOSD: SWOSD_setBmpchangeWinXYPrm Failure................. n");
return FAIL;
]
return SUCCESS;
]
其中streamID=0; width=1280;height=720;framerate=30000; pBufInfo=capBuf[0].start
我设置的SWOSD_setNumWindows(osdHndl, SWOSD_WINMAX) 用的SWOSD_WINMAX=28,参考代码原本的值
然后我所有函数都只有对SWOSD_WINDOW_ONE操作,其他窗口没有相关代码,这个可以只用一个窗口吧??
运行没有出错返回,但是没有看到有logo出现,只有正常的采集过来的视频。。。
我是哪里出错了呢?搞不清楚为什么,需要什么其他的配置?还是库用错了?我用的是framework/alg/lib/alg_osd_ti.a ,这个可以直接用吧,还是需要重新编译的?
麻烦大家帮我解答一下,谢谢。
0
|
|
|
|