📄 dvb_osd.c
字号:
EN_OSD_ERROR DVB_OSDBitmap_Load (DVB_OSD_BmpParameter *pstBmp, u8 *pu8BmpData , u16 u16Length)
{
EN_OSD_ERROR enStatus;
if (enCurrentOSDMode == EN_OSD_MODE_DISABLE)
{
return (EN_OSD_ERROR_DATA_FORMAT);
}
/*
* Check if the load bmp overlap with other bmp in the database.
*/
enStatus = DVB_OSDUpdateBmpParameter(pstBmp->u8BmpIndex,pstBmp->u16PosX, pstBmp->u16PosY, pstBmp->u16Width, pstBmp->u16Height);
if( enStatus != EN_OSD_NO_ERROR)
{
OSD_DEBUG(( "Check area fail.\n"));
return (enStatus);
}
enStatus = DVB_OSDBitmap_LoadPlus (pstBmp, pu8BmpData , OSD_FRAME_WORKING_REGION);
if( enStatus != EN_OSD_NO_ERROR)
{
OSD_DEBUG(( "BMP load fail.\n"));
return (enStatus);
}
BmpParameter[u16ToatalLoadBmp].u8BmpIndex = pstBmp->u8BmpIndex;
BmpParameter[u16ToatalLoadBmp].u16PosX = pstBmp->u16PosX;
BmpParameter[u16ToatalLoadBmp].u16PosY = pstBmp->u16PosY;
BmpParameter[u16ToatalLoadBmp].u16Width = pstBmp->u16Width;
BmpParameter[u16ToatalLoadBmp].u16Height = pstBmp->u16Height;
u16ToatalLoadBmp++;
return (EN_OSD_NO_ERROR);
}
#ifdef NO_BMP_REGION
/*******************************************************************************************/
EN_OSD_ERROR DVB_OSDBitmap_LoadPlus_No_CK (DVB_OSD_BmpParameter *pstBmp, u8 *pu8BmpData , u8 u8DstRegion)
{
OSD_BmpLoadParams stBmpLoad;
EN_CT_OSD_FRAME_REGION enDstCtRegion = EN_CT_OSD_FRAME_REGION_WORKING;
u32 u32BmpMode = 0;
u16 u16BmpWidth = 0;
u16 u16BmpHeight = 0;
u16 u16Count = 0;
u8* pu8HuffmanLineBuffer = NULL;
u32* pu32BmpSrcBuffer = NULL;
if (enCurrentOSDMode == EN_OSD_MODE_DISABLE)
{
return (EN_OSD_ERROR_DATA_FORMAT);
}
enDstCtRegion = OSD_GetCtRegionByDvbRegion(u8DstRegion);
if (pu8BmpData == NULL)
{
return (EN_OSD_ERROR_DATA_FORMAT);
}
pu32BmpSrcBuffer = (u32*)pu8BmpData;
u32BmpMode = (u32)*(pu32BmpSrcBuffer+1); // compression mode
u16BmpWidth = (u16)*(pu32BmpSrcBuffer+2); // the width
u16BmpHeight = (u16)*(pu32BmpSrcBuffer+3); // the width
pu32BmpSrcBuffer = pu32BmpSrcBuffer+4;
pstBmp->u16Width = u16BmpWidth;
pstBmp->u16Height = u16BmpHeight;
OSD_DEBUG(("bmp format %lu\n", u32BmpMode));
if(u32BmpMode==5 ) // huffman coding
{
stBmpLoad.u16PosY = pstBmp->u16PosY;
gen_point = 323;
pu8HuffmanLineBuffer = DVB_MemoryAllocate(u16BmpWidth);
if(pu8HuffmanLineBuffer==NULL)
{
OSD_DEBUG(( "huffman decode malloc fail!!\n"));
return EN_OSD_ERROR_BMP_SIZE;
}
HuffmanDecode_Init( (u8*)pu32BmpSrcBuffer, u16BmpWidth );
for(u16Count=0; u16Count<pstBmp->u16Height; u16Count++)
{
if( HuffmanDecode_GetLine( &pu8HuffmanLineBuffer[0]) ==FALSE)
{
DVB_MemoryFree(pu8HuffmanLineBuffer);
OSD_DEBUG(( "HuffmanDecode_GetLine() Fail 1\n"));
return EN_OSD_ERROR_DATA_FORMAT;
}
stBmpLoad.enRegion = enDstCtRegion;
stBmpLoad.u16PosX = pstBmp->u16PosX;
stBmpLoad.u16PosY = pstBmp->u16PosY+u16Count;
stBmpLoad.u16Width = pstBmp->u16Width;
stBmpLoad.u16Height = 1;
stBmpLoad.pu8Data = pu8HuffmanLineBuffer;
if (OSD_LoadBitmap_No_CK(u16OSDFrameHandleID, (OSD_BmpLoadParams *)&stBmpLoad) != TRUE)
{
DVB_MemoryFree(pu8HuffmanLineBuffer);
OSD_DEBUG(( "OSD_LoadBitmap() Fail\n"));
return EN_OSD_ERROR_BMP_SIZE;
}
}
DVB_MemoryFree(pu8HuffmanLineBuffer);
OSD_DEBUG(( "HuffmanDecode Success\n"));
}
else
{
stBmpLoad.enRegion = enDstCtRegion;
stBmpLoad.u16PosX = pstBmp->u16PosX;
stBmpLoad.u16PosY = pstBmp->u16PosY;
stBmpLoad.u16Width = pstBmp->u16Width;
stBmpLoad.u16Height = pstBmp->u16Height;
stBmpLoad.pu8Data = (u8*)pu32BmpSrcBuffer;
if (OSD_LoadBitmap_No_CK(u16OSDFrameHandleID, (OSD_BmpLoadParams *)&stBmpLoad) != TRUE)
{
return EN_OSD_ERROR_BMP_SIZE;
}
}
return (EN_OSD_NO_ERROR);
}
#endif // end #ifdef NO_BMP_REGION
/*******************************************************************************************/
/************************************************************************
* Unzip Icon Top or Bottom Field.
************************************************************************/
bool8 Unzip_Icon_Field(DVB_OSD_UnzipBmpParameter* pstUnzipIconParam, bool8 b8TopField)
{
u32 u32UnzipIconSrcLength = 0;
u32 u32UnzipIconDstLength = 0;
u8* pu8UnzipIconSrcBuffer = NULL;
u8* pu8UnzipIconDstBuffer = NULL;
u32 u32FieldAddr = 0;
CT_OSD_FrameHandleParams* pstFrameHandle=NULL;
bool8 enUnzipStatus;
u32 u32FieldEndAddr1 = 0;
u32 u32FieldEndAddr2 = 0;
u32 u32OSDStartAddr = 0;
u32 u32OSDEndAddr = 0;
u16 u16RegionWidth = 0;
u16 u16DisplayRegionHeight = 0;
u16 u16WorkingRegionHeight = 0;
u16 u16BitmapRegionHeight = 0;
u16 u16OSDRegionHeight = 0;
u32 u32OSDLength = 0;
pstFrameHandle = CT_OSD_GetOperationFrameHandle();
if (pstFrameHandle == NULL)
{
return FALSE;
}
u32OSDStartAddr = pstFrameHandle->stInitParams.u32FrameBufferAddr;
u16RegionWidth = pstFrameHandle->stInitParams.u16RegionWidth;
u16DisplayRegionHeight = pstFrameHandle->stInitParams.u16DisplayRegionHeight;
u16WorkingRegionHeight = pstFrameHandle->stInitParams.u16WorkingRegionHeight;
u16BitmapRegionHeight = pstFrameHandle->stInitParams.u16BitmapRegionHeight;
u16OSDRegionHeight = u16DisplayRegionHeight;
u16OSDRegionHeight += u16WorkingRegionHeight;
u16OSDRegionHeight += u16BitmapRegionHeight;
u32OSDLength = (u32) u16RegionWidth;
u32OSDLength *= ((u32) u16OSDRegionHeight);
u32OSDEndAddr = u32OSDStartAddr;
u32OSDEndAddr += u32OSDLength;
// OSD_DEBUG(("\n### u32OSDStartAddr =%lx ###\n", u32OSDStartAddr));
// OSD_DEBUG(("\n### u16RegionWidth =%x ###\n", u16RegionWidth));
// OSD_DEBUG(("\n### u16DisplayRegionHeight =%x ###\n", u16DisplayRegionHeight));
// OSD_DEBUG(("\n### u16WorkingRegionHeight =%x ###\n", u16WorkingRegionHeight));
// OSD_DEBUG(("\n### u16BitmapRegionHeight =%x ###\n", u16BitmapRegionHeight));
// OSD_DEBUG(("\n+++ u32OSDLength = %lx +++\n", u32OSDLength));
// OSD_DEBUG(("\n### u32OSDEndAddr =%lx ###\n", u32OSDEndAddr));
if (b8TopField == TRUE)
{
u32UnzipIconSrcLength = pstUnzipIconParam->u32TopFieldZipLength;
u32UnzipIconDstLength = pstUnzipIconParam->u32TopFieldBmpLength;
pu8UnzipIconSrcBuffer = pstUnzipIconParam->pu8TopFieldData;
u32FieldAddr = pstFrameHandle->u32BitmapRegionTopFieldStartAddr;
pu8UnzipIconDstBuffer = (u8*)u32FieldAddr;
// OSD_DEBUG(("\n### u32FieldAddr(TRUE) = %lx\n", u32FieldAddr));
// OSD_DEBUG(("\n### u32UnzipIconDstLength(TRUE) = %lx\n", u32UnzipIconDstLength));
u32FieldEndAddr1 = u32FieldAddr + u32UnzipIconDstLength;
// OSD_DEBUG(("\n### u32FieldEndAddr1 = %lx\n", u32FieldEndAddr1));
}
else
{
u32UnzipIconSrcLength = pstUnzipIconParam->u32BottomFieldZipLength;
u32UnzipIconDstLength = pstUnzipIconParam->u32BottomFieldBmpLength;
pu8UnzipIconSrcBuffer = pstUnzipIconParam->pu8BottomFieldData;
u32FieldAddr = pstFrameHandle->u32BitmapRegionBtmFieldStartAddr;
pu8UnzipIconDstBuffer = (u8*)u32FieldAddr;
// OSD_DEBUG(("\n### u32FieldAddr(FALSE) = %lx\n", u32FieldAddr));
// OSD_DEBUG(("\n### u32UnzipIconDstLength(FALSE) = %lx\n", u32UnzipIconDstLength));
u32FieldEndAddr2 = u32FieldAddr + u32UnzipIconDstLength;
// OSD_DEBUG(("\n### u32FieldEndAddr2 = %lx\n", u32FieldEndAddr2));
}
if( (u32FieldEndAddr1 > u32OSDEndAddr) || (u32FieldEndAddr2 > u32OSDEndAddr) )
{
OSD_DEBUG(("\n### can not use Icon !! ###\n"));
return FALSE;
}
memset(pu8UnzipIconDstBuffer, 0x00, u32UnzipIconDstLength);
enUnzipStatus = CT_SYS_Unzip(pu8UnzipIconDstBuffer, pu8UnzipIconSrcBuffer, u32UnzipIconSrcLength);
if (enUnzipStatus != TRUE)
{
OSD_DEBUG(( "\n>> Unzip_Icon_Field() : DVB_ZipUnzipProcess() Fail\r\n"));
return (FALSE);
}
return (TRUE);
} /* end Unzip_Icon_Field */
/************************************************************************
* Load ICON data to OSD frame's bitmap region.
************************************************************************/
bool8 DVB_OSDIcon_Load(DVB_OSD_UnzipBmpParameter* pstParam)
{
if ((pstParam->u32TopFieldZipLength == 0)||
(pstParam->u32BottomFieldZipLength == 0)||
(pstParam->u32TopFieldBmpLength == 0)||
(pstParam->u32BottomFieldBmpLength == 0)||
(pstParam->pu8TopFieldData == NULL)||
(pstParam->pu8BottomFieldData == NULL))
{
return (FALSE);
}
if (Unzip_Icon_Field(pstParam, TRUE) == FALSE)
{
return (FALSE);
}
if (Unzip_Icon_Field(pstParam, FALSE) == FALSE)
{
return (FALSE);
}
return (TRUE);
} /* end DVB_OSDIcon_Load */
/*******************************************************************************************/
EN_OSD_ERROR DVB_OSDBitmap_Copy(DVB_OSD_BmpParameter *pstBmp, u16 u16DestPostX, u16 u16DestPostY)
{
EN_OSD_ERROR enStatus;
bool8 b8CtStatus = FALSE;
CT_OSD_AreaCopyParam stAreaCopy;
if (enCurrentOSDMode == EN_OSD_MODE_DISABLE)
return EN_OSD_ERROR_DATA_FORMAT;
enStatus = DVB_OSDUpdateBmpParameter(pstBmp->u8BmpIndex,u16DestPostX, u16DestPostY, pstBmp->u16Width, pstBmp->u16Height);
if( enStatus != EN_OSD_NO_ERROR)
return enStatus;
// check image boundary
OSD_DEBUG(("sorce x=%d, y=%d, w=%d, h=%d\n", pstBmp->u16PosX, pstBmp->u16PosY, pstBmp->u16Width, pstBmp->u16Height));
stAreaCopy.enSrcRegion = EN_CT_OSD_FRAME_REGION_DISPLAY;
stAreaCopy.u16SrcPosX = pstBmp->u16PosX;
stAreaCopy.u16SrcPosY = pstBmp->u16PosY;
stAreaCopy.u16Width = pstBmp->u16Width;
stAreaCopy.u16Height = pstBmp->u16Height;
stAreaCopy.enDstRegion = EN_CT_OSD_FRAME_REGION_WORKING;
stAreaCopy.u16DstPosX = u16DestPostX;
stAreaCopy.u16DstPosY = u16DestPostY;
stAreaCopy.u16ColorKeyIdx = u16AreaCopyColorKeyIndex;
stAreaCopy.b8ColorKey = b8AreaCopyColorKeyEnable;
#ifdef OSD_DIRECT_ACCESS_MODE
b8CtStatus = GrFrame_RegionCopy(stAreaCopy.enDstRegion,
stAreaCopy.u16DstPosX ,
stAreaCopy.u16DstPosY,
stAreaCopy.enSrcRegion,
stAreaCopy.u16SrcPosX,
stAreaCopy.u16SrcPosY,
stAreaCopy.u16Width,
stAreaCopy.u16Height,
stAreaCopy.u16ColorKeyIdx,
stAreaCopy.b8ColorKey);
#else
b8CtStatus = CT_OSD_AreaCopy(u16OSDFrameHandleID, &stAreaCopy);
#endif
if (b8CtStatus!=TRUE)
{
return EN_OSD_ERROR_BMP_SIZE;
}
if (CT_OS_WaitOnSemaphore(&stDvbOsdSemaphore, CTOS_WAIT)!= EN_CTOS_SUCCESS)
{
return EN_OSD_ERROR_SEMAPHORE;
}
// Add to dataBase
BmpParameter[u16ToatalLoadBmp].u8BmpIndex = pstBmp->u8BmpIndex;
BmpParameter[u16ToatalLoadBmp].u16PosX = u16DestPostX;
BmpParameter[u16ToatalLoadBmp].u16PosY = u16DestPostY;
BmpParameter[u16ToatalLoadBmp].u16Width = pstBmp->u16Width;
BmpParameter[u16ToatalLoadBmp].u16Height = pstBmp->u16Height;
u16ToatalLoadBmp++;
// Free Semaphore
CT_OS_FreeSemaphore(&stDvbOsdSemaphore);
return EN_OSD_NO_ERROR;
}
/*******************************************************************************************/
EN_OSD_ERROR DVB_OSDBitmap_CopyPlus(DVB_OSD_BmpParameter *pstBmp, u16 u16DestPostX, u16 u16DestPostY, u8 u8SrcRegion, u8 u8DstRegion)
{
bool8 b8CtStatus = FALSE;
CT_OSD_AreaCopyParam stAreaCopy;
if (enCurrentOSDMode == EN_OSD_MODE_DISABLE)
return EN_OSD_ERROR_DATA_FORMAT;
stAreaCopy.enSrcRegion = OSD_GetCtRegionByDvbRegion(u8SrcRegion);
stAreaCopy.u16SrcPosX = pstBmp->u16PosX;
stAreaCopy.u16SrcPosY = pstBmp->u16PosY;
stAreaCopy.u16Width = pstBmp->u16Width;
stAreaCopy.u16Height = pstBmp->u16Height;
stAreaCopy.enDstRegion = OSD_GetCtRegionByDvbRegion(u8DstRegion);
stAreaCopy.u16DstPosX = u16DestPostX;
stAreaCopy.u16DstPosY = u16DestPostY;
stAreaCopy.u16ColorKeyIdx = u16AreaCopyColorKeyIndex;
stAreaCopy.b8ColorKey = b8AreaCopyColorKeyEnable;
#ifdef OSD_DIRECT_ACCESS_MODE
b8CtStatus = GrFrame_RegionCopy(stAreaCopy.enDstRegion,
stAreaCopy.u16DstPosX ,
stAreaCopy.u16DstPosY,
stAreaCopy.enSrcRegion,
stAreaCopy.u16SrcPosX,
stAreaCopy.u16SrcPosY,
stAreaCopy.u16Width,
stAreaCopy.u16Height,
stAreaCopy.u16ColorKeyIdx,
stAreaCopy.b8ColorKey);
#else
b8CtStatus = CT_OSD_AreaCopy(u16OSDFrameHandleID, &stAreaCopy);
#endif
if (b8CtStatus!=TRUE)
{
return EN_OSD_ERROR_BMP_SIZE;
}
return EN_OSD_NO_ERROR;
}
#ifndef NO_BMP_REGION
/*
This function will copy a block of area in region to an allocated bitmap data buffer
The allocated bitmap data buffer is linear and in WxH raster format
When to use this API :
- in pop up windows case
before pup up, backup the block of area data in region to a new allocated bitmap data buffer
it will be convenient to recover the original graphic when pop up disappear
it is like push/pop methodology in "C program calling chain
*/
EN_OSD_ERROR DVB_OSD_CopyRegionDataToBitmap(
u16 u16RegionId,
u16 u16X,
u16 u16Y,
u16 u16Width,
u16 u16Height,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -