From 90a138ac13c7d05e9d5ab4a66e7b655ea81d8502 Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Mon, 14 Sep 2015 23:38:38 -0500 Subject: [PATCH] decklink: capture in RGB for BMI Intensity Pro 4K detect the device type when initializing the device instance and determine whether to capture YUV or RGB. tested with a Blackmagic Intensity Pro and a Blackmagic Intensity Pro 4K in the same machine, capturing at the same time, on Linux --- plugins/decklink/decklink-device-instance.cpp | 20 +++++++++++++++++-- plugins/decklink/decklink-device-instance.hpp | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/plugins/decklink/decklink-device-instance.cpp b/plugins/decklink/decklink-device-instance.cpp index 71b554f84..981074872 100644 --- a/plugins/decklink/decklink-device-instance.cpp +++ b/plugins/decklink/decklink-device-instance.cpp @@ -12,7 +12,16 @@ DeckLinkDeviceInstance::DeckLinkDeviceInstance(DeckLink *decklink_, DeckLinkDevice *device_) : currentFrame(), currentPacket(), decklink(decklink_), device(device_) { - currentFrame.format = VIDEO_FORMAT_UYVY; + // use BGRA mode if the device is a BMI intensity pro 4K... wish there + // was a better way to check the device model, but older cards don't + // implement BMDDeckLinkPersistentID + if (std::string("Intensity Pro 4K").compare(device_->GetName()) == 0) { + currentFrame.format = VIDEO_FORMAT_BGRX; + doRgb = true; + } else { + currentFrame.format = VIDEO_FORMAT_UYVY; + doRgb = false; + } currentPacket.samples_per_sec = 48000; currentPacket.speakers = SPEAKERS_STEREO; @@ -82,9 +91,16 @@ bool DeckLinkDeviceInstance::StartCapture(DeckLinkDeviceMode *mode_) input->SetCallback(this); + BMDPixelFormat pixelFormat; const BMDDisplayMode displayMode = mode_->GetDisplayMode(); + + if (doRgb) + pixelFormat = bmdFormat8BitBGRA; + else + pixelFormat = bmdFormat8BitYUV; + const HRESULT videoResult = input->EnableVideoInput(displayMode, - bmdFormat8BitYUV, bmdVideoInputFlagDefault); + pixelFormat, bmdVideoInputFlagDefault); if (videoResult != S_OK) { LOG(LOG_ERROR, "Failed to enable video input"); diff --git a/plugins/decklink/decklink-device-instance.hpp b/plugins/decklink/decklink-device-instance.hpp index 86cebdc3a..8e0d39007 100644 --- a/plugins/decklink/decklink-device-instance.hpp +++ b/plugins/decklink/decklink-device-instance.hpp @@ -8,6 +8,7 @@ protected: struct obs_source_audio currentPacket; DeckLink *decklink = nullptr; DeckLinkDevice *device = nullptr; + bool doRgb = false; DeckLinkDeviceMode *mode = nullptr; ComPtr input; volatile long refCount = 1;