[Bf-blender-cvs] [5fea6ca] decklink: Fix MSVC compilation error after merge

Benoit Bolsee noreply at git.blender.org
Thu May 19 20:58:02 CEST 2016


Commit: 5fea6ca52f8586a7201c62f4926762b906453899
Author: Benoit Bolsee
Date:   Thu May 19 20:56:51 2016 +0200
Branches: decklink
https://developer.blender.org/rB5fea6ca52f8586a7201c62f4926762b906453899

Fix MSVC compilation error after merge

===================================================================

M	intern/decklink/DeckLinkAPI.cpp
M	intern/decklink/DeckLinkAPI.h
M	source/gameengine/VideoTexture/DeckLink.cpp
M	source/gameengine/VideoTexture/VideoDeckLink.cpp
M	source/gameengine/VideoTexture/VideoDeckLink.h

===================================================================

diff --git a/intern/decklink/DeckLinkAPI.cpp b/intern/decklink/DeckLinkAPI.cpp
index 2ec8e08..73a1264 100644
--- a/intern/decklink/DeckLinkAPI.cpp
+++ b/intern/decklink/DeckLinkAPI.cpp
@@ -29,12 +29,6 @@
 *  \ingroup decklink
 */
 
-#ifdef WIN32
-#include <windows.h>
-#include <objbase.h>
-#include <comutil.h>
-#endif
-
 #include "DeckLinkAPI.h"
 
 #ifdef WIN32
diff --git a/intern/decklink/DeckLinkAPI.h b/intern/decklink/DeckLinkAPI.h
index 2f3d3c6..5c040f5 100644
--- a/intern/decklink/DeckLinkAPI.h
+++ b/intern/decklink/DeckLinkAPI.h
@@ -35,6 +35,9 @@
 /* Include the OS specific Declink headers */
 
 #ifdef WIN32
+	#include <windows.h>
+	#include <objbase.h>
+	#include <comutil.h>
 	#include "win/DeckLinkAPI_h.h"
     typedef unsigned int   dl_size_t;
 #elif defined(__APPLE__)
diff --git a/source/gameengine/VideoTexture/DeckLink.cpp b/source/gameengine/VideoTexture/DeckLink.cpp
index 0bd4329..a9cd622 100644
--- a/source/gameengine/VideoTexture/DeckLink.cpp
+++ b/source/gameengine/VideoTexture/DeckLink.cpp
@@ -33,6 +33,17 @@
 
 // implementation
 
+// FFmpeg defines its own version of stdint.h on Windows.
+// Decklink needs FFmpeg, so it uses its version of stdint.h
+// this is necessary for INT64_C macro
+#ifndef __STDC_CONSTANT_MACROS
+#define __STDC_CONSTANT_MACROS
+#endif
+// this is necessary for UINTPTR_MAX (used by atomic-ops)
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS
+#endif
+
 #include "atomic_ops.h"
 
 #include "EXP_PyObjectPlus.h"
@@ -142,7 +153,7 @@ HRESULT decklink_ReadDisplayMode(const char *format, size_t len, BMDDisplayMode
 	if (len != 4)
 		THRWEXCP(DeckLinkBadDisplayMode, S_OK);
 	// assume the user entered directly the mode value as a 4 char string
-	*displayMode = (BMDDisplayMode)((((u_int)format[0]) << 24) + (((u_int)format[1]) << 16) + (((u_int)format[2]) << 8) + ((u_int)format[3]));
+	*displayMode = (BMDDisplayMode)((((uint32_t)format[0]) << 24) + (((uint32_t)format[1]) << 16) + (((uint32_t)format[2]) << 8) + ((uint32_t)format[3]));
 	return S_OK;
 }
 
@@ -164,7 +175,7 @@ HRESULT decklink_ReadPixelFormat(const char *format, size_t len, BMDPixelFormat
 	if (len != 4)
 		THRWEXCP(DeckLinkBadPixelFormat, S_OK);
 	// assume the user entered directly the mode value as a 4 char string
-	*pixelFormat = (BMDPixelFormat)((((u_int)format[0]) << 24) + (((u_int)format[1]) << 16) + (((u_int)format[2]) << 8) + ((u_int)format[3]));
+	*pixelFormat = (BMDPixelFormat)((((uint32_t)format[0]) << 24) + (((uint32_t)format[1]) << 16) + (((uint32_t)format[2]) << 8) + ((uint32_t)format[3]));
 	return S_OK;
 }
 
@@ -279,11 +290,11 @@ static void decklink_Reset(DeckLink *self)
 
 // adapt the pixel format from VideoTexture (RGBA) to DeckLink (BGRA)
 // return false if no conversion at all is necessary
-static bool decklink_ConvImage(u_int *dest, const short *destSize, const u_int *source, const short *srcSize, bool extend, bool swap)
+static bool decklink_ConvImage(uint32_t *dest, const short *destSize, const uint32_t *source, const short *srcSize, bool extend, bool swap)
 {
 	short w, h, x, y;
-	const u_int *s;
-	u_int *d, p;
+	const uint32_t *s;
+	uint32_t *d, p;
 	bool sameSize = (destSize[0] == srcSize[0] && destSize[1] == srcSize[1]);
 
 	if (sameSize || !extend)
@@ -416,10 +427,10 @@ static int DeckLink_init(DeckLink *self, PyObject *args, PyObject *kwds)
 	BOOL							flag;
 	size_t							len;
 	int								i;
-	u_int							displayFlags;
+	uint32_t						displayFlags;
 	BMDVideoOutputFlags				outputFlags;
 	BMDDisplayModeSupport			support;
-	u_int*							bytes;
+	uint32_t*						bytes;
 
 
 	// material ID
@@ -600,7 +611,7 @@ static PyObject *DeckLink_refresh(DeckLink *self, PyObject *args)
 				// we must adapt the image to the frame 1) in size 2) in byte order
 				// VideoTexture frame are RGBA, DecklinkBGRA
 				short * srcSize = self->m_leftEye->m_image->getSize();
-				u_int *dest;
+				uint32_t *dest;
 				self->mLeftFrame->GetBytes((void **)&dest);
 				bool leftConverted = decklink_ConvImage(dest, self->mSize, leftEye, srcSize, self->mUseExtend, self->mUseSwap);
 				if (self->mUse3D)
diff --git a/source/gameengine/VideoTexture/VideoDeckLink.cpp b/source/gameengine/VideoTexture/VideoDeckLink.cpp
index 45c80af..54907b7 100644
--- a/source/gameengine/VideoTexture/VideoDeckLink.cpp
+++ b/source/gameengine/VideoTexture/VideoDeckLink.cpp
@@ -31,10 +31,16 @@
 
 #ifdef WITH_DECKLINK
 
-// INT64_C fix for some linux machines (C99ism)
+// FFmpeg defines its own version of stdint.h on Windows.
+// Decklink needs FFmpeg, so it uses its version of stdint.h
+// this is necessary for INT64_C macro
 #ifndef __STDC_CONSTANT_MACROS
 #define __STDC_CONSTANT_MACROS
 #endif
+// this is necessary for UINTPTR_MAX (used by atomic-ops)
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS
+#endif
 #include <stdint.h>
 #include <string.h>
 #ifndef WIN32
@@ -115,7 +121,7 @@ struct SyncInfo
 class TextureTransferDvp : public TextureTransfer
 {
 public:
-	TextureTransferDvp(DVPBufferHandle dvpTextureHandle, TextureDesc *pDesc, void *address, u_int allocatedSize)
+	TextureTransferDvp(DVPBufferHandle dvpTextureHandle, TextureDesc *pDesc, void *address, uint32_t allocatedSize)
 	{
 		DVPSysmemBufferDesc sysMemBuffersDesc;
 
@@ -234,8 +240,8 @@ private:
 	SyncInfo*				mGpuSync;
 	DVPBufferHandle			mDvpSysMemHandle;
 	DVPBufferHandle			mDvpTextureHandle;
-	u_int					mTextureHeight;
-	u_int					mAllocatedSize;
+	uint32_t				mTextureHeight;
+	uint32_t				mAllocatedSize;
 	void*					mBuffer;
 };
 
@@ -300,7 +306,7 @@ private:
 class TextureTransferPMD : public TextureTransfer
 {
 public:
-    TextureTransferPMD(GLuint texId, TextureDesc *pDesc, void *address, u_int allocatedSize)
+    TextureTransferPMD(GLuint texId, TextureDesc *pDesc, void *address, uint32_t allocatedSize)
 	{
 		memcpy(&mDesc, pDesc, sizeof(mDesc));
 		mTexId = texId;
@@ -343,12 +349,12 @@ private:
 	// buffer
 	void *mBuffer;
     // the allocated size
-    u_int mAllocatedSize;
+    uint32_t mAllocatedSize;
     // characteristic of the image
 	TextureDesc mDesc;
 };
 
-bool TextureTransfer::_PinBuffer(void *address, u_int size)
+bool TextureTransfer::_PinBuffer(void *address, uint32_t size)
 {
 #ifdef WIN32
 	return VirtualLock(address, size);
@@ -357,7 +363,7 @@ bool TextureTransfer::_PinBuffer(void *address, u_int size)
 #endif
 }
 
-void TextureTransfer::_UnpinBuffer(void* address, u_int size)
+void TextureTransfer::_UnpinBuffer(void* address, uint32_t size)
 {
 #ifdef WIN32
 	VirtualUnlock(address, size);
@@ -480,7 +486,7 @@ PinnedMemoryAllocator::~PinnedMemoryAllocator()
 
 void PinnedMemoryAllocator::TransferBuffer(void* address, TextureDesc* texDesc, GLuint texId)
 {
-	u_int allocatedSize = 0;
+	uint32_t allocatedSize = 0;
 	TextureTransfer *pTransfer = NULL;
 
 	Lock();
@@ -784,7 +790,7 @@ void VideoDeckLink::openCam (char *format, short camIdx)
 	BMDTimeValue					frameDuration;
 	BMDTimeScale					frameTimescale;
 	IDeckLink*						pDL;
-	u_int displayFlags, inputFlags; 
+	uint32_t displayFlags, inputFlags; 
 	char *pPixel, *p3D, *pEnd, *pSize;
 	size_t len;
 	int i, modeIdx, cacheSize;
@@ -830,7 +836,7 @@ void VideoDeckLink::openCam (char *format, short camIdx)
         // found a valid mode, remember that we do not look for an index
         modeIdx = -1;
     }
-    catch (Exception & exp)
+    catch (Exception &)
     {
         // accept also purely numerical mode as a mode index
         modeIdx = strtol(format, &pEnd, 10);
@@ -1077,8 +1083,8 @@ void VideoDeckLink::calcImage (unsigned int texId, double ts)
 		// it is crucial that we release the frame to keep the reference count right on the DeckLink device
 		try
 		{
-			u_int rowSize = pFrame->GetRowBytes();
-			u_int textureSize = rowSize * pFrame->GetHeight();
+			uint32_t rowSize = pFrame->GetRowBytes();
+			uint32_t textureSize = rowSize * pFrame->GetHeight();
 			void* videoPixels = NULL;
 			void* rightEyePixels = NULL;
 			if (!mTextureDesc.stride)
diff --git a/source/gameengine/VideoTexture/VideoDeckLink.h b/source/gameengine/VideoTexture/VideoDeckLink.h
index 5dc97bd..cd87d4a 100644
--- a/source/gameengine/VideoTexture/VideoDeckLink.h
+++ b/source/gameengine/VideoTexture/VideoDeckLink.h
@@ -58,10 +58,10 @@ class PinnedMemoryAllocator;
 
 struct TextureDesc
 {
-	u_int		width;
-	u_int		height;
-	u_int		stride;
-	u_int		size;
+	uint32_t	width;
+	uint32_t	height;
+	uint32_t	stride;
+	uint32_t	size;
 	GLenum		internalFormat;
 	GLenum		format;
 	GLenum		type;
@@ -129,8 +129,8 @@ private:
 	BMDDisplayMode			mDisplayMode;
 	BMDPixelFormat			mPixelFormat;
 	bool					mUse3D;
-	u_int					mFrameWidth;
-	u_int					mFrameHeight;
+	uint32_t				mFrameWidth;
+	uint32_t				mFrameHeight;
 	TextureDesc				mTextureDesc;
 	PinnedMemoryAllocator*	mpAllocator;
 	CaptureDelegate*		mpCaptureDelegate;
@@ -159,8 +159,8 @@ public:
 
 	virtual void PerformTransfer() = 0;
 protected:
-	static bool _PinBuffer(void *address, u_int size);
-	static void _UnpinBuffer(void* address, u_int size);
+	static bool _PinBuffer(void *address, uint32_t size);
+	static void _UnpinBuffer(void* address, uint32_t size);
 };
 
 ////////////////////////////////////////////
@@ -219,7 +219,7 @@ private:
 	// protect the cache and the allocated map, 
 	// not the pinnedBuffer map as it is only used from main thread
 	pthread_mutex_t						mMutex;
-	std::map<void*, u_int>				mAllocatedSize;
+	std::map<void*, uint32_t>			mAllocatedSize;
 	std::vector<void*>					mBufferCache;
 	std::map<void *, TextureTransfer*>	mPinnedBuffer;
 #ifdef WIN32
@@ -227,7 +227,7 @@ private:
 #endif
 	// target texture in GPU
 	GLuint								mTexId;
-	u_int								mBufferCacheSize;
+	uint32_t							mBufferCacheSize;
 };
 
 ////////////////////////////////////////////




More information about the Bf-blender-cvs mailing list