📄 scaler.cpp
字号:
{
m_lines = min(m_ptrVideoIn->Max_Lines,
max((WORD)clientScr.Height(), m_ptrVideoIn->Min_Lines));
WORD LPB_VScale_Factor = (WORD) (1 + (m_lines - 1) / m_ptrVideoIn->Active_lines_per_field);
m_lines = (WORD) ((m_lines + LPB_VScale_Factor - 1) / LPB_VScale_Factor);
LONG a = (LONG)m_ptrVideoIn->Active_lines_per_field * 512L / (LONG)m_lines;
WORD VScale = (WORD) ((0x10000L - a + 512L) & 0x1FFFL);
regVScale = VScale;
}
/////////////////////////////////////////////////////////////////////////////
// Method: void Scaler::SetVDelay()
// Purpose: Set VDelay register
// Input: None
// Output: None
// Return: None
/////////////////////////////////////////////////////////////////////////////
void Scaler::SetVDelay()
{
WORD VDelay, moreDelay;
// increase VDelay will eliminate garbage lines at top of image
switch (m_VFilter)
{
case 3:
moreDelay = 4;
break;
case 2:
moreDelay = 2;
break;
case 1:
case 0:
default:
moreDelay = 0;
break;
}
if ( ( m_videoFormat == VFormat_NTSC ) ||
( m_videoFormat == VFormat_NTSC_J ) ||
( m_videoFormat == VFormat_PAL_M ) ||
( m_videoFormat == VFormat_PAL_N_COMB ) ) // the reason that PAL_N_COMB is here is purely empirical
VDelay = 0x001A + moreDelay; // NTSC
else
VDelay = 0x0026 + moreDelay; // PAL/SECAM
// now add the cropping region into VDelay register; i.e. skip some pixels
// before we start taking them as real image
VDelay += (WORD)(((LONG)m_ptrVideoIn->Max_Lines * (LONG)AnalogWin_.top + m_lines - 1) / (LONG)m_lines * 2);
regVDelay = VDelay;
}
/////////////////////////////////////////////////////////////////////////////
// Method: void Scaler::SetVActive()
// Purpose: Set VActive register
// Input: None
// Output: None
// Return: None
/////////////////////////////////////////////////////////////////////////////
void Scaler::SetVActive()
{
// No calculation needed for VActive register since it based on the UNSCALED image
if ( ( m_videoFormat == VFormat_NTSC ) ||
( m_videoFormat == VFormat_NTSC_J ) ||
( m_videoFormat == VFormat_PAL_M ) )
regVActive = 0x1F4;
else
regVActive = 0x238;
}
/////////////////////////////////////////////////////////////////////////////
// Method: void Scaler::SetVBIEN(BOOL)
// Purpose: Set VBIEN register field
// Input: None
// Output: None
// Return: None
/////////////////////////////////////////////////////////////////////////////
void Scaler::SetVBIEN(BOOL enable)
{
if (enable)
{
fieldVBIEN = 1;
}
else
{
fieldVBIEN = 0;
}
}
/////////////////////////////////////////////////////////////////////////////
// Method: BOOL void Scaler::IsVBIEN()
// Purpose: Set VBIEN register field
// Input: None
// Output: None
// Return: None
/////////////////////////////////////////////////////////////////////////////
BOOL Scaler::IsVBIEN()
{
if (fieldVBIEN)
return TRUE;
else
return FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// Method: void Scaler::SetVBIFMT(BOOL)
// Purpose: Set VBIFMT register field
// Input: None
// Output: None
// Return: None
/////////////////////////////////////////////////////////////////////////////
void Scaler::SetVBIFMT(BOOL enable)
{
if (enable)
{
fieldVBIFMT = 1;
}
else
{
fieldVBIFMT = 0;
}
}
/////////////////////////////////////////////////////////////////////////////
// Method: BOOL void Scaler::IsVBIFMT()
// Purpose: Set VBIFMT register field
// Input: None
// Output: None
// Return: None
/////////////////////////////////////////////////////////////////////////////
BOOL Scaler::IsVBIFMT()
{
if (fieldVBIFMT)
return TRUE;
else
return FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// Method: void Scaler::SetVFilter()
// Purpose: Set VFilt register field
// Input: None
// Output: None
// Return: None
/////////////////////////////////////////////////////////////////////////////
void Scaler::SetVFilter()
{
// this is to remove junk lines at the top of video. flag set to off
// when image hight is above CIF
if (VFilterFlag_ == Off) {
fieldVFILT = 0;
m_VFilter = 0;
return;
}
if ((m_HActive <= m_ptrVideoIn->Max_VFilter3_Pixels) &&
(m_lines <= m_ptrVideoIn->Max_VFilter3_Lines))
m_VFilter = 3;
else if ((m_HActive <= m_ptrVideoIn->Max_VFilter2_Pixels) &&
(m_lines <= m_ptrVideoIn->Max_VFilter2_Lines))
m_VFilter = 2;
else if ((m_HActive <= m_ptrVideoIn->Max_VFilter1_Pixels) &&
(m_lines <= m_ptrVideoIn->Max_VFilter1_Lines))
m_VFilter = 1;
else
m_VFilter = 0;
fieldVFILT = m_VFilter;
}
/////////////////////////////////////////////////////////////////////////////
// Method: void Scaler::GetDigitalWin(MRect &DigWin) const
// Purpose: Retreives the size of digital window
// Input: None
// Output: MRect &DigWin - retrieved value
// Return: None
/////////////////////////////////////////////////////////////////////////////
void Scaler::GetDigitalWin(MRect &DigWin) const
{
DigWin = DigitalWin_;
}
/////////////////////////////////////////////////////////////////////////////
// Method: ErrorCode Scaler::SetDigitalWin(const MRect &DigWin)
// Purpose: Sets the size and location of the digital window
// Input: const MRect &DigWin - window size to set to
// Output: None
// Return: Success or Fail if passed rect is bigger then analog window
// Note: This function can affect the scaling, so Scale() is called
/////////////////////////////////////////////////////////////////////////////
ErrorCode Scaler::SetDigitalWin(const MRect &DigWin)
{
// we can not scale up
if ((DigWin.Height() > AnalogWin_.Height()) ||
(DigWin.Width() > AnalogWin_.Width()))
return Fail;
DigitalWin_ = DigWin;
// every invocation of SetDigitalWin potentially changes the scaling
Scale(DigitalWin_);
return Success;
}
/////////////////////////////////////////////////////////////////////////////
// Method: void Scaler::GetAnalogWin(MRect &AWin) const
// Purpose: Retreives the size of analog window
// Input: None
// Output: MRect &DigWin - retrieved value
// Return: None
/////////////////////////////////////////////////////////////////////////////
void Scaler::GetAnalogWin(MRect &AWin) const
{
AWin = AnalogWin_;
}
/////////////////////////////////////////////////////////////////////////////
// Method: ErrorCode Scaler::SetAnalogWin(const MRect &AWin)
// Purpose: Sets the size and location of the analog window
// Input: const MRect &AWin - window size to set to
// Output: None
// Return: Success or Fail if passed rect is bigger then analog window
/////////////////////////////////////////////////////////////////////////////
ErrorCode Scaler::SetAnalogWin(const MRect &AWin)
{
AnalogWin_ = AWin;
return Success;
}
void Scaler::DumpSomeState()
{
UINT vDelay = regVDelay;
UINT vActive = regVActive;
UINT vScale = regVScale;
UINT hDelay = regHDelay;
UINT hActive = regHActive;
UINT hScale = regHScale;
MRect rect;
GetDigitalWin(rect);
DBGINFO(("vDelay = 0x%x\n", vDelay));
DBGINFO(("vActive = 0x%x\n", vActive));
DBGINFO(("vScale = 0x%x\n", vScale));
DBGINFO(("hDelay = 0x%x\n", hDelay));
DBGINFO(("hActive = 0x%x\n", hActive));
DBGINFO(("hScale = 0x%x\n", hScale));
DBGINFO(("top = 0x%x\n", rect.top));
DBGINFO(("left = 0x%x\n", rect.left));
DBGINFO(("right = 0x%x\n", rect.right));
DBGINFO(("bottom = 0x%x\n", rect.bottom));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -