📄 prpclass.cpp
字号:
}
else
{
DEBUGMSG(ZONE_INIT, (TEXT("%s: create viewfinding buffer worker thread success\r\n"), __WFUNCTION__));
}
// Initialize viewfinding buffer worker thread
m_hPrpVfRotBufThread = ::CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PrpVfRotBufferWorkerThread, this, 0, NULL);
if (m_hPrpVfRotBufThread == NULL)
{
DEBUGMSG(ZONE_ERROR,(TEXT("%s: CreateThread failed!\r\n"), __WFUNCTION__));
return FALSE;
}
else
{
DEBUGMSG(ZONE_INIT, (TEXT("%s: create rotation for viewfinding buffer worker thread success\r\n"), __WFUNCTION__));
}
// Enable Preprocessor
PrpEnable();
PRP_FUNCTION_EXIT();
return TRUE;
Error:
PrpDeinit();
return FALSE;
}
//-----------------------------------------------------------------------------
//
// Function: PrpDeinit
//
// This function deinitializes the Image Converter (Preprocessor).
//
// Parameters:
// None.
//
// Returns:
// None.
//
//-----------------------------------------------------------------------------
void PrpClass::PrpDeinit(void)
{
PRP_FUNCTION_ENTRY();
// Disable Preprocessor
PrpDisable();
if (m_hPrpIntrEvent != NULL)
{
CloseHandle(m_hPrpIntrEvent);
m_hPrpIntrEvent = NULL;
}
CloseHandle(m_hEncEOFEvent);
m_hEncEOFEvent = NULL;
CloseHandle(m_hVfEOFEvent);
m_hVfEOFEvent = NULL;
CloseHandle(m_hReadVfBufferQueue);
m_hReadVfBufferQueue = NULL;
CloseHandle(m_hWriteVfBufferQueue);
m_hWriteVfBufferQueue = NULL;
if (m_hDisplay != NULL)
{
DeleteDC(m_hDisplay);
m_hDisplay = NULL;
}
if (m_hPrpISRThread)
{
TerminateThread(m_hPrpISRThread, 0);
CloseHandle(m_hPrpISRThread);
m_hPrpISRThread = NULL;
}
if (m_hPrpEncBufThread)
{
TerminateThread(m_hPrpEncBufThread, 0);
CloseHandle(m_hPrpEncBufThread);
m_hPrpEncBufThread = NULL;
}
if (m_hPrpVfBufThread)
{
TerminateThread(m_hPrpVfBufThread, 0);
CloseHandle(m_hPrpVfBufThread);
m_hPrpVfBufThread = NULL;
}
PRP_FUNCTION_EXIT();
}
//-----------------------------------------------------------------------------
//
// Function: PrpInitDisplayCharacteristics
//
// This function initializes the display characteristics by
// retrieving them from the display driver.
//
// Parameters:
// None.
//
// Returns:
// TRUE if success, FALSE if failure.
//
//-----------------------------------------------------------------------------
BOOL PrpClass::PrpInitDisplayCharacteristics(void)
{
PRP_FUNCTION_ENTRY();
m_hDisplay = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
// Get Display Type from Display driver
if (ExtEscape(m_hDisplay, VF_GET_DISPLAY_INFO, NULL, NULL,
sizeof(DISPLAY_CHARACTERISTIC), (LPSTR) &m_displayCharacteristics) < 0)
{
DEBUGMSG(ZONE_ERROR, (TEXT("%s: Unable to get display characteristics! \r\n"), __WFUNCTION__));
return FALSE;
}
PRP_FUNCTION_EXIT();
return TRUE;
}
//-----------------------------------------------------------------------------
//
// Function: PrpAllocateEncBuffers
//
// This function allocates buffers for the encoding channel
// and adds each to the buffer queue. This function must be called
// in order to allocate physically contiguous buffers for use in
// the IPU's IDMAC.
//
// Parameters:
// numBuffers
// [in] Number of buffers to allocate and add
// to the queues.
//
// bufSize
// [in] Size of buffer to create and enqueue.
//
// Returns:
// Returns virtual pointer to buffer created.
// Returns NULL if unsuccessful.
//
//-----------------------------------------------------------------------------
BOOL PrpClass::PrpAllocateEncBuffers(ULONG numBuffers, ULONG bufSize)
{
PRP_FUNCTION_ENTRY();
DEBUGMSG(ZONE_ERROR,
(TEXT("%s : Buffer size: %x\r\n"), __WFUNCTION__, bufSize));
pEncBufferManager->PrintBufferInfo();
m_iEncNumBuffers = numBuffers;
m_iEncBufSize = bufSize;
// Initialize MsgQueues when buffers are allocated
if (!pEncBufferManager->AllocateBuffers(m_iEncNumBuffers, m_iEncBufSize))
{
DEBUGMSG(ZONE_ERROR,
(TEXT("%s : Encoding Buffer allocation failed!\r\n"), __WFUNCTION__));
return FALSE;
}
if (m_bEncFlipRot)
{
// Initialize MsgQueues when buffers are allocated
if (!PrpAllocateEncRotBuffers())
{
DEBUGMSG(ZONE_ERROR,
(TEXT("%s : Rotation for encoding Buffer allocation failed!\r\n"), __WFUNCTION__));
return FALSE;
}
m_bEncRotBuffersAllocated = TRUE;
}
pEncBufferManager->PrintBufferInfo();
PRP_FUNCTION_EXIT();
// Return virtual buffer address
return TRUE;
}
//-----------------------------------------------------------------------------
//
// Function: PrpAllocateEncRotBuffers
//
// This function allocates buffers for the rotation for encoding channel
// and adds each to the buffer queue. This function must be called
// in order to allocate physically contiguous buffers for use in
// the IPU's IDMAC.
//
// Parameters:
// numBuffers
// [in] Number of buffers to allocate and add
// to the queues.
//
// bufSize
// [in] Size of buffer to create and enqueue.
//
// Returns:
// TRUE if success, FALSE if failure.
//
//-----------------------------------------------------------------------------
BOOL PrpClass::PrpAllocateEncRotBuffers()
{
PRP_FUNCTION_ENTRY();
// Initialize MsgQueues when buffers are allocated
if (!pEncRotBufferManager->AllocateBuffers(m_iEncNumBuffers, m_iEncBufSize))
{
return FALSE;
}
m_bEncRotBuffersAllocated = TRUE;
PRP_FUNCTION_EXIT();
return TRUE;
}
//-----------------------------------------------------------------------------
//
// Function: PrpGetEncBufFilled
//
// This function reads the queue of filled encoding channel
// buffers and returns the buffer at the top of the queue.
//
// Parameters:
// None.
//
// Returns:
// Pointer to filled buffer, or NULL if failure.
//
//-----------------------------------------------------------------------------
UINT32* PrpClass::PrpGetEncBufFilled()
{
PRP_FUNCTION_ENTRY();
if (m_bEncFlipRot)
{
PRP_FUNCTION_EXIT();
// Get filled buffer from the filled buffer queue.
return pEncRotBufferManager->GetBufferFilled();
}
else
{
PRP_FUNCTION_EXIT();
// Get filled buffer from the filled buffer queue.
return pEncBufferManager->GetBufferFilled();
}
}
//-----------------------------------------------------------------------------
//
// Function: PrpDeleteEncBuffers
//
// This function deletes all of the encoding buffers in the Idle
// and Ready queues.
//
// Parameters:
// None.
//
// Returns:
// TRUE if success, otherwise FALSE.
//
//-----------------------------------------------------------------------------
BOOL PrpClass::PrpDeleteEncBuffers()
{
PRP_FUNCTION_ENTRY();
// Delete encoding buffers.
if (!pEncBufferManager->DeleteBuffers())
{
DEBUGMSG(ZONE_ERROR,
(TEXT("%s : Failed to delete buffers!\r\n"), __WFUNCTION__));
return FALSE;
}
// TODO: Make sure that encoding buffers deleted whenever
// encoding is turned off
if (m_bEncFlipRot)
{
// Delete encoding buffers for rotation.
if (!pEncRotBufferManager->DeleteBuffers())
{
DEBUGMSG(ZONE_ERROR,
(TEXT("%s : Failed to delete buffers!\r\n"), __WFUNCTION__));
return FALSE;
}
m_bEncRotBuffersAllocated = TRUE;
}
PRP_FUNCTION_EXIT();
return TRUE;
}
//-----------------------------------------------------------------------------
//
// Function: PrpAllocateVfBuffers
//
// This function allocates buffers for the viewfinding channel
// and adds each to the buffer queue. This function must be called
// in order to allocate physically contiguous buffers for use in
// the IPU's IDMAC.
//
// Parameters:
// numBuffers
// [in] Number of buffers to allocate and add
// to the queues.
//
// bufSize
// [in] Size of buffer to create and enqueue.
//
// Returns:
// Returns virtual pointer to buffer created.
// Returns NULL if unsuccessful.
//
//-----------------------------------------------------------------------------
BOOL PrpClass::PrpAllocateVfBuffers(ULONG numBuffers, ULONG bufSize)
{
PRP_FUNCTION_ENTRY();
m_iVfNumBuffers = numBuffers;
m_iVfBufSize = bufSize;
// Initialize MsgQueues when buffers are allocated
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -