Bladeren bron

Decklink: only use RGBA when using keyer

Colin Edwards 6 jaren geleden
bovenliggende
commit
e296855d14
2 gewijzigde bestanden met toevoegingen van 27 en 7 verwijderingen
  1. 21 6
      plugins/decklink/decklink-device-instance.cpp
  2. 6 1
      plugins/decklink/decklink-output.cpp

+ 21 - 6
plugins/decklink/decklink-device-instance.cpp

@@ -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);
 }

+ 6 - 1
plugins/decklink/decklink-output.cpp

@@ -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();