[prev in list] [next in list] [prev in thread] [next in thread] 

List:       helix-video-cvs
Subject:    [Video-cvs] vidutil/platform/win diballoc.cpp,1.3.42.1,1.3.42.2
From:       pankajgupta () helixcommunity ! org
Date:       2004-07-26 9:01:27
[Download RAW message or body]

Update of /cvsroot/video/vidutil/platform/win
In directory cvs-new:/tmp/cvs-serv21627

Modified Files:
      Tag: hxclient_1_3_0_neptunex
	diballoc.cpp 
Log Message:
To remove dependency on Real Media files

Index: diballoc.cpp
===================================================================
RCS file: /cvsroot/video/vidutil/platform/win/diballoc.cpp,v
retrieving revision 1.3.42.1
retrieving revision 1.3.42.2
diff -u -d -r1.3.42.1 -r1.3.42.2
--- diballoc.cpp	9 Jul 2004 01:59:45 -0000	1.3.42.1
+++ diballoc.cpp	26 Jul 2004 09:01:25 -0000	1.3.42.2
@@ -1,8 +1,8 @@
 /* ***** BEGIN LICENSE BLOCK *****
  * Source last modified: $Id$
- * 
+ *
  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved.
- * 
+ *
  * The contents of this file, and the files included with this file,
  * are subject to the current version of the RealNetworks Public
  * Source License (the "RPSL") available at
@@ -16,7 +16,7 @@
  * to this file, the RCSL.  Please see the applicable RPSL or RCSL for
  * the rights, obligations and limitations governing use of the
  * contents of the file.
- * 
+ *
  * Alternatively, the contents of this file may be used under the
  * terms of the GNU General Public License Version 2 or later (the
  * "GPL") in which case the provisions of the GPL are applicable
@@ -28,23 +28,23 @@
  * the GPL. If you do not delete the provisions above, a recipient may
  * use your version of this file under the terms of any one of the
  * RPSL, the RCSL or the GPL.
- * 
+ *
  * This file is part of the Helix DNA Technology. RealNetworks is the
  * developer of the Original Code and owns the copyrights in the
  * portions it created.
- * 
+ *
  * This file, and the files included with this file, is distributed
  * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
  * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
  * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
  * ENJOYMENT OR NON-INFRINGEMENT.
- * 
+ *
  * Technology Compatibility Kit Test Suite(s) Location:
  *    http://www.helixcommunity.org/content/tck
- * 
+ *
  * Contributor(s):
- * 
+ *
  * ***** END LICENSE BLOCK ***** */
 
 #include "hxtypes.h"
@@ -54,262 +54,16 @@
 #include "hxmap.h"
 #include "hxassert.h"
 #include "hxerrors.h"
-#include "hxalloc.h"
 #include "diballoc.h"
 #include "hxheap.h"
 
 ///////////////////
 //	private data
 #ifdef _DEBUG
-#undef HX_THIS_FILE		
+#undef HX_THIS_FILE
 static const char HX_THIS_FILE[] = __FILE__;
 #endif
 
-#ifdef _WIN32
-CHXImageSample::CHXImageSample(CHXMemoryAllocator *pAllocator):
-				CHXMemoryBlock(pAllocator),
-				m_bInitialized(FALSE)
-{
-}
-
-BOOL CHXImageSample::Allocate(ULONG32 uSize)
-{
-    HX_ASSERT_VALID_PTR(m_pAllocator);
-
-    if (m_bInitialized && uSize <= m_DibData.bmiHeader.biSizeImage)
-    {
-	// Create a file mapping object and map into our address space
-	m_DibData.hMapping = CreateFileMapping((HANDLE)0xFFFFFFFF,	// Use system page file
-						NULL,			// No security attributes
-						PAGE_READWRITE,		// Full access to memory
-						(DWORD) 0,		// Less than 4Gb in size
-						uSize,			// Size of buffer
-						NULL);			// No name to section
-
-	if(m_DibData.hMapping != NULL)
-	{
-	    m_DibData.hBitmap = 
-				CreateDIBSection((HDC) NULL,		// NO device context
-				(BITMAPINFO*)&m_DibData,		// Format information
-				DIB_RGB_COLORS,				// Use the palette
-				(VOID **) &m_pMemBuffer,		// Pointer to image data
-				NULL,					// Mapped memory handle
-				(DWORD) 0);				// Offset into memory
-	}
-
-	if (m_pMemBuffer != NULL)
-	{
-	    m_MemBufferSize = uSize;
-	    // Initialise the DIB information structure
-	    GetObject(m_DibData.hBitmap,sizeof(DIBSECTION), (VOID *)&m_DibData.DibSection);
-	    
-	    return(TRUE);
-	}
-    }
-
-    // we consider it a improper to allocate with 0 size.
-    return(FALSE);
-}
-
-void CHXImageSample::Free()
-{
-    HX_ASSERT_VALID_PTR(m_pMemBuffer);
-
-    if (m_pMemBuffer != NULL)
-    {
-	DeleteBitmap(m_DibData.hBitmap);
-	m_DibData.hBitmap = NULL;
-	CloseHandle(m_DibData.hMapping);
-	m_DibData.hMapping = NULL;
-
-	memset((char*)&m_DibData.DibSection, 0, sizeof(DIBSECTION));
-
-	m_pMemBuffer = NULL;
-	m_MemBufferSize = 0;
-    }
-}
-
-void CHXImageSample::SetDibData(DIBDATA* pDibData)
-{
-    m_DibData = *pDibData;
-    m_bInitialized = TRUE;
-}
-
-DIBDATA* CHXImageSample::GetDibData()
-{
-    return &m_DibData;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-//	CHXDibSection Implementation
-///////////////////////////////////////////////////////////////////////////////
-CHXDibSectionAllocator::CHXDibSectionAllocator(BOOL bThreadSafe/*=FALSE*/):
-    CHXMemoryAllocator(bThreadSafe),
-    m_pbi(NULL)
-{
-}
-
-CHXDibSectionAllocator::~CHXDibSectionAllocator()
-{
-    if (m_pbi != NULL)
-    {
-	delete [] m_pbi;
-	m_pbi = NULL;
-    }
-}
-
-
-HX_RESULT
-CHXDibSectionAllocator::SetProperties(HX20ALLOCPROPS* pRequest, 
-				    HX20ALLOCPROPS* pActual)
-{
-    HX_RESULT theErr = HXR_OK;
-
-    if (m_bThreadSafe) EnterCriticalSection(&m_critsec);
-
-    // if we don't have a format set yet then we cannot
-    // set properties, otherwise if the requested size is less than or
-    // equal to the dib section memory size than allow it to succeed.
-    if (m_pbi != NULL && m_pbi->bmiHeader.biSizeImage >= pRequest->uBufferSize)
-    {
-	pActual->uBufferSize = m_pbi->bmiHeader.biSizeImage;
-	pActual->nNumBuffers = m_Count = pRequest->nNumBuffers;
-    }
-    else
-    {
-	pActual->uBufferSize = m_uSize;
-	pActual->nNumBuffers = m_Count;
-    }
-
-    if (m_bThreadSafe) LeaveCriticalSection(&m_critsec);
-
-    return(theErr);
-}
-
-HX_RESULT 
-CHXDibSectionAllocator::SetDibFormat(BITMAPINFO* pbi)
-{
-    // if there are buffers allocated, then empyt the free list 
-    // so we don't give anyone a buffer of the wrong size
-    if (m_AllocCount != 0)
-    {
-	if (!m_freeList.IsEmpty())
-	{
-	    while(!m_freeList.IsEmpty())
-	    {
-		CHXMemoryBlock * pMemBlock = (CHXMemoryBlock *)m_freeList.RemoveHead();
-		pMemBlock->Free();
-		delete pMemBlock;
-		m_AllocCount--;		
-	    }
-	}
-    }
-
-    // find out how big the bitmap info struct is
-    ULONG32 numColors;
-
-    switch (pbi->bmiHeader.biBitCount)
-    {
-	case 4: numColors = 16; break;
-	case 8: numColors = 256; break;
-	case 16: numColors = 3; break;
-	case 24: numColors = 0; break;
-    }
-
-    ULONG32 ulSize = sizeof(BITMAPINFO) + (numColors * sizeof(DWORD));
-
-    // get rid of the old one
-    delete [] m_pbi;
-    m_pbi = NULL;
-
-    // allocat a new one
-    m_pbi = (BITMAPINFO*)new UCHAR[ulSize];
-    
-    if (m_pbi != NULL)
-    {
-	// set it's members up 
-	memcpy(m_pbi, pbi, ulSize); /* Flawfinder: ignore */
-	
-	// set the buffer size since the dib format defines the buffer size.
-	m_uSize = m_pbi->bmiHeader.biSizeImage;
-
-	return HXR_OK;
-    }
-    else
-    {
-	return HXR_OUTOFMEMORY;
-    }
-}
-
-UCHAR* 
-CHXDibSectionAllocator::GetPacketBuffer(IHXUnknown** pPacketBuffer)
-{
-    HX_ASSERT_VALID_PTR(this);
-    HX_ASSERT_VALID_PTR(pPacketBuffer);
-
-    UCHAR * pRetVal = NULL;
-    *pPacketBuffer = NULL;
-    
-    if (m_bThreadSafe) EnterCriticalSection(&m_critsec);
-
-    if (m_uSize > 0)
-    {
-	// Get the next free buffer from the buffer pool
-	if (!m_freeList.IsEmpty())
-	{
-	    // Get the first buffer
-	    CHXImageSample * pImageSample = (CHXImageSample *)m_freeList.RemoveHead();
-	    
-	    // Add ref the block so we know we are using it
-	    pImageSample->AddRef();
-	    
-	    // setup the map so we don't loose the block
-	    pRetVal = pImageSample->GetSampleBase();
-	    m_MemBlockMap.SetAt(pRetVal, pImageSample);
-	    *pPacketBuffer = (IHXUnknown *)pImageSample;
-	}
-
-	// if we didn't find any blocks in the list allocate a new one
-	if (pRetVal == NULL)
-	{
-	    CHXImageSample * pImageSample = new CHXImageSample(this);
-	    if (pImageSample != NULL)
-	    {
-		DIBDATA dibData;
-		
-		// find out how big the bitmap info struct is
-		ULONG32 numColors;
-
-		switch (m_pbi->bmiHeader.biBitCount)
-		{
-			case 4: numColors = 16; break;
-			case 8: numColors = 256; break;
-			case 16: numColors = 3; break;
-			case 24: numColors = 0; break;
-		}
-
-		ULONG32 ulSize = sizeof(BITMAPINFO) + (numColors * sizeof(DWORD));
-		memcpy(&dibData, m_pbi, ulSize); /* Flawfinder: ignore */
-
-		pImageSample->SetDibData(&dibData);
-
-		if (pImageSample->Allocate(m_uSize))
-		{
-			pImageSample->AddRef();
-			pRetVal = pImageSample->GetSampleBase();
-			m_MemBlockMap.SetAt(pRetVal, pImageSample);
-			m_AllocCount++;
-			*pPacketBuffer = (IHXUnknown *)pImageSample;
-		}
-	    }
-	}
-    }
-
-    if (m_bThreadSafe) LeaveCriticalSection(&m_critsec);
-
-    return(pRetVal);
-}
-#endif /* _WIN32 */
 
 CHXDIBits::CHXDIBits()
 {
@@ -337,7 +91,7 @@
     BITMAP		bm;
     BITMAPINFOHEADER	bi;
     LPBITMAPINFOHEADER	lpbi = NULL;
- 
+
     pBits = NULL;
     pHeader = NULL;
 
@@ -350,7 +104,7 @@
     GetObject(hBM, sizeof(bm), &bm);
 
     wBits = (WORD)(bm.bmPlanes * bm.bmBitsPixel);
-  
+
     bi.biSize		= sizeof(BITMAPINFOHEADER);
     bi.biWidth		= bm.bmWidth;
     bi.biHeight		= bm.bmHeight;
@@ -407,7 +161,7 @@
     GlobalUnlock(m_hDIB);
 
 cleanup:
-    
+
     return hr;
 }
-    
+



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic