⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdi.c

📁 ct952 source code use for Digital Frame Photo
💻 C
📖 第 1 页 / 共 5 页
字号:
}//  *********************************************************************//  Function    :   GDI_InitialRegion//  Description :   This function prepares the region by setting the header of BMP OSD//  Arguments   :   bRegionId: the ID of the region to initialize,//                             The ID is an index to the __RegionList//  Return      :   NULL//  Side Effect ://  *********************************************************************void GDI_InitialRegion(BYTE bRegionId){	WIN_PARAMETER OSD;#ifndef NO_GDI    if (bRegionId >= NUMBER_OF_REGION)        return;	OSD.sHStart =REGION_X_NTSC; //176;//164; //136; //128; //117;//176; //117; //REGION_X_NTSC;	OSD.sVStart =REGION_Y_NTSC; //72; //46; //72; //46; //REGION_Y_NTSC;	OSD.wHWidth = __RegionList[bRegionId].wWidth;	OSD.wVWidth  = __RegionList[bRegionId].wHeight;	OSD.bEnable = FALSE; // still disable OSD region now	// Set OSD size and position:	// Set REG_MCU_VCR22 and REG_MCU_VCR23	DISP_OSDSet(&OSD, OSD.wHWidth, OSD.wVWidth);#ifndef GDI_STANDALONE_LIBRARY    // if GDI is going to be a library, it should not call OSD module functions, because there may be no OSD module    // so the AP need to adjust OSD position accroding TV mode and Scan mode.        OSD_AdjustOSDPos();#endif	// Set REG_DISP_BRIGHT_CR#ifdef SUPPORT_CT909S/*	DISP_OSDEffect(					16,		// Blending mix ratio					__RegionList[bRegionId].bColorMode  //GDI_OSD_8B_MODE // color mode					);*/        // Brian2.17        DISP_OSDSetMixRatio(GDI_GENERAL_MIX_RATIO);        DISP_OSDSetColorMode(__RegionList[bRegionId].bColorMode);#else    DISP_OSDEffect(					// Brian1.10, DISPLAY module will check the duplication by OSD output window					//FALSE,	// Horizontal Duplication					//FALSE,	// Vertical Duplication					GDI_GENERAL_MIX_RATIO,		// Blending mix ratio					__RegionList[bRegionId].bColorMode //FALSE   // 4-bit mode					);#endif	// Set OSD region Base Address:	// Set REG_MCU_VCR20       // this variable is declared and refernced by DISP module.        __dwOSD_Region_Base  = __RegionList[bRegionId].dwTAddr;#endif  //#ifndef NO_GDI}void GDI_ChangeRegionHeight(BYTE bRegionId){#ifndef NO_GDI#ifndef GDI_STANDALONE_LIBRARY	extern BYTE     __bMPEGVideoMode;	WIN_PARAMETER OSD;	PARM_RECT parm;	BYTE bN2P=0;	//return ;	if (bRegionId >= NUMBER_OF_REGION)		return;	OSD.sHStart =REGION_X_NTSC;	// don't care, will adjust latter	OSD.sVStart =REGION_Y_NTSC; // don't care, will adjust latter	if (__bMPEGVideoMode == MPEG_VIDEO_MODE_NTSC)	{		if ( __RegionList[bRegionId].wHeight != GDI_REGION_HEIGHT)		{			__RegionList[bRegionId].wHeight = GDI_REGION_HEIGHT;		}		else			return;       }	else	{		if ( __RegionList[bRegionId].wHeight != GDI_REGION_HEIGHT_PAL)		{			__RegionList[bRegionId].wHeight = GDI_REGION_HEIGHT_PAL;			bN2P = 1;		}		else			return;	}	OSD.wHWidth = __RegionList[bRegionId].wWidth;	OSD.wVWidth  = __RegionList[bRegionId].wHeight;	if (!_bGDIInit)	{		OSD.bEnable = FALSE;	}	else	{		OSD.bEnable = TRUE; // suppose OSD is enabled when calling this function	}	// Set OSD size and position:	// Set REG_MCU_VCR22 and REG_MCU_VCR23	DISP_OSDSet(&OSD, OSD.wHWidth, OSD.wVWidth);	printf("PAL/NTSC mode change\n");        __dwOSD_Region_Base  = __RegionList[bRegionId].dwTAddr;	if (bN2P)	{		// Clear the extra PAL area		parm.bColor = PAL_ENTRY_COLOR_TRANSPARENT; //14; //PAL_ENTRY_COLOR_TRANSPARENT; // transparenct color is the last entry		parm.rect.wLeft = 0;		parm.rect.wTop = GDI_REGION_HEIGHT;		parm.rect.wRight = __RegionList[bRegionId].wWidth -1;		parm.rect.wBottom = __RegionList[bRegionId].wHeight -1;		GDI_FillRect(bRegionId, &parm);	}#endif#endif  //#ifndef NO_GDI}//  *********************************************************************//  Function    :   GDI_ClearRegion//  Description :   This function clears the entire region to transparent color//  Arguments   :   bRegionId: the ID of the region to initialize,//                             The ID is an index to the __RegionList//  Return      :   NOne//  Side Effect ://  *********************************************************************void GDI_ClearRegion(BYTE bRegionId){#ifndef NO_GDI	PARM_RECT parm;	parm.bColor = PAL_ENTRY_COLOR_TRANSPARENT; //14; //PAL_ENTRY_COLOR_TRANSPARENT; // transparenct color is the last entry	parm.rect.wLeft = 0;	parm.rect.wTop = 0;	parm.rect.wRight = __RegionList[bRegionId].wWidth -1;	parm.rect.wBottom = __RegionList[bRegionId].wHeight -1;	GDI_FillRect(bRegionId, &parm);#endif  //#ifndef NO_GDI}//  *********************************************************************//  Function    :   GDI_ActivateRegion//  Description :   This function prepares the region by setting the header of BMP OSD//  Arguments   :   bPlaneId: the ID of the plane to be mapped with current region,//                             The ID is an index to the __PlaneList//  Return      :   TRUE:   function succeeded//                  FALSE:  function failed//  Side Effect ://  *********************************************************************void GDI_ActivateRegion(BYTE bRegionId){#ifndef NO_GDI        if (!_bGDIInit) // Brian1.20        {            return;        }	//DISP_OSDEnable(TRUE);	DISP_DisplayCtrl(DISP_OSD, TRUE);#endif  //#ifndef NO_GDI}//  *********************************************************************//  Function    :   GDI_DeactivateRegion//  Description :   This function deactivate the region mapped with plane//  Arguments   :   none//  Return      :   none//  Side Effect ://  *********************************************************************void GDI_DeactivateRegion(void){#ifndef NO_GDI    //DISP_OSDEnable(FALSE);	DISP_DisplayCtrl(DISP_OSD, FALSE);       //OS_DelayTime(COUNT_50_MSEC); // Brian2.21, need to wait until completed#ifndef SUPPORT_STB   //Alan2.31a, patch for the OSD disappearance bug of DVB       DISP_DelayVSYNC(1);#endif#endif  //#ifndef NO_GDI}//  *********************************************************************//  Function    :   GDI_MoveRegion//  Description :   This function moves the entire region//  Arguments   :   None//  Global Var  :   __wGDIx, __wGDIy: the new start point of the region//  Return      :   none//  Side Effect ://  *********************************************************************void GDI_MoveRegion(BYTE bRegionId, SHORT sX, SHORT sY){#ifndef NO_GDI    WIN_PARAMETER OSD;    if (bRegionId >= NUMBER_OF_REGION)        return;	OSD.sHStart = sX; //176;//164; //136; //128; //117;//176; //117; //REGION_X_NTSC;	OSD.sVStart = sY; //72; //46; //72; //46; //REGION_Y_NTSC;	OSD.wHWidth = __RegionList[bRegionId].wWidth;	OSD.wVWidth  = __RegionList[bRegionId].wHeight;#ifdef SUPPORT_CT909S       if (REG_DISP_OSD_SIZE & 0x10000000) // bit 28: OSD enable  bit#else       if (REG_DISP_OSD_SIZE & 0x800) // bit 11: OSD enable  bit#endif       {	    OSD.bEnable = TRUE;       }       else       {	    OSD.bEnable = FALSE;       }	// Set OSD size and position:	// Set REG_MCU_VCR22 and REG_MCU_VCR23	DISP_OSDSet(&OSD, OSD.wHWidth, OSD.wVWidth);#endif  //#ifndef NO_GDI}//  *********************************************************************//  Function    :   GDI_SetMixRatio//  Description :   This function sets the mix ratio of the current region//  Arguments   :   bMixRatio: the mix ratio, 0~63//  Return      :   none//  Side Effect ://  *********************************************************************void GDI_SetMixRatio(BYTE bMixRatio){#ifndef NO_GDI// be careful, better use a dedicate set mix ratio function    // Set REG_DISP_BRIGHT_CR#ifdef SUPPORT_CT909S/*	DISP_OSDEffect(					bMixRatio,		// Blending mix ratio					GDI_OSD_8B_MODE // color mode					);*/        // Brian2.17        DISP_OSDSetMixRatio(bMixRatio);#else    DISP_OSDEffect(			        // Brian1.10, DISPLAY module will check the duplication by OSD output window					//FALSE,	// Horizontal Duplication					//FALSE,	// Vertical Duplication					bMixRatio, // Blending mix ratio					FALSE   // 4-bit mode					);#endif#endif  //#ifndef NO_GDI}#if 0DWORD COMUTL_RGB2YUV(DWORD dwRGB){	BYTE _bCOMUTLTmp1, _bCOMUTLTmp2, _bCOMUTLTmp3;	UDWORD uDWord;	DWORD __dwCOMUTLTemp;    // use uDWord.cS[0] ~ [3] to store YUV value    // use _wCOMUTLTemp to store final value    // Step 0: split RGB value    _bCOMUTLTmp1=(RGB_R(dwRGB));    _bCOMUTLTmp2=(RGB_G(dwRGB));    _bCOMUTLTmp3=(RGB_B(dwRGB));// Micky1.20, 4M flash, reduce common bank lib.// don't use float point.// can't use DWORD, must use signed operation#ifdef  NO_FLOAT_POINT    // Step 1: Calculate YUV value depending on input RGB    uDWord.cS[0]=(BYTE)(16+(65738L*(long)_bCOMUTLTmp1                      +129057L*(long)_bCOMUTLTmp2                      +25064L*(long)_bCOMUTLTmp3)/256000);  // Y value    uDWord.cS[1]=(BYTE)(128+(-37945L*(long)_bCOMUTLTmp1                       -74494L*(long)_bCOMUTLTmp2                       +112439L*(long)_bCOMUTLTmp3)/256000); // U value    uDWord.cS[2]=(BYTE)(128+(112439L*(long)_bCOMUTLTmp1                       -94154L*(long)_bCOMUTLTmp2                       -18285L*((long)_bCOMUTLTmp3)/256000));  // V value// debug the value between float and long// float > long by 1./*    uWord.cS[0]=(BYTE)(16+(65738*(float)_bCOMUTLTmp1                      +129057*(float)_bCOMUTLTmp2                      +25064*(float)_bCOMUTLTmp3)/256000);  // Y value    uWord.cS[1]=(BYTE)(128+(-37945*(float)_bCOMUTLTmp1                       -74494*(float)_bCOMUTLTmp2                       +112439*(float)_bCOMUTLTmp3)/256000); // U value    uWord.cS[1]=(BYTE)(128+(112439*(float)_bCOMUTLTmp1                       -94154*(float)_bCOMUTLTmp2                       -18285*(float)_bCOMUTLTmp3)/256000);  // V value    if (uDWord.cS[2] != uWord.cS[1])        printf("\nError");*/#else    // Step 1: Calculate YUV value depending on input RGB    uDWord.cS[0]=(BYTE)(16+(65738*(float)_bCOMUTLTmp1                      +129057*(float)_bCOMUTLTmp2                      +25064*(float)_bCOMUTLTmp3)/256000);  // Y value    uDWord.cS[1]=(BYTE)(128+(-37945*(float)_bCOMUTLTmp1                       -74494*(float)_bCOMUTLTmp2                       +112439*((float)_bCOMUTLTmp3)/256000)); // U value    uDWord.cS[2]=(BYTE)(128+(112439*(float)_bCOMUTLTmp1                       -94154*(float)_bCOMUTLTmp2                       -18285*((float)_bCOMUTLTmp3)/256000));  // V value#endif    // Step 2: merge YUV value into DWORD unit and match OSD spec.	__dwCOMUTLTemp=(MAKE_RGB(uDWord.cS[0], uDWord.cS[1], uDWord.cS[2]));    return  __dwCOMUTLTemp;}#endif//  *********************************************************************//  Function    :   GDI_ChangePALEntry//  Description :   This function sets one palette entry//  Arguments   :   bIdx: the entry index//                  dwRGB:  the color value to set//                  bMixEnable: TRUE/FALSE//  Return      :   none//  Side Effect ://  *********************************************************************void GDI_ChangePALEntry(BYTE bIdx, DWORD dwRGB, BYTE bMixEnable){#ifndef NO_GDI	DWORD dwTemp;     if (bIdx == PAL_ENTRY_COLOR_TRANSPARENT) // Brian2.17, protect transparency entry     {        return;     }    // one palette entry uses one DWORD    // if the highest byte == 0x5A, the parameter is already in YCbCr format    //if ((dwRGB & 0xFF000000 )== GDI_VALUE_YUV)    if ((dwRGB & 0xFE000000 )== GDI_VALUE_YUV) // bit 24 is used for mix_en, so skip this bit    {		dwTemp = (dwRGB & 0xFFFFFF); // it is YCbCr already    }    else    {		dwTemp =COMUTL_RGB2YUV(dwRGB);    }    // enable the mix_en bit [24]    dwTemp |= (((DWORD)bMixEnable)<<24);    // set desired entry value    _dwGDIPalette[bIdx] = dwTemp;#ifdef SUPPORT_CT909S    DISP_SetPalette(_dwGDIPalette);#else    DISP_SetPalette(FALSE, _dwGDIPalette);#endif#endif  // #ifndef NO_GDI}// Brian0.95void GDI_WaitPaletteComplete(void){	//UTL_DelayTime(COUNT_50_MSEC, FALSE);    //return;	// Brian1.02,#if 0 //ndef GDI_WITHOUT_OS	// *** must use development tool >=1.02, otherwise the flag_time_wait will hang    if (!OS_TimedWaitFlag(&__fDISPInfo, DISP_INFO_SETPALETTE_DONE, FLAG_WAITMODE_OR, COUNT_50_MSEC))    {        // wait palette complete time out        printf("GDI wait palette complete time out");    }#else

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -