Decklink: only use RGBA when using keyer

This commit is contained in:
Colin Edwards 2019-01-04 22:25:08 -06:00
parent 37dc3cde2b
commit e296855d14
2 changed files with 27 additions and 7 deletions

View File

@ -1,4 +1,4 @@
#include "decklink-device-instance.hpp"
#include "decklink-device-instance.hpp"
#include "audio-repack.hpp"
#include "DecklinkInput.hpp"
@ -312,10 +312,10 @@ bool DeckLinkDeviceInstance::StartOutput(DeckLinkDeviceMode *mode_)
mode = mode_;
int keyerMode = device->GetKeyerMode();
IDeckLinkKeyer *deckLinkKeyer = nullptr;
if (device->GetKeyer(&deckLinkKeyer)) {
int keyerMode = device->GetKeyerMode();
if (keyerMode) {
deckLinkKeyer->Enable(keyerMode == 1);
deckLinkKeyer->SetLevel(255);
@ -328,11 +328,21 @@ bool DeckLinkDeviceInstance::StartOutput(DeckLinkDeviceMode *mode_)
if (decklinkOutput == nullptr)
return false;
int rowBytes = decklinkOutput->GetWidth() * 2;
if (decklinkOutput->keyerMode != 0) {
rowBytes = decklinkOutput->GetWidth() * 4;
}
BMDPixelFormat pixelFormat = bmdFormat8BitYUV;
if (keyerMode != 0) {
pixelFormat = bmdFormat8BitBGRA;
}
HRESULT result;
result = output->CreateVideoFrame(decklinkOutput->GetWidth(),
decklinkOutput->GetHeight(),
decklinkOutput->GetWidth() * 4,
bmdFormat8BitBGRA,
rowBytes,
pixelFormat,
bmdFrameFlagDefault,
&decklinkOutputFrame);
if (result != S_OK) {
@ -373,8 +383,13 @@ void DeckLinkDeviceInstance::DisplayVideoFrame(video_data *frame)
uint8_t *outData = frame->data[0];
std::copy(outData, outData + (decklinkOutput->GetWidth() *
decklinkOutput->GetHeight() * 4), destData);
int rowBytes = decklinkOutput->GetWidth() * 2;
if (device->GetKeyerMode()) {
rowBytes = decklinkOutput->GetWidth() * 4;
}
std::copy(outData, outData + (decklinkOutput->GetHeight() *
rowBytes), destData);
output->DisplayVideoFrameSync(decklinkOutputFrame);
}

View File

@ -61,7 +61,12 @@ static bool decklink_output_start(void *data)
decklink->SetSize(mode->GetWidth(), mode->GetHeight());
struct video_scale_info to = {};
to.format = VIDEO_FORMAT_BGRA;
if (decklink->keyerMode != 0) {
to.format = VIDEO_FORMAT_BGRA;
} else {
to.format = VIDEO_FORMAT_UYVY;
}
to.width = mode->GetWidth();
to.height = mode->GetHeight();