diff options
-rw-r--r-- | intern/decklink/CMakeLists.txt | 22 | ||||
-rw-r--r-- | intern/decklink/DeckLinkAPI.h | 24 | ||||
-rw-r--r-- | intern/gpudirect/CMakeLists.txt | 1 | ||||
-rw-r--r-- | intern/gpudirect/dvpapi.cpp | 16 | ||||
-rw-r--r-- | intern/gpudirect/dvpapi.h | 185 | ||||
-rw-r--r-- | source/blenderplayer/CMakeLists.txt | 12 | ||||
-rw-r--r-- | source/gameengine/VideoTexture/DeckLink.cpp | 127 | ||||
-rw-r--r-- | source/gameengine/VideoTexture/VideoDeckLink.cpp | 293 | ||||
-rw-r--r-- | source/gameengine/VideoTexture/VideoDeckLink.h | 6 |
9 files changed, 304 insertions, 382 deletions
diff --git a/intern/decklink/CMakeLists.txt b/intern/decklink/CMakeLists.txt index 9329ab1bc82..fbef65cdba4 100644 --- a/intern/decklink/CMakeLists.txt +++ b/intern/decklink/CMakeLists.txt @@ -42,17 +42,17 @@ if (WIN32) endif() if (UNIX AND NOT APPLE) - list(APPEND SRC - linux/DeckLinkAPI.h - linux/DeckLinkAPIConfiguration.h - linux/DeckLinkAPIDeckControl.h - linux/DeckLinkAPIDiscovery.h - linux/DeckLinkAPIDispatch.cpp - linux/DeckLinkAPIModes.h - linux/DeckLinkAPIVersion.h - linux/DeckLinkAPITypes.h - linux/LinuxCOM.h - ) + list(APPEND SRC + linux/DeckLinkAPI.h + linux/DeckLinkAPIConfiguration.h + linux/DeckLinkAPIDeckControl.h + linux/DeckLinkAPIDiscovery.h + linux/DeckLinkAPIDispatch.cpp + linux/DeckLinkAPIModes.h + linux/DeckLinkAPIVersion.h + linux/DeckLinkAPITypes.h + linux/LinuxCOM.h + ) endif() blender_add_lib(bf_intern_decklink "${SRC}" "${INC}" "${INC_SYS}") diff --git a/intern/decklink/DeckLinkAPI.h b/intern/decklink/DeckLinkAPI.h index 5c040f5f250..f6d2b79f53e 100644 --- a/intern/decklink/DeckLinkAPI.h +++ b/intern/decklink/DeckLinkAPI.h @@ -35,24 +35,22 @@ /* 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; +# include <windows.h> +# include <objbase.h> +# include <comutil.h> +# include "win/DeckLinkAPI_h.h" + typedef unsigned int dl_size_t; #elif defined(__APPLE__) - #error "Decklink not supported in OSX" +# error "Decklink not supported in OSX" #else - #include "linux/DeckLinkAPI.h" - /* Windows COM API uses BOOL, linux uses bool */ - #define BOOL bool - typedef uint32_t dl_size_t; +# include "linux/DeckLinkAPI.h" + /* Windows COM API uses BOOL, linux uses bool */ +# define BOOL bool + typedef uint32_t dl_size_t; #endif - - /* OS independent function to get the device iterator */ IDeckLinkIterator* BMD_CreateDeckLinkIterator(void); -#endif +#endif /* __DECKLINKAPI_H__ */ diff --git a/intern/gpudirect/CMakeLists.txt b/intern/gpudirect/CMakeLists.txt index e47be7ec727..88c09a663b8 100644 --- a/intern/gpudirect/CMakeLists.txt +++ b/intern/gpudirect/CMakeLists.txt @@ -25,6 +25,7 @@ set(INC . + # XXX, bad level include! ../../source/blender/blenlib ) diff --git a/intern/gpudirect/dvpapi.cpp b/intern/gpudirect/dvpapi.cpp index 78c58bda6db..8ae5cdbf17b 100644 --- a/intern/gpudirect/dvpapi.cpp +++ b/intern/gpudirect/dvpapi.cpp @@ -81,11 +81,9 @@ DVPStatus dvpGetLibrayVersion(uint32_t *major, uint32_t *minor) DVPStatus dvpInitGLContext(uint32_t flags) { DVPStatus status; - if (!__dvpLibrary) - { + if (!__dvpLibrary) { __dvpLibrary = BLI_dynlib_open(KDVPAPI_Name); - if (!__dvpLibrary) - { + if (!__dvpLibrary) { return DVP_STATUS_ERROR; } // "?dvpInitGLContext@@YA?AW4DVPStatus@@I@Z"; @@ -129,19 +127,21 @@ DVPStatus dvpInitGLContext(uint32_t flags) !__dvpGetRequiredConstantsGLCtx || !__dvpCreateGPUTextureGL || !__dvpUnbindFromGLCtx) - return DVP_STATUS_ERROR; + { + return DVP_STATUS_ERROR; + } // check that the library version is what we want if ((status = __dvpGetLibrayVersion(&__dvpMajorVersion, &__dvpMinorVersion)) != DVP_STATUS_OK) return status; if (__dvpMajorVersion != DVP_MAJOR_VERSION || __dvpMinorVersion < DVP_MINOR_VERSION) return DVP_STATUS_ERROR; - } - return (!__dvpInitGLContext) ? DVP_STATUS_ERROR : __dvpInitGLContext(flags); + } + return (!__dvpInitGLContext) ? DVP_STATUS_ERROR : __dvpInitGLContext(flags); } DVPStatus dvpCloseGLContext(void) { - return (!__dvpCloseGLContext) ? DVP_STATUS_ERROR : __dvpCloseGLContext(); + return (!__dvpCloseGLContext) ? DVP_STATUS_ERROR : __dvpCloseGLContext(); } #endif // WIN32 diff --git a/intern/gpudirect/dvpapi.h b/intern/gpudirect/dvpapi.h index 36c690bcf3c..4cc259f0fe8 100644 --- a/intern/gpudirect/dvpapi.h +++ b/intern/gpudirect/dvpapi.h @@ -54,24 +54,23 @@ typedef uint64_t DVPBufferHandle; typedef uint64_t DVPSyncObjectHandle; -typedef enum -{ - DVP_STATUS_OK = 0, - DVP_STATUS_INVALID_PARAMETER = 1, - DVP_STATUS_UNSUPPORTED = 2, - DVP_STATUS_END_ENUMERATION = 3, - DVP_STATUS_INVALID_DEVICE = 4, - DVP_STATUS_OUT_OF_MEMORY = 5, - DVP_STATUS_INVALID_OPERATION = 6, - DVP_STATUS_TIMEOUT = 7, - DVP_STATUS_INVALID_CONTEXT = 8, - DVP_STATUS_INVALID_RESOURCE_TYPE = 9, - DVP_STATUS_INVALID_FORMAT_OR_TYPE = 10, - DVP_STATUS_DEVICE_UNINITIALIZED = 11, - DVP_STATUS_UNSIGNALED = 12, - DVP_STATUS_SYNC_ERROR = 13, - DVP_STATUS_SYNC_STILL_BOUND = 14, - DVP_STATUS_ERROR = -1, +typedef enum { + DVP_STATUS_OK = 0, + DVP_STATUS_INVALID_PARAMETER = 1, + DVP_STATUS_UNSUPPORTED = 2, + DVP_STATUS_END_ENUMERATION = 3, + DVP_STATUS_INVALID_DEVICE = 4, + DVP_STATUS_OUT_OF_MEMORY = 5, + DVP_STATUS_INVALID_OPERATION = 6, + DVP_STATUS_TIMEOUT = 7, + DVP_STATUS_INVALID_CONTEXT = 8, + DVP_STATUS_INVALID_RESOURCE_TYPE = 9, + DVP_STATUS_INVALID_FORMAT_OR_TYPE = 10, + DVP_STATUS_DEVICE_UNINITIALIZED = 11, + DVP_STATUS_UNSIGNALED = 12, + DVP_STATUS_SYNC_ERROR = 13, + DVP_STATUS_SYNC_STILL_BOUND = 14, + DVP_STATUS_ERROR = -1, } DVPStatus; // Pixel component formats stored in the system memory buffer @@ -83,74 +82,72 @@ typedef enum // for the transformation. The CUDA types are to be used when // copying to/from a system memory buffer from-to a CUDA array, as the // CUDA array implies a memory layout that matches the array. -typedef enum -{ - DVP_BUFFER, // Buffer treated as a raw buffer - // and copied directly into GPU buffer - // without any interpretation of the - // stored bytes. - DVP_DEPTH_COMPONENT, - DVP_RGBA, - DVP_BGRA, - DVP_RED, - DVP_GREEN, - DVP_BLUE, - DVP_ALPHA, - DVP_RGB, - DVP_BGR, - DVP_LUMINANCE, - DVP_LUMINANCE_ALPHA, - DVP_CUDA_1_CHANNEL, - DVP_CUDA_2_CHANNELS, - DVP_CUDA_4_CHANNELS, - DVP_RGBA_INTEGER, - DVP_BGRA_INTEGER, - DVP_RED_INTEGER, - DVP_GREEN_INTEGER, - DVP_BLUE_INTEGER, - DVP_ALPHA_INTEGER, - DVP_RGB_INTEGER, - DVP_BGR_INTEGER, - DVP_LUMINANCE_INTEGER, - DVP_LUMINANCE_ALPHA_INTEGER, +typedef enum { + DVP_BUFFER, // Buffer treated as a raw buffer + // and copied directly into GPU buffer + // without any interpretation of the + // stored bytes. + DVP_DEPTH_COMPONENT, + DVP_RGBA, + DVP_BGRA, + DVP_RED, + DVP_GREEN, + DVP_BLUE, + DVP_ALPHA, + DVP_RGB, + DVP_BGR, + DVP_LUMINANCE, + DVP_LUMINANCE_ALPHA, + DVP_CUDA_1_CHANNEL, + DVP_CUDA_2_CHANNELS, + DVP_CUDA_4_CHANNELS, + DVP_RGBA_INTEGER, + DVP_BGRA_INTEGER, + DVP_RED_INTEGER, + DVP_GREEN_INTEGER, + DVP_BLUE_INTEGER, + DVP_ALPHA_INTEGER, + DVP_RGB_INTEGER, + DVP_BGR_INTEGER, + DVP_LUMINANCE_INTEGER, + DVP_LUMINANCE_ALPHA_INTEGER, } DVPBufferFormats; // Possible pixel component storage types for system memory buffers -typedef enum -{ - DVP_UNSIGNED_BYTE, - DVP_BYTE, - DVP_UNSIGNED_SHORT, - DVP_SHORT, - DVP_UNSIGNED_INT, - DVP_INT, - DVP_FLOAT, - DVP_HALF_FLOAT, - DVP_UNSIGNED_BYTE_3_3_2, - DVP_UNSIGNED_BYTE_2_3_3_REV, - DVP_UNSIGNED_SHORT_5_6_5, - DVP_UNSIGNED_SHORT_5_6_5_REV, - DVP_UNSIGNED_SHORT_4_4_4_4, - DVP_UNSIGNED_SHORT_4_4_4_4_REV, - DVP_UNSIGNED_SHORT_5_5_5_1, - DVP_UNSIGNED_SHORT_1_5_5_5_REV, - DVP_UNSIGNED_INT_8_8_8_8, - DVP_UNSIGNED_INT_8_8_8_8_REV, - DVP_UNSIGNED_INT_10_10_10_2, - DVP_UNSIGNED_INT_2_10_10_10_REV, +typedef enum { + DVP_UNSIGNED_BYTE, + DVP_BYTE, + DVP_UNSIGNED_SHORT, + DVP_SHORT, + DVP_UNSIGNED_INT, + DVP_INT, + DVP_FLOAT, + DVP_HALF_FLOAT, + DVP_UNSIGNED_BYTE_3_3_2, + DVP_UNSIGNED_BYTE_2_3_3_REV, + DVP_UNSIGNED_SHORT_5_6_5, + DVP_UNSIGNED_SHORT_5_6_5_REV, + DVP_UNSIGNED_SHORT_4_4_4_4, + DVP_UNSIGNED_SHORT_4_4_4_4_REV, + DVP_UNSIGNED_SHORT_5_5_5_1, + DVP_UNSIGNED_SHORT_1_5_5_5_REV, + DVP_UNSIGNED_INT_8_8_8_8, + DVP_UNSIGNED_INT_8_8_8_8_REV, + DVP_UNSIGNED_INT_10_10_10_2, + DVP_UNSIGNED_INT_2_10_10_10_REV, } DVPBufferTypes; // System memory descriptor describing the size and storage formats // of the buffer typedef struct DVPSysmemBufferDescRec { - uint32_t width; // Buffer Width - uint32_t height; // Buffer Height - uint32_t stride; // Stride - uint32_t size; // Specifies the surface size if - // format == DVP_BUFFER - DVPBufferFormats format; // see enum above - DVPBufferTypes type; // see enum above - void *bufAddr; // Buffer memory address + uint32_t width; // Buffer Width + uint32_t height; // Buffer Height + uint32_t stride; // Stride + uint32_t size; // Specifies the surface size if + // format == DVP_BUFFER + DVPBufferFormats format; // see enum above + DVPBufferTypes type; // see enum above + void *bufAddr; // Buffer memory address } DVPSysmemBufferDesc; // Flags specified at sync object creation: @@ -164,22 +161,22 @@ typedef struct DVPSysmemBufferDescRec { #define DVP_SYNC_OBJECT_FLAGS_USE_EVENTS 0x00000001 typedef struct DVPSyncObjectDescRec { - uint32_t *sem; // Location to write semaphore value - uint32_t flags; // See above DVP_SYNC_OBJECT_FLAGS_* bits - DVPStatus (*externalClientWaitFunc) (DVPSyncObjectHandle sync, - uint32_t value, - bool GEQ, // If true then the function should wait for the sync value to be - // greater than or equal to the value parameter. Otherwise just a - // straight forward equality comparison should be performed. - uint64_t timeout); - // If non-null, externalClientWaitFunc allows the DVP library - // to call the application to wait for a sync object to be - // released. This allows the application to create events, - // which can be triggered on device interrupts instead of - // using spin loops inside the DVP library. Upon succeeding - // the function must return DVP_STATUS_OK, non-zero for failure - // and DVP_STATUS_TIMEOUT on timeout. The externalClientWaitFunc should - // not alter the current GL or CUDA context state + uint32_t *sem; // Location to write semaphore value + uint32_t flags; // See above DVP_SYNC_OBJECT_FLAGS_* bits + DVPStatus (*externalClientWaitFunc) (DVPSyncObjectHandle sync, + uint32_t value, + bool GEQ, // If true then the function should wait for the sync value to be + // greater than or equal to the value parameter. Otherwise just a + // straight forward equality comparison should be performed. + uint64_t timeout); + // If non-null, externalClientWaitFunc allows the DVP library + // to call the application to wait for a sync object to be + // released. This allows the application to create events, + // which can be triggered on device interrupts instead of + // using spin loops inside the DVP library. Upon succeeding + // the function must return DVP_STATUS_OK, non-zero for failure + // and DVP_STATUS_TIMEOUT on timeout. The externalClientWaitFunc should + // not alter the current GL or CUDA context state } DVPSyncObjectDesc; // Time used when event timeouts should be ignored diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt index b034ec91cb9..5694a29acf8 100644 --- a/source/blenderplayer/CMakeLists.txt +++ b/source/blenderplayer/CMakeLists.txt @@ -215,13 +215,13 @@ endif() list(APPEND BLENDER_SORTED_LIBS bf_intern_locale) endif() - if(WITH_DECKLINK) - list(APPEND BLENDER_SORTED_LIBS bf_intern_decklink) - endif() + if(WITH_DECKLINK) + list(APPEND BLENDER_SORTED_LIBS bf_intern_decklink) + endif() - if(WIN32) - list(APPEND BLENDER_SORTED_LIBS bf_intern_gpudirect) - endif() + if(WIN32) + list(APPEND BLENDER_SORTED_LIBS bf_intern_gpudirect) + endif() if(WITH_OPENSUBDIV) list(APPEND BLENDER_SORTED_LIBS bf_intern_opensubdiv) diff --git a/source/gameengine/VideoTexture/DeckLink.cpp b/source/gameengine/VideoTexture/DeckLink.cpp index b864dee9b61..e9b583dba05 100644 --- a/source/gameengine/VideoTexture/DeckLink.cpp +++ b/source/gameengine/VideoTexture/DeckLink.cpp @@ -163,8 +163,7 @@ HRESULT decklink_ReadPixelFormat(const char *format, size_t len, BMDPixelFormat if (!len) len = strlen(format); - for (i = 0; sFormatStringTab[i].name != NULL; i++) - { + for (i = 0; sFormatStringTab[i].name != NULL; i++) { if (strlen(sFormatStringTab[i].name) == len && !strncmp(sFormatStringTab[i].name, format, len)) { @@ -185,10 +184,8 @@ public: // IUnknown virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv) { - if (!memcmp(&iid, &IID_IDeckLinkVideoFrame3DExtensions, sizeof(iid))) - { - if (mpRightEye) - { + if (!memcmp(&iid, &IID_IDeckLinkVideoFrame3DExtensions, sizeof(iid))) { + if (mpRightEye) { *ppv = (IDeckLinkVideoFrame3DExtensions*)this; return S_OK; } @@ -265,65 +262,59 @@ static void decklink_ConvImage(uint32_t *dest, const short *destSize, const uint uint32_t *d, p; bool sameSize = (destSize[0] == srcSize[0] && destSize[1] == srcSize[1]); - if (sameSize || !extend) - { + if (sameSize || !extend) { // here we convert pixel by pixel w = (destSize[0] < srcSize[0]) ? destSize[0] : srcSize[0]; h = (destSize[1] < srcSize[1]) ? destSize[1] : srcSize[1]; - for (y = 0; y < h; ++y) - { + for (y = 0; y < h; ++y) { s = source + y*srcSize[0]; d = dest + y*destSize[0]; - for (x = 0; x < w; ++x, ++s, ++d) + for (x = 0; x < w; ++x, ++s, ++d) { *d = CONV_PIXEL(*s); + } } } - else - { + else { // here we scale // interpolation accumulator int accHeight = srcSize[1] >> 1; d = dest; s = source; // process image rows - for (y = 0; y < srcSize[1]; ++y) - { + for (y = 0; y < srcSize[1]; ++y) { // increase height accum accHeight += destSize[1]; // if pixel row has to be drawn - if (accHeight >= srcSize[1]) - { + if (accHeight >= srcSize[1]) { // decrease accum accHeight -= srcSize[1]; // width accum int accWidth = srcSize[0] >> 1; // process row - for (x = 0; x < srcSize[0]; ++x, ++s) - { + for (x = 0; x < srcSize[0]; ++x, ++s) { // increase width accum accWidth += destSize[0]; // convert pixel p = CONV_PIXEL(*s); // if pixel has to be drown one or more times - while (accWidth >= srcSize[0]) - { + while (accWidth >= srcSize[0]) { // decrease accum accWidth -= srcSize[0]; *d++ = p; } } // if there should be more identical lines - while (accHeight >= srcSize[1]) - { + while (accHeight >= srcSize[1]) { accHeight -= srcSize[1]; // copy previous line memcpy(d, d - destSize[0], 4 * destSize[0]); d += destSize[0]; } } - else + else { // if we skip a source line s += srcSize[0]; + } } } } @@ -396,10 +387,8 @@ static int DeckLink_init(DeckLink *self, PyObject *args, PyObject *kwds) const_cast<char**>(kwlist), &cardIdx, &format)) return -1; - try - { - if (format == NULL) - { + try { + if (format == NULL) { THRWEXCP(AutoDetectionNotAvail, S_OK); } @@ -413,13 +402,10 @@ static int DeckLink_init(DeckLink *self, PyObject *args, PyObject *kwds) pIterator = BMD_CreateDeckLinkIterator(); pDL = NULL; - if (pIterator) - { + if (pIterator) { i = 0; - while (pIterator->Next(&pDL) == S_OK) - { - if (i == cardIdx) - { + while (pIterator->Next(&pDL) == S_OK) { + if (i == cardIdx) { break; } i++; @@ -429,28 +415,24 @@ static int DeckLink_init(DeckLink *self, PyObject *args, PyObject *kwds) pIterator->Release(); } - if (!pDL) - { + if (!pDL) { THRWEXCP(DeckLinkOpenCard, S_OK); } // detect the capabilities - if (pDL->QueryInterface(IID_IDeckLinkAttributes, (void**)&pAttributes) == S_OK) - { - if (pAttributes->GetFlag(BMDDeckLinkSupportsInternalKeying, &flag) == S_OK && flag) - { + if (pDL->QueryInterface(IID_IDeckLinkAttributes, (void**)&pAttributes) == S_OK) { + if (pAttributes->GetFlag(BMDDeckLinkSupportsInternalKeying, &flag) == S_OK && flag) { self->mKeyingSupported = true; - if (pAttributes->GetFlag(BMDDeckLinkSupportsHDKeying, &flag) == S_OK && flag) - { + if (pAttributes->GetFlag(BMDDeckLinkSupportsHDKeying, &flag) == S_OK && flag) { self->mHDKeyingSupported = true; } } pAttributes->Release(); } - if (pDL->QueryInterface(IID_IDeckLinkOutput, (void**)&self->mDLOutput) != S_OK) + if (pDL->QueryInterface(IID_IDeckLinkOutput, (void**)&self->mDLOutput) != S_OK) { self->mDLOutput = NULL; - if (self->mKeyingSupported) - { + } + if (self->mKeyingSupported) { pDL->QueryInterface(IID_IDeckLinkKeyer, (void **)&self->mKeyer); } // we don't need the device anymore, release to avoid leaking @@ -466,12 +448,11 @@ static int DeckLink_init(DeckLink *self, PyObject *args, PyObject *kwds) outputFlags = (self->mUse3D) ? bmdVideoOutputDualStream3D : bmdVideoOutputFlagDefault; pDisplayMode = NULL; i = 0; - while (pDisplayModeIterator->Next(&pDisplayMode) == S_OK) - { + while (pDisplayModeIterator->Next(&pDisplayMode) == S_OK) { if (pDisplayMode->GetDisplayMode() == self->mDisplayMode && (pDisplayMode->GetFlags() & displayFlags) == displayFlags) { - if (self->mDLOutput->DoesSupportVideoMode(self->mDisplayMode, bmdFormat8BitBGRA, outputFlags, &support, NULL) != S_OK - || support == bmdDisplayModeNotSupported) + if (self->mDLOutput->DoesSupportVideoMode(self->mDisplayMode, bmdFormat8BitBGRA, outputFlags, &support, NULL) != S_OK || + support == bmdDisplayModeNotSupported) { printf("Warning: DeckLink card %d reports no BGRA support, proceed anyway\n", cardIdx); } @@ -498,8 +479,7 @@ static int DeckLink_init(DeckLink *self, PyObject *args, PyObject *kwds) // clear alpha channel in the frame buffer self->mLeftFrame->GetBytes((void **)&bytes); memset(bytes, 0, self->mFrameSize); - if (self->mUse3D) - { + if (self->mUse3D) { if (self->mDLOutput->CreateVideoFrame(self->mSize[0], self->mSize[1], self->mSize[0] * 4, bmdFormat8BitBGRA, bmdFrameFlagFlipVertical, &self->mRightFrame) != S_OK) THRWEXCP(DeckLinkInternalError, S_OK); // clear alpha channel in the frame buffer @@ -542,8 +522,7 @@ static PyObject *DeckLink_refresh(DeckLink *self, PyObject *args) PyObject *param; double ts = -1.0; - if (!PyArg_ParseTuple(args, "O|d:refresh", ¶m, &ts) || !PyBool_Check(param)) - { + if (!PyArg_ParseTuple(args, "O|d:refresh", ¶m, &ts) || !PyBool_Check(param)) { // report error PyErr_SetString(PyExc_TypeError, "The value must be a bool"); return NULL; @@ -560,11 +539,9 @@ static PyObject *DeckLink_refresh(DeckLink *self, PyObject *args) uint32_t *leftEye = NULL; uint32_t *rightEye = NULL; // try to process key frame from source - try - { + try { // check if optimization is possible - if (self->m_leftEye != NULL) - { + if (self->m_leftEye != NULL) { ImageBase *leftImage = self->m_leftEye->m_image; short * srcSize = leftImage->getSize(); self->mLeftFrame->GetBytes((void **)&leftEye); @@ -574,8 +551,7 @@ static PyObject *DeckLink_refresh(DeckLink *self, PyObject *args) if (!leftImage->loadImage(leftEye, self->mFrameSize, GL_BGRA, ts)) leftEye = NULL; } - else - { + else { // scaling is required, go the hard way unsigned int *src = leftImage->getImage(0, ts); if (src != NULL) @@ -584,10 +560,8 @@ static PyObject *DeckLink_refresh(DeckLink *self, PyObject *args) leftEye = NULL; } } - if (leftEye) - { - if (self->mUse3D && self->m_rightEye != NULL) - { + if (leftEye) { + if (self->mUse3D && self->m_rightEye != NULL) { ImageBase *rightImage = self->m_rightEye->m_image; short * srcSize = rightImage->getSize(); self->mRightFrame->GetBytes((void **)&rightEye); @@ -596,29 +570,25 @@ static PyObject *DeckLink_refresh(DeckLink *self, PyObject *args) // buffer has same size, can load directly rightImage->loadImage(rightEye, self->mFrameSize, GL_BGRA, ts); } - else - { + else { // scaling is required, go the hard way unsigned int *src = rightImage->getImage(0, ts); if (src != NULL) decklink_ConvImage(rightEye, self->mSize, src, srcSize, self->mUseExtend); } } - if (self->mUse3D) - { + if (self->mUse3D) { DeckLink3DFrameWrapper frame3D( (IDeckLinkVideoFrame*)self->mLeftFrame, (IDeckLinkVideoFrame*)self->mRightFrame); self->mDLOutput->DisplayVideoFrameSync(&frame3D); } - else - { + else { self->mDLOutput->DisplayVideoFrameSync((IDeckLinkVideoFrame*)self->mLeftFrame); } } // refresh texture source, if required - if (refreshSource) - { + if (refreshSource) { if (self->m_leftEye) self->m_leftEye->m_image->refresh(); if (self->m_rightEye) @@ -634,8 +604,7 @@ static PyObject *DeckLink_refresh(DeckLink *self, PyObject *args) static PyObject *DeckLink_getSource(DeckLink *self, PyObject *value, void *closure) { // if source exists - if (self->m_leftEye != NULL) - { + if (self->m_leftEye != NULL) { Py_INCREF(self->m_leftEye); return reinterpret_cast<PyObject*>(self->m_leftEye); } @@ -648,8 +617,7 @@ static PyObject *DeckLink_getSource(DeckLink *self, PyObject *value, void *closu int DeckLink_setSource(DeckLink *self, PyObject *value, void *closure) { // check new value - if (value == NULL || !pyImageTypes.in(Py_TYPE(value))) - { + if (value == NULL || !pyImageTypes.in(Py_TYPE(value))) { // report value error PyErr_SetString(PyExc_TypeError, "Invalid type of value"); return -1; @@ -742,8 +710,7 @@ static PyObject *DeckLink_getLevel(DeckLink *self, PyObject *value, void *closur static int DeckLink_setLevel(DeckLink *self, PyObject *value, void *closure) { long level; - if (value == NULL || !PyLong_Check(value)) - { + if (value == NULL || !PyLong_Check(value)) { PyErr_SetString(PyExc_TypeError, "The value must be an integer from 0 to 255"); return -1; } @@ -753,10 +720,8 @@ static int DeckLink_setLevel(DeckLink *self, PyObject *value, void *closure) else if (level < 0) level = 0; self->mKeyingLevel = (uint8_t)level; - if (self->mUseKeying) - { - if (self->mKeyer->SetLevel(self->mKeyingLevel) != S_OK) - { + if (self->mUseKeying) { + if (self->mKeyer->SetLevel(self->mKeyingLevel) != S_OK) { PyErr_SetString(PyExc_RuntimeError, "Error changin level of keyer"); return -1; } diff --git a/source/gameengine/VideoTexture/VideoDeckLink.cpp b/source/gameengine/VideoTexture/VideoDeckLink.cpp index 23161ee5963..50421f47951 100644 --- a/source/gameengine/VideoTexture/VideoDeckLink.cpp +++ b/source/gameengine/VideoTexture/VideoDeckLink.cpp @@ -40,6 +40,8 @@ // this is necessary for UINTPTR_MAX (used by atomic-ops) #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS +#ifdef __STDC_LIMIT_MACROS /* else it may be unused */ +#endif #endif #include <stdint.h> #include <string.h> @@ -138,10 +140,8 @@ public: mAllocatedSize = allocatedSize; mBuffer = address; - try - { - if (!mBufferAddrAlignment) - { + try { + if (!mBufferAddrAlignment) { DVP_CHECK(dvpGetRequiredConstantsGLCtx(&mBufferAddrAlignment, &mBufferGpuStrideAlignment, &mSemaphoreAddrAlignment, &mSemaphoreAllocSize, &mSemaphorePayloadOffset, &mSemaphorePayloadSize)); @@ -151,32 +151,30 @@ public: sysMemBuffersDesc.width = pDesc->width; sysMemBuffersDesc.height = pDesc->height; sysMemBuffersDesc.stride = pDesc->stride; - switch (pDesc->format) - { - case GL_RED_INTEGER: - sysMemBuffersDesc.format = DVP_RED_INTEGER; - break; - default: - sysMemBuffersDesc.format = DVP_BGRA; - break; + switch (pDesc->format) { + case GL_RED_INTEGER: + sysMemBuffersDesc.format = DVP_RED_INTEGER; + break; + default: + sysMemBuffersDesc.format = DVP_BGRA; + break; } - switch (pDesc->type) - { - case GL_UNSIGNED_BYTE: - sysMemBuffersDesc.type = DVP_UNSIGNED_BYTE; - break; - case GL_UNSIGNED_INT_2_10_10_10_REV: - sysMemBuffersDesc.type = DVP_UNSIGNED_INT_2_10_10_10_REV; - break; - case GL_UNSIGNED_INT_8_8_8_8: - sysMemBuffersDesc.type = DVP_UNSIGNED_INT_8_8_8_8; - break; - case GL_UNSIGNED_INT_10_10_10_2: - sysMemBuffersDesc.type = DVP_UNSIGNED_INT_10_10_10_2; - break; - default: - sysMemBuffersDesc.type = DVP_UNSIGNED_INT; - break; + switch (pDesc->type) { + case GL_UNSIGNED_BYTE: + sysMemBuffersDesc.type = DVP_UNSIGNED_BYTE; + break; + case GL_UNSIGNED_INT_2_10_10_10_REV: + sysMemBuffersDesc.type = DVP_UNSIGNED_INT_2_10_10_10_REV; + break; + case GL_UNSIGNED_INT_8_8_8_8: + sysMemBuffersDesc.type = DVP_UNSIGNED_INT_8_8_8_8; + break; + case GL_UNSIGNED_INT_10_10_10_2: + sysMemBuffersDesc.type = DVP_UNSIGNED_INT_10_10_10_2; + break; + default: + sysMemBuffersDesc.type = DVP_UNSIGNED_INT; + break; } sysMemBuffersDesc.size = pDesc->width * pDesc->height * 4; sysMemBuffersDesc.bufAddr = mBuffer; @@ -185,8 +183,7 @@ public: mDvpTextureHandle = dvpTextureHandle; mTextureHeight = pDesc->height; } - catch (Exception &) - { + catch (Exception &) { clean(); throw; } @@ -224,8 +221,7 @@ private: void clean() { - if (mDvpSysMemHandle) - { + if (mDvpSysMemHandle) { dvpUnbindFromGLCtx(mDvpSysMemHandle); dvpDestroyBuffer(mDvpSysMemHandle); } @@ -306,14 +302,14 @@ private: class TextureTransferPMD : public TextureTransfer { public: - TextureTransferPMD(GLuint texId, TextureDesc *pDesc, void *address, uint32_t allocatedSize) + TextureTransferPMD(GLuint texId, TextureDesc *pDesc, void *address, uint32_t allocatedSize) { memcpy(&mDesc, pDesc, sizeof(mDesc)); mTexId = texId; mBuffer = address; - mAllocatedSize = allocatedSize; + mAllocatedSize = allocatedSize; - _PinBuffer(address, allocatedSize); + _PinBuffer(address, allocatedSize); // as we cache transfer object, we will create one texture to hold the buffer glGenBuffers(1, &mPinnedTextureBuffer); @@ -335,7 +331,7 @@ public: glBindTexture(GL_TEXTURE_2D, mTexId); // NULL for last arg indicates use current GL_PIXEL_UNPACK_BUFFER target as texture data glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, mDesc.width, mDesc.height, mDesc.format, mDesc.type, NULL); - // wait for the trasnfer to complete + // wait for the trasnfer to complete GLsync fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); glClientWaitSync(fence, GL_SYNC_FLUSH_COMMANDS_BIT, 40 * 1000 * 1000); // timeout in nanosec glDeleteSync(fence); @@ -405,20 +401,18 @@ bool PinnedMemoryAllocator::ReserveMemory(size_t size) return false; mReservedProcessMemory = size; CloseHandle(hProcess); - return true; + return true; #else - struct rlimit rlim; - if (getrlimit(RLIMIT_MEMLOCK, &rlim) == 0) - { - if (rlim.rlim_cur < size) - { - if (rlim.rlim_max < size) - rlim.rlim_max = size; - rlim.rlim_cur = size; - return !setrlimit(RLIMIT_MEMLOCK, &rlim); - } - } - return false; + struct rlimit rlim; + if (getrlimit(RLIMIT_MEMLOCK, &rlim) == 0) { + if (rlim.rlim_cur < size) { + if (rlim.rlim_max < size) + rlim.rlim_max = size; + rlim.rlim_cur = size; + return !setrlimit(RLIMIT_MEMLOCK, &rlim); + } + } + return false; #endif } @@ -432,22 +426,19 @@ mBufferCacheSize(cacheSize) { pthread_mutex_init(&mMutex, NULL); // do it once - if (!mGPUDirectInitialized) - { + if (!mGPUDirectInitialized) { #ifdef WIN32 // In windows, AMD_pinned_memory option is not available, // we must use special DVP API only available for Quadro cards const char* renderer = (const char *)glGetString(GL_RENDERER); mHasDvp = (strstr(renderer, "Quadro") != NULL); - if (mHasDvp) - { - // In case the DLL is not in place, don't fail, just fallback on OpenGL - if (dvpInitGLContext(DVP_DEVICE_FLAGS_SHARE_APP_CONTEXT) != DVP_STATUS_OK) - { - printf("Warning: Could not initialize DVP context, fallback on OpenGL transfer.\nInstall dvp.dll to take advantage of nVidia GPUDirect.\n"); - mHasDvp = false; - } + if (mHasDvp) { + // In case the DLL is not in place, don't fail, just fallback on OpenGL + if (dvpInitGLContext(DVP_DEVICE_FLAGS_SHARE_APP_CONTEXT) != DVP_STATUS_OK) { + printf("Warning: Could not initialize DVP context, fallback on OpenGL transfer.\nInstall dvp.dll to take advantage of nVidia GPUDirect.\n"); + mHasDvp = false; + } } #endif if (GLEW_AMD_pinned_memory) @@ -455,8 +446,7 @@ mBufferCacheSize(cacheSize) mGPUDirectInitialized = true; } - if (mHasDvp || mHasAMDPinnedMemory) - { + if (mHasDvp || mHasAMDPinnedMemory) { ReserveMemory(memSize); } } @@ -465,15 +455,13 @@ PinnedMemoryAllocator::~PinnedMemoryAllocator() { void *address; // first clean the cache if not already done - while (!mBufferCache.empty()) - { + while (!mBufferCache.empty()) { address = mBufferCache.back(); mBufferCache.pop_back(); _ReleaseBuffer(address); } // clean preallocated buffers - while (!mAllocatedSize.empty()) - { + while (!mAllocatedSize.empty()) { address = mAllocatedSize.begin()->first; _ReleaseBuffer(address); } @@ -531,12 +519,10 @@ void PinnedMemoryAllocator::TransferBuffer(void* address, TextureDesc* texDesc, pTransfer = new TextureTransferDvp(mDvpCaptureTextureHandle, texDesc, address, allocatedSize); else #endif - if (mHasAMDPinnedMemory) - { - pTransfer = new TextureTransferPMD(texId, texDesc, address, allocatedSize); + if (mHasAMDPinnedMemory) { + pTransfer = new TextureTransferPMD(texId, texDesc, address, allocatedSize); } - else - { + else { pTransfer = new TextureTransferOGL(texId, texDesc, address); } if (pTransfer) @@ -558,13 +544,13 @@ HRESULT STDMETHODCALLTYPE PinnedMemoryAllocator::QueryInterface(REFIID /*iid*/, ULONG STDMETHODCALLTYPE PinnedMemoryAllocator::AddRef(void) { - return atomic_add_uint32(&mRefCount, 1U); + return atomic_add_uint32(&mRefCount, 1U); } ULONG STDMETHODCALLTYPE PinnedMemoryAllocator::Release(void) { uint32_t newCount = atomic_sub_uint32(&mRefCount, 1U); - if (newCount == 0) + if (newCount == 0) delete this; return (ULONG)newCount; } @@ -577,12 +563,11 @@ HRESULT STDMETHODCALLTYPE PinnedMemoryAllocator::AllocateBuffer(dl_size_t buffer { // Allocate memory on a page boundary // Note: aligned alloc exist in Blender but only for small alignment, use direct allocation then. - // Note: the DeckLink API tries to allocate up to 65 buffer in advance, we will limit this to 3 + // Note: the DeckLink API tries to allocate up to 65 buffer in advance, we will limit this to 3 // because we don't need any caching - if (mAllocatedSize.size() >= mBufferCacheSize) + if (mAllocatedSize.size() >= mBufferCacheSize) *allocatedBuffer = NULL; - else - { + else { #ifdef WIN32 *allocatedBuffer = VirtualAlloc(NULL, bufferSize, MEM_COMMIT | MEM_RESERVE | MEM_WRITE_WATCH, PAGE_READWRITE); #else @@ -592,8 +577,7 @@ HRESULT STDMETHODCALLTYPE PinnedMemoryAllocator::AllocateBuffer(dl_size_t buffer mAllocatedSize[*allocatedBuffer] = bufferSize; } } - else - { + else { // Re-use most recently ReleaseBuffer'd address *allocatedBuffer = mBufferCache.back(); mBufferCache.pop_back(); @@ -606,12 +590,10 @@ HRESULT STDMETHODCALLTYPE PinnedMemoryAllocator::ReleaseBuffer(void* buffer) { HRESULT result = S_OK; Lock(); - if (mBufferCache.size() < mBufferCacheSize) - { + if (mBufferCache.size() < mBufferCacheSize) { mBufferCache.push_back(buffer); } - else - { + else { result = _ReleaseBuffer(buffer); } Unlock(); @@ -622,16 +604,13 @@ HRESULT STDMETHODCALLTYPE PinnedMemoryAllocator::ReleaseBuffer(void* buffer) HRESULT PinnedMemoryAllocator::_ReleaseBuffer(void* buffer) { TextureTransfer *pTransfer; - if (mAllocatedSize.count(buffer) == 0) - { + if (mAllocatedSize.count(buffer) == 0) { // Internal error!! return S_OK; } - else - { + else { // No room left in cache, so un-pin (if it was pinned) and free this buffer - if (mPinnedBuffer.count(buffer) > 0) - { + if (mPinnedBuffer.count(buffer) > 0) { pTransfer = mPinnedBuffer[buffer]; mPinnedBuffer.erase(buffer); delete pTransfer; @@ -655,8 +634,7 @@ HRESULT STDMETHODCALLTYPE PinnedMemoryAllocator::Decommit() { void *buffer; Lock(); - while (!mBufferCache.empty()) - { + while (!mBufferCache.empty()) { // Cleanup any frames allocated and pinned in AllocateBuffer() but not freed in ReleaseBuffer() buffer = mBufferCache.back(); mBufferCache.pop_back(); @@ -677,13 +655,11 @@ CaptureDelegate::CaptureDelegate(VideoDeckLink* pOwner) : mpOwner(pOwner) HRESULT CaptureDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame* inputFrame, IDeckLinkAudioInputPacket* /*audioPacket*/) { - if (!inputFrame) - { + if (!inputFrame) { // It's possible to receive a NULL inputFrame, but a valid audioPacket. Ignore audio-only frame. return S_OK; } - if ((inputFrame->GetFlags() & bmdFrameHasNoInputSource) == bmdFrameHasNoInputSource) - { + if ((inputFrame->GetFlags() & bmdFrameHasNoInputSource) == bmdFrameHasNoInputSource) { // let's not bother transferring frames if there is no source return S_OK; } @@ -739,8 +715,8 @@ VideoDeckLink::~VideoDeckLink () mDLInput->StopStreams(); mDLInput->SetCallback(NULL); mDLInput->DisableVideoInput(); - mDLInput->DisableAudioInput(); - mDLInput->FlushStreams(); + mDLInput->DisableAudioInput(); + mDLInput->FlushStreams(); if (mDLInput->Release() != 0) THRWEXCP(DeckLinkInternalError, S_OK); mDLInput = NULL; @@ -762,7 +738,7 @@ VideoDeckLink::~VideoDeckLink () void VideoDeckLink::refresh(void) { - m_avail = false; + m_avail = false; } // release components @@ -808,12 +784,10 @@ void VideoDeckLink::openCam (char *format, short camIdx) // "HD1080p24/10BitRGB/3D" (same as "24ps/r210/3D") // (this will be the normal capture format for FullHD on the DeckLink 4k extreme) - if ((pSize = strchr(format, ':')) != NULL) - { + if ((pSize = strchr(format, ':')) != NULL) { cacheSize = strtol(pSize+1, &pEnd, 10); } - else - { + else { cacheSize = 8; pSize = format + strlen(format); } @@ -827,23 +801,21 @@ void VideoDeckLink::openCam (char *format, short camIdx) // read the mode len = (size_t)(pPixel - format); - // accept integer display mode - - try - { - // throws if bad mode - decklink_ReadDisplayMode(format, len, &mDisplayMode); - // found a valid mode, remember that we do not look for an index - modeIdx = -1; - } - catch (Exception &) - { - // accept also purely numerical mode as a mode index - modeIdx = strtol(format, &pEnd, 10); - if (pEnd != pPixel || modeIdx < 0) - // not a pure number, give up - throw; - } + // accept integer display mode + + try { + // throws if bad mode + decklink_ReadDisplayMode(format, len, &mDisplayMode); + // found a valid mode, remember that we do not look for an index + modeIdx = -1; + } + catch (Exception &) { + // accept also purely numerical mode as a mode index + modeIdx = strtol(format, &pEnd, 10); + if (pEnd != pPixel || modeIdx < 0) + // not a pure number, give up + throw; + } // skip / pPixel++; @@ -854,13 +826,10 @@ void VideoDeckLink::openCam (char *format, short camIdx) // Caution: DeckLink API used from this point, make sure entity are released before throwing // open the card pIterator = BMD_CreateDeckLinkIterator(); - if (pIterator) - { + if (pIterator) { i = 0; - while (pIterator->Next(&pDL) == S_OK) - { - if (i == camIdx) - { + while (pIterator->Next(&pDL) == S_OK) { + if (i == camIdx) { if (pDL->QueryInterface(IID_IDeckLinkInput, (void**)&mDLInput) != S_OK) mDLInput = NULL; pDL->Release(); @@ -882,22 +851,24 @@ void VideoDeckLink::openCam (char *format, short camIdx) pDLDisplayMode = NULL; displayFlags = (mUse3D) ? bmdDisplayModeSupports3D : 0; inputFlags = (mUse3D) ? bmdVideoInputDualStream3D : bmdVideoInputFlagDefault; - while (pDLDisplayModeIterator->Next(&pDLDisplayMode) == S_OK) + while (pDLDisplayModeIterator->Next(&pDLDisplayMode) == S_OK) { - if (modeIdx == 0 || pDLDisplayMode->GetDisplayMode() == mDisplayMode) - { - // in case we get here because of modeIdx, make sure we have mDisplayMode set - mDisplayMode = pDLDisplayMode->GetDisplayMode(); - if ( (pDLDisplayMode->GetFlags() & displayFlags) == displayFlags - && mDLInput->DoesSupportVideoMode(mDisplayMode, mPixelFormat, inputFlags, &modeSupport, NULL) == S_OK - && modeSupport == bmdDisplayModeSupported) - break; - } + if (modeIdx == 0 || pDLDisplayMode->GetDisplayMode() == mDisplayMode) { + // in case we get here because of modeIdx, make sure we have mDisplayMode set + mDisplayMode = pDLDisplayMode->GetDisplayMode(); + if ((pDLDisplayMode->GetFlags() & displayFlags) == displayFlags && + mDLInput->DoesSupportVideoMode(mDisplayMode, mPixelFormat, inputFlags, &modeSupport, NULL) == S_OK && + modeSupport == bmdDisplayModeSupported) + { + break; + } + } pDLDisplayMode->Release(); pDLDisplayMode = NULL; - if (modeIdx-- == 0) - // reached the correct mode index but it does not meet the pixel format, give up - break; + if (modeIdx-- == 0) { + // reached the correct mode index but it does not meet the pixel format, give up + break; + } } pDLDisplayModeIterator->Release(); @@ -912,7 +883,7 @@ void VideoDeckLink::openCam (char *format, short camIdx) // for information, in case the application wants to know m_size[0] = mFrameWidth; m_size[1] = mTextureDesc.height; - m_frameRate = (float)frameTimescale / (float)frameDuration; + m_frameRate = (float)frameTimescale / (float)frameDuration; switch (mPixelFormat) { @@ -987,15 +958,15 @@ void VideoDeckLink::openCam (char *format, short camIdx) if (mDLInput->SetVideoInputFrameMemoryAllocator(mpAllocator) != S_OK) THRWEXCP(DeckLinkInternalError, S_OK); - mpCaptureDelegate = new CaptureDelegate(this); - if (mDLInput->SetCallback(mpCaptureDelegate) != S_OK) - THRWEXCP(DeckLinkInternalError, S_OK); + mpCaptureDelegate = new CaptureDelegate(this); + if (mDLInput->SetCallback(mpCaptureDelegate) != S_OK) + THRWEXCP(DeckLinkInternalError, S_OK); - if (mDLInput->EnableVideoInput(mDisplayMode, mPixelFormat, ((mUse3D) ? bmdVideoInputDualStream3D : bmdVideoInputFlagDefault)) != S_OK) + if (mDLInput->EnableVideoInput(mDisplayMode, mPixelFormat, ((mUse3D) ? bmdVideoInputDualStream3D : bmdVideoInputFlagDefault)) != S_OK) // this shouldn't failed, we tested above THRWEXCP(DeckLinkInternalError, S_OK); - // just in case it is needed to capture from certain cards, we don't check error because we don't need audio + // just in case it is needed to capture from certain cards, we don't check error because we don't need audio mDLInput->EnableAudioInput(bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, 2); // open base class @@ -1070,37 +1041,32 @@ void VideoDeckLink::calcImage (unsigned int texId, double ts) pFrame = mpCacheFrame; mpCacheFrame = NULL; UnlockCache(); - if (pFrame) - { + if (pFrame) { // BUG: the dvpBindToGLCtx function fails the first time it is used, don't know why. // This causes an exception to be thrown. // This should be fixed but in the meantime we will catch the exception because // it is crucial that we release the frame to keep the reference count right on the DeckLink device - try - { + try { uint32_t rowSize = pFrame->GetRowBytes(); uint32_t textureSize = rowSize * pFrame->GetHeight(); void* videoPixels = NULL; void* rightEyePixels = NULL; - if (!mTextureDesc.stride) - { + if (!mTextureDesc.stride) { // we could not compute the texture size earlier (unknown pixel size) // let's do it now mTextureDesc.stride = rowSize; mTextureDesc.width = mTextureDesc.stride / 4; } - if (mTextureDesc.stride != rowSize) - { + if (mTextureDesc.stride != rowSize) { // unexpected frame size, ignore // TBD: print a warning } - else - { + else { pFrame->GetBytes(&videoPixels); if (mUse3D) { IDeckLinkVideoFrame3DExtensions *if3DExtensions = NULL; IDeckLinkVideoFrame *rightEyeFrame = NULL; - if (pFrame->QueryInterface(IID_IDeckLinkVideoFrame3DExtensions, (void **)&if3DExtensions) == S_OK && + if (pFrame->QueryInterface(IID_IDeckLinkVideoFrame3DExtensions, (void **)&if3DExtensions) == S_OK && if3DExtensions->GetFrameForRightEye(&rightEyeFrame) == S_OK) { rightEyeFrame->GetBytes(&rightEyePixels); textureSize += ((uint64_t)rightEyePixels - (uint64_t)videoPixels); @@ -1110,17 +1076,15 @@ void VideoDeckLink::calcImage (unsigned int texId, double ts) if (if3DExtensions) if3DExtensions->Release(); } - mTextureDesc.size = mTextureDesc.width * mTextureDesc.height * 4; - if (mTextureDesc.size == textureSize) - { + mTextureDesc.size = mTextureDesc.width * mTextureDesc.height * 4; + if (mTextureDesc.size == textureSize) { // this means that both left and right frame are contiguous and that there is no padding // do the transfer mpAllocator->TransferBuffer(videoPixels, &mTextureDesc, texId); } } } - catch (Exception &) - { + catch (Exception &) { pFrame->Release(); throw; } @@ -1161,8 +1125,7 @@ static int VideoDeckLink_init(PyObject *pySelf, PyObject *args, PyObject *kwds) // capture device number, i.e. DeckLink card number, default first one short capt = 0; - if (!GLEW_VERSION_1_5) - { + if (!GLEW_VERSION_1_5) { PyErr_SetString(PyExc_RuntimeError, "VideoDeckLink requires at least OpenGL 1.5"); return -1; } @@ -1171,16 +1134,14 @@ static int VideoDeckLink_init(PyObject *pySelf, PyObject *args, PyObject *kwds) const_cast<char**>(kwlist), &format, &capt)) return -1; - try - { + try { // create video object Video_init<VideoDeckLink>(self); // open video source, control comes back to VideoDeckLink::openCam Video_open(getVideo(self), format, capt); } - catch (Exception & exp) - { + catch (Exception & exp) { exp.report(); return -1; } diff --git a/source/gameengine/VideoTexture/VideoDeckLink.h b/source/gameengine/VideoTexture/VideoDeckLink.h index cd87d4afbdc..fc55460b379 100644 --- a/source/gameengine/VideoTexture/VideoDeckLink.h +++ b/source/gameengine/VideoTexture/VideoDeckLink.h @@ -96,8 +96,8 @@ public: /// release video source virtual bool release (void); - /// overwrite base refresh to handle fixed image - virtual void refresh(void); + /// overwrite base refresh to handle fixed image + virtual void refresh(void); /// play video virtual bool play (void); /// pause video @@ -193,7 +193,7 @@ public: virtual ULONG STDMETHODCALLTYPE Release(void); // IDeckLinkMemoryAllocator methods - virtual HRESULT STDMETHODCALLTYPE AllocateBuffer(dl_size_t bufferSize, void* *allocatedBuffer); + virtual HRESULT STDMETHODCALLTYPE AllocateBuffer(dl_size_t bufferSize, void* *allocatedBuffer); virtual HRESULT STDMETHODCALLTYPE ReleaseBuffer(void* buffer); virtual HRESULT STDMETHODCALLTYPE Commit(); virtual HRESULT STDMETHODCALLTYPE Decommit(); |