#pragma once #include #include "../../EdgeInspector_App/Define/Global_Define.h" class AFX_EXT_CLASS CMultiBuffer // ´ÙÁß ¹öÆÛ ¼³Á¤, m_nBuff °³ÀÇ ¹öÆÛ¸¦ »ý¼º ¹× °ü¸®(¿©·¯ °³ÀÇ ½ºÄµ ¹öÆÛ ÀúÀå) { BYTE* m_pTotalBuff; // m_BuffCnt °³¼ö ¸¸Å­ÀÇ ¹öÆÛ¸¦ ÇѲ¨¹ø¿¡ ÇÒ´ç. int m_BuffCnt; // ¹öÆÛÀÇ °³¼ö SIZE_T m_BuffSize; // °³º° ¹öÆÛÀÇ Å©±â (frameWidth * frameHeight * frameCnt // ¹öÆÛ´Â n°³ÀÇ Frame À¸·Î »ý¼º : Width * Height * Cnt int m_FrameWidth, m_FrameHeight; int m_FrameCnt; public: int GetFrameWidth() { return m_FrameWidth; } int GetFrameHeight() { return m_FrameHeight; } int GetFrameCount() { return m_FrameCnt; } int GetBuffCount() { return m_BuffCnt; } SIZE_T GetFrameSize() { return GetFrameWidth()*GetFrameHeight(); } public: CMultiBuffer() { m_BuffCnt = 0; m_pTotalBuff = NULL; m_FrameWidth = m_FrameHeight = m_FrameCnt = 0; } ~CMultiBuffer() { if (m_pTotalBuff) { VirtualFree(m_pTotalBuff, 0, MEM_RELEASE); m_pTotalBuff = NULL; } } BYTE* GetMultiBuffData(int id) { return m_pTotalBuff + m_BuffSize*id; } int CreateMultiBuff(int buffCnt, int frameWidth, int frameHeight, int frameCnt) { m_BuffCnt = buffCnt; m_FrameWidth = frameWidth; m_FrameHeight = frameHeight; m_FrameCnt = frameCnt; m_BuffSize = (SIZE_T)frameWidth*frameHeight*frameCnt; SIZE_T frameSize = frameWidth* frameHeight; SIZE_T TotalBufferSize = frameSize*frameCnt*buffCnt; m_pTotalBuff = (BYTE*)VirtualAlloc(NULL, TotalBufferSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); if (m_pTotalBuff == NULL) { return FALSE; } ZeroMemory(m_pTotalBuff, sizeof(BYTE)*TotalBufferSize); return TRUE; } void ClearBuffer() { SIZE_T frameSize = m_FrameWidth * m_FrameHeight; SIZE_T TotalBufferSize = frameSize * m_FrameCnt*m_BuffCnt; ZeroMemory(m_pTotalBuff, sizeof(BYTE)*TotalBufferSize); } }; class AFX_EXT_CLASS CFrameBufferController { public: CFrameBufferController(void); virtual ~CFrameBufferController(void); public: void ClearBuffer(); BOOL CreateBuffer(int iCamera, int nFrameWidth, int nFrameHeight, int nFrameCnt, int nBufferCnt = 1); CMultiBuffer* GetMultiBuffer() { return &m_MultiBuffer; } BYTE *GetMultiBuffData(int id) { return m_MultiBuffer.GetMultiBuffData(id); } void SetMutualEx(BOOL bEnter) { if (bEnter == TRUE) EnterCriticalSection(&m_csProcBuffer); else LeaveCriticalSection(&m_csProcBuffer); } int GetCameraIdx() { return m_nCameraIdx; } LPBYTE GetFrameBuferHeader(int iScan, int iFrame); BOOL CheckProcFrame(int iFrame); BOOL SetFrameBuffer(int iScan, int iFrame, LPBYTE lpBuffer); LPBYTE GetFrameHeaderLine(int iScan, int nLine = 0); LPBYTE GetFrameHeader_Line_FromStartLine(int iScan, int iFrame, int nStartLine = 0); int GetFrameWidth() { return GetMultiBuffer()->GetFrameWidth(); } int GetFrameHeight() { return GetMultiBuffer()->GetFrameHeight(); } int GetFrameCount() { return GetMultiBuffer()->GetFrameCount(); } int GetFrameSize() { return (int)GetMultiBuffer()->GetFrameSize(); } protected: CRITICAL_SECTION m_csProcBuffer; // Critical Section CMultiBuffer m_MultiBuffer; int m_nCameraIdx; }; struct stFrameIndex { stFrameIndex() { nScanIdx = -1; nFrameIdx = -1; } stFrameIndex(const stFrameIndex &rhs) { this->nScanIdx = rhs.nScanIdx; this->nFrameIdx = rhs.nFrameIdx; } stFrameIndex(int nScan, int nGrab) { nScanIdx = nScan; nFrameIdx = nGrab; } int nScanIdx; int nFrameIdx; }; typedef deque dqGrabIdx; typedef deque::iterator dqGrabIdxIt;