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

📄 sfli2310.c

📁 Fil2310.c De-interlace芯片源码
💻 C
📖 第 1 页 / 共 5 页
字号:
//				part of the Film Edit descriptor data structure. 
//
// DESCRIPTION:	
//
// INPUT:		Stp_FEDesc	- film edit processing config descriptor
//
// OUTPUT:		None
//
// GLOBALS:		gB_Fli2300NRDCtrl7Shadow, gB_Fli2300NRDCtrl10Shadow
//
// USED_REGS:	NRD_CTRL_7, NRD_EDIT_1
//*******************************************************************************
void fli2300_ConfigureFilmEditProcess(Fli2300FilmEditDesc_t *Stp_FEDesc)	
{
	BYTE B_CtrlValue = 0;

	//Threshold settings
	gB_Fli2300NRDCtrl7Shadow &= 0xF0;
	gB_Fli2300NRDCtrl7Shadow |= Stp_FEDesc->MotionThreshold & 0x0F;
	fli2300_Write08(NRD_CTRL_7, gB_Fli2300NRDCtrl7Shadow);

	fli2300_Write08(NRD_EDIT_TEST1, Stp_FEDesc->EditThreshold1);
	fli2300_Write08(NRD_EDIT_TEST2, Stp_FEDesc->EditThreshold2);
	fli2300_Write08(NRD_EDIT_TEST3, Stp_FEDesc->EditThreshold3);
	fli2300_Write08(NRD_EDIT_MOVEDGE_THRESHOLD, Stp_FEDesc->MovingEdgeDetectThreshold);

	//Real time edit correction disable
	gB_Fli2300NRDCtrl10Shadow &= 0xFC;
	gB_Fli2300NRDCtrl10Shadow |= 0x02;
	fli2300_Write08(NRD_CTRL_10, gB_Fli2300NRDCtrl10Shadow);

} // end - fli2300_ConfigureFilmEditProcess


//*******************************************************************************
// FUNCTION:	void fli2300_ConfigureMotionProcess(Fli2300MotionProcessDesc_t
//														 *Stp_MotionDesc)	
//
// USAGE:		Configures the Deinterlacer Motion processing
//					processing mode, detection thresholds, 
//					processing thresholds
//				The configuration parameters for the Motion processing  are
//				part of the Motion processing descriptor data structure. 
//
// DESCRIPTION:	
//
// INPUT:		Stp_MotionDesc	- Motion processing config descriptor
//
// OUTPUT:		None
//
// GLOBALS:		gB_Fli2300NRDCtrl1Shadow, gB_Fli2300NRDCtrl10Shadow
//
// USED_REGS:	NRD_CTRL_1, NRD_CTRL_6, NRD_FILMS_1
//*******************************************************************************
void fli2300_ConfigureMotionProcess(Fli2300MotionProcessDesc_t *Stp_MotionDesc)
{
	gB_Fli2300NRDCtrl1Shadow &= 0xCF;
	gB_Fli2300NRDCtrl1Shadow |= Stp_MotionDesc->ProcessingMode;
	fli2300_Write08(NRD_CTRL_1, gB_Fli2300NRDCtrl1Shadow);

	// motion thresholds
	fli2300_Write08(NRD_MTN_MLPF_THRESHOLD, Stp_MotionDesc->LPFThreshold);

	//motion expansion window
	gB_Fli2300NRDCtrl10Shadow &= 0x1F;
	gB_Fli2300NRDCtrl10Shadow |= ((Stp_MotionDesc->HExpansion & 0x03) << 5);
	gB_Fli2300NRDCtrl10Shadow |= ((Stp_MotionDesc->VExpansion & 0x01) << 7);
	fli2300_Write08(NRD_CTRL_10, gB_Fli2300NRDCtrl10Shadow);

} // end - fli2300_ConfigureMotionProcess


//*******************************************************************************
// FUNCTION:	void fli2300_ConfigureFleshToneCtrl(Fli2300FleshToneDesc_t
//													 *Stp_FTDesc)	
//
// USAGE:		Configures the Fleshtone processing
//					processing levels and color window 
//				The configuration parameters for the Fleshtone processing  are
//				part of the Fleshtone processing descriptor data structure. 
//
// DESCRIPTION:	
//
// INPUT:		Stp_FTDesc	- Fleshtone processing config descriptor
//
// OUTPUT:		None
//
// GLOBALS:
//
// USED_REGS:	
//*******************************************************************************
void fli2300_ConfigureFleshToneCtrl(Fli2300FleshToneDesc_t *Stp_FTDesc)
{
	// control
	gB_Fli2300NRDCtrl11Shadow = 0x00; // DEBUG
	if (Stp_FTDesc->FleshToneEnable == EnDisCtrl_Enable)
		gB_Fli2300NRDCtrl11Shadow |= 0x01;
	gB_Fli2300NRDCtrl11Shadow |= (Stp_FTDesc->MaxRecursionLevel & 0x0F) << 2;
	
	fli2300_Write08(NRD_CTRL_11, gB_Fli2300NRDCtrl11Shadow);

	// window
	fli2300_Write08(NRD_FT_UMIN, Stp_FTDesc->DetectWindowCbMin);
	fli2300_Write08(NRD_FT_VMIN, Stp_FTDesc->DetectWindowCrMin);
	fli2300_Write08(NRD_FT_UMAX, Stp_FTDesc->DetectWindowCbMax);
	fli2300_Write08(NRD_FT_VMAX, Stp_FTDesc->DetectWindowCrMax);
	fli2300_Write08(NRD_FT_UVDIFF, Stp_FTDesc->DetectWindowCbCrDiff);

} // end - fli2300_ConfigureFleshToneCtrl


//*******************************************************************************
// FUNCTION:	BYTE fli2300_GetNRDProcessingStatus(void)
//
// USAGE:		Returns the status of NRD processing
//
// DESCRIPTION:	
//
// INPUT:		None
//
// OUTPUT:		Status 
//					bit 0 =	0 - non-standard definition video
//							1 - standard definition video
//					bit 1 =	0 - 625 line signal 
//							1 - 525 line signal
//					bit 2 =	0 - 2:2 pull down
//							1 - 3:2 pull down
//					bit 3 =	0 - film mode not detected
//							1 - filim mode detected
// GLOBALS:
//
// USED_REGS:	NRD_STATUS_0
//*******************************************************************************
BYTE fli2300_GetNRDProcessingStatus(void)
{
	BYTE B_Status;

	//fli2300_Read(NRD_STATUS_0, BYTE_RD, (BYTE *)&B_Status);
	B_Status = fli2300_Read08(NRD_STATUS_0);
	return B_Status;

} // end - fli2300_GetNRDProcessingStatus

//*******************************************************************************
// FUNCTION:	BYTE fli2300_GetNRDNoiseMeterLevel(void)
//
// USAGE:		Returns the status of NRD processing Noise meter noise level
//
// DESCRIPTION:	
//
// INPUT:		None
//
// OUTPUT:		Status 
//
// GLOBALS:
//
// USED_REGS:	NRD_STATUS_1
//*******************************************************************************
BYTE fli2300_GetNRDNoiseMeterLevel(void)
{
	BYTE B_Level;

//	fli2300_Read(NRD_STATUS_1, BYTE_RD, (BYTE *)&B_Level);
	B_Level = fli2300_Read08(NRD_STATUS_1);
	return B_Level;

} // end - fli2300_GetNRDNoiseMeterLevel


//*******************************************************************************
// FUNCITON:	void fli2300_ConfigureFilmModeWindow(Fli2300Sdtv_t SdtvType,
//									 Fli2300CaptureDesc_t *Stp_CaptureDesc,
//									 Fli2300NRDBlankDesc_t *Stp_BlankDesc);
//
// USAGE:		This module programs film mode window definitions
//				Number of pixels to blanked on left - the recommended valued is 16
//				Number of pixels to blanked on right- the recommended valued is 50
//				Number of lines to blanked on top - the recommended valued is 16
//				Number of lines to blanked on bottom - the recommended valued is 12
//
//				This function should be called on mode change after identifying
//				new mode parameters
//
// DESCRIPTION:	Horizontal film blanking is placed wrt to HSAV pulse 
//				Vertical film blanking is placed wrt to raising edge of VREF
//				 49 clocks of delay in video path wrt to HSAV pulse
//
// INPUT:		SdtvType	- sdtv type 525i or 625i
//				Stp_CaptureDesc - pointer to capture desc
//				Stp_BlankDesc - pointer to blank desc
//
// OUTPUT:		None
//
//
// USED_REGS:	
//*******************************************************************************
void fli2300_ConfigureFilmModeWindow(Fli2300Sdtv_t SdtvType,
									 Fli2300CaptureDesc_t *Stp_CaptureDesc,
									 Fli2300NRDBlankDesc_t *Stp_BlankDesc)
{
	WORD W_Vblank;
	WORD W_LeftBlank;
	WORD W_RightBlank;
	WORD W_TopBlank;
	WORD W_BottomBlank;
	WORD W_Hblank;

	switch (Stp_CaptureDesc->SignalType)
	{
		case Fli2300InputCtrlSig_Embedded:
			W_LeftBlank = 49 + Stp_BlankDesc->LeftBlank;
			W_RightBlank = 49 + Stp_CaptureDesc->HActive - Stp_BlankDesc->RightBlank;  

			// in this case the raising edge of VREF = EAV
			W_Vblank = Stp_CaptureDesc->VTotal - Stp_CaptureDesc->VActive;
			W_TopBlank = W_Vblank + Stp_BlankDesc->TopBlank;
			W_BottomBlank = W_Vblank + Stp_CaptureDesc->VActive - Stp_BlankDesc->BottomBlank;
			break;

		case Fli2300InputCtrlSig_Ref: 
			W_LeftBlank = 49 + Stp_BlankDesc->LeftBlank;
			W_RightBlank = 49 + Stp_CaptureDesc->HActive - Stp_BlankDesc->RightBlank;  

			// remember the invert control bit is common for H and V in SDTV path
			if (Stp_CaptureDesc->VPolarity == Stp_CaptureDesc->HPolarity)
			{
				//in this case the raising edge of VREF = SAV
				W_TopBlank = Stp_BlankDesc->TopBlank;
				W_BottomBlank = Stp_CaptureDesc->VActive - Stp_BlankDesc->BottomBlank;
			}
			else // not equal
			{
				// in this case the raising edge of VREF = EAV
				W_Vblank = Stp_CaptureDesc->VTotal - Stp_CaptureDesc->VActive;
				W_TopBlank = W_Vblank + Stp_BlankDesc->TopBlank;
				W_BottomBlank = W_Vblank + Stp_CaptureDesc->VActive - Stp_BlankDesc->BottomBlank;
			}
			break;

		case Fli2300InputCtrlSig_Sync: 
		{
//SOI move to the top			WORD W_Hblank;

			W_Hblank = Stp_CaptureDesc->HActiveStart;
			if (SdtvType == Fli2300Sdtv_525I) 
			{
				if (W_Hblank >= 134)
					W_Hblank = W_Hblank - 134;
				else
					W_Hblank = 0;
			}
			if (SdtvType == Fli2300Sdtv_625I) 
			{
				if (W_Hblank >= 140)
					W_Hblank = W_Hblank - 140;
				else
					W_Hblank = 0;
			}
			W_LeftBlank = 49 + W_Hblank + Stp_BlankDesc->LeftBlank;  
			W_RightBlank = 49 + W_Hblank + Stp_CaptureDesc->HActive - Stp_BlankDesc->RightBlank;  

			// In this case the VREF is active Low and the raising edge = EAV
			// remember in case of Sync based input the EAV position is hard-coded 
			// - 3 line before falling edge of sync
			// remember the invert control bit is common for H and V in SDTV path
			if (Stp_CaptureDesc->VPolarity == Stp_CaptureDesc->HPolarity)
				W_Vblank = 3 + Stp_CaptureDesc->VSyncWidth + Stp_CaptureDesc->VBackPorch;
			else
				W_Vblank = 3 + Stp_CaptureDesc->VBackPorch;

			W_TopBlank =  W_Vblank + Stp_BlankDesc->TopBlank;
			W_BottomBlank = W_Vblank + Stp_CaptureDesc->VActive - Stp_BlankDesc->BottomBlank;
			break;
		}

		default:
			return;
	} // end switch - Stp_CaptureDesc->SignalType

	W_RightBlank = W_RightBlank % Stp_CaptureDesc->HTotal;
	// line doubled calculation
	W_TopBlank = W_TopBlank * 2; 
	W_BottomBlank = W_BottomBlank * 2;

	fli2300_Write16(NRD_FBLNK_L_L, W_LeftBlank);
	fli2300_Write16(NRD_FBLNK_R_L, W_RightBlank);
	fli2300_Write16(NRD_FBLNK_T_L, W_TopBlank);
	if (SdtvType == Fli2300Sdtv_525I) // 525i input
		fli2300_Write16(NRD_FBLNK_B_N_L, W_BottomBlank);
	if (SdtvType == Fli2300Sdtv_625I) // 625i input
		fli2300_Write16(NRD_FBLNK_B_P_L, W_BottomBlank);

	//SOI PRINT(("Nrd FM : %d : %d : %d : %d\n",W_LeftBlank,W_RightBlank,W_TopBlank,W_BottomBlank));

} // end - fli2300_ConfigureFilmModeWindow


//*******************************************************************************
// FUNCITON:	void fli2300_ConfigureFilmEditWindow(Fli2300Sdtv_t SdtvType,
//									  Fli2300CaptureDesc_t *Stp_CaptureDesc,
//									  Fli2300NRDBlankDesc_t *Stp_BlankDesc)
//
// USAGE:		This module programs film Edit window definitions
//				Number of pixels to blanked on left - the recommended valued is 16
//				Number of pixels to blanked on right- the recommended valued is 50
//				Number of lines to blanked on top - the recommended valued is 16
//				Number of lines to blanked on bottom - the recommended valued is 12
//
// DESCRIPTION:	Horizontal Edit blanking is placed wrt to HSAV pulse 
//				Vertical Edit blanking is placed wrt to raising edge of VREF
//				9 clocks of delay in video path wrt to HSAV pulse
//
// INPUT:		SdtvType	- sdtv type 525i or 625i
//				Stp_CaptureDesc - pointer to capture desc
//				Stp_BlankDesc - pointer to blank desc
//
// OUTPUT:		None
//
//
// USED_REGS:	
//*******************************************************************************
void fli2300_ConfigureFilmEditWindow(Fli2300Sdtv_t SdtvType,
									  Fli2300CaptureDesc_t *Stp_CaptureDesc,
									  Fli2300NRDBlankDesc_t *Stp_BlankDesc)
{
	WORD W_Vblank;
	WORD W_LeftBlank;
	WORD W_RightBlank;
	WORD W_TopBlank;
	WORD W_BottomBlank;
	WORD W_Hblank;

	switch (Stp_CaptureDesc->SignalType)
	{
		case Fli2300InputCtrlSig_Embedded:
			W_LeftBlank = 9 + Stp_BlankDesc->LeftBlank;
			W_RightBlank = 9 + Stp_CaptureDesc->HActive - Stp_BlankDesc->RightBlank;  

			// in this case the raising edge of VREF = EAV
			W_Vblank = Stp_CaptureDesc->VTotal - Stp_CaptureDesc->VActive;
			W_TopBlank = W_Vblank + Stp_BlankDesc->TopBlank;
			W_BottomBlank = W_Vblank + Stp_CaptureDesc->VActive - Stp_BlankDesc->BottomBlank;
			break;

		case Fli2300InputCtrlSig_Ref: 
			W_LeftBlank = 9 + Stp_BlankDesc->LeftBlank;
			W_RightBlank = 9 + Stp_CaptureDesc->HActive - Stp_BlankDesc->RightBlank;  

			// remember the invert control bit is common for H and V in SDTV path
			if (Stp_CaptureDesc->VPolarity == Stp_CaptureDesc->HPolarity)
			{
				//in this case the raising edge of VREF = SAV
				W_TopBlank = Stp_BlankDesc->TopBlank;
				W_BottomBlank = Stp_CaptureDesc->VActive - Stp_BlankDesc->BottomBlank;
			}
			else // not equal
			{
				// in this case the raising edge of VREF = EAV
				W_Vblank = Stp_CaptureDesc->VTotal - Stp_CaptureDesc->VActive;
				W_TopBlank = W_Vblank + Stp_BlankDesc->TopBlank;
				W_BottomBlank = W_Vblank + Stp_CaptureDesc->VActive - Stp_BlankDesc->BottomBlank;
			}
			break;

		case Fli2300InputCtrlSig_Sync: 
		{
//SOI move to the top			WORD W_Hblank;

			W_Hblank = Stp_CaptureDesc->HActiveStart;
			if (SdtvType == Fli2300Sdtv_525I) 
			{
				if (W_Hblank >= 134)
					W_Hblank = W_Hblank - 134;
				else
					W_Hblank = 0;
			}
			if (SdtvType == Fli2300Sdtv_625I) 
			{
				if (W_Hblank >= 140)
					W_Hblank = W_Hblank - 140;
				else
					W_Hblank = 0;
			}
			W_LeftBlank = 9 + W_Hblank + Stp_BlankDesc->LeftBlank;  
			W_RightBlank = 9 + W_Hblank + Stp_CaptureDesc->HActive - Stp_BlankDesc->RightBlank;  

			// In this case the VREF is active Low and the raising edge = EAV
			// remember in case of Sync based input the EAV position is hard-coded 
			// - 3 line before falling edge of sync
			// remember the invert control bit is common for H and V in SDTV path
			if (Stp_CaptureDesc->VPolarity == Stp_CaptureDesc->HPolarity)
				W_Vblank = 3 + Stp_CaptureDesc->VSyncWidth + Stp_CaptureDesc->VBackPorch;
			else
				W_Vblank = 3 + Stp_CaptureDesc->VBackPorch;

			W_TopBlank =  W_Vblank + Stp_BlankDesc->TopBlank;
			W_BottomBlank = W_Vblank + Stp_CaptureDesc->VActive - Stp_BlankDesc->BottomBlank;
			break;
		}

		default:
			return;
	} // end switch - Stp_CaptureDesc->SignalType

	W_RightBlank = W_RightBlank % Stp_CaptureDesc->HTotal;
	// line doubled calculation
	W_TopBlank = W_TopBlank * 2; 

⌨️ 快捷键说明

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