瀏覽代碼

decklink: Always output BGRA

jpark37 3 年之前
父節點
當前提交
0c4e7c4142
共有 2 個文件被更改,包括 11 次插入32 次删除
  1. 9 24
      plugins/decklink/decklink-device-instance.cpp
  2. 2 8
      plugins/decklink/decklink-output.cpp

+ 9 - 24
plugins/decklink/decklink-device-instance.cpp

@@ -521,10 +521,9 @@ bool DeckLinkDeviceInstance::StartOutput(DeckLinkDeviceMode *mode_)
 
 
 	mode = mode_;
 	mode = mode_;
 
 
-	int keyerMode = device->GetKeyerMode();
-
 	ComPtr<IDeckLinkKeyer> deckLinkKeyer;
 	ComPtr<IDeckLinkKeyer> deckLinkKeyer;
 	if (device->GetKeyer(&deckLinkKeyer)) {
 	if (device->GetKeyer(&deckLinkKeyer)) {
+		const int keyerMode = device->GetKeyerMode();
 		if (keyerMode) {
 		if (keyerMode) {
 			deckLinkKeyer->Enable(keyerMode == 1);
 			deckLinkKeyer->Enable(keyerMode == 1);
 			deckLinkKeyer->SetLevel(255);
 			deckLinkKeyer->SetLevel(255);
@@ -537,21 +536,11 @@ bool DeckLinkDeviceInstance::StartOutput(DeckLinkDeviceMode *mode_)
 	if (decklinkOutput == nullptr)
 	if (decklinkOutput == nullptr)
 		return false;
 		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;
 	HRESULT result;
-	result = output->CreateVideoFrame(decklinkOutput->GetWidth(),
-					  decklinkOutput->GetHeight(), rowBytes,
-					  pixelFormat, bmdFrameFlagDefault,
-					  &decklinkOutputFrame);
+	result = output->CreateVideoFrame(
+		decklinkOutput->GetWidth(), decklinkOutput->GetHeight(),
+		decklinkOutput->GetWidth() * 4, bmdFormat8BitBGRA,
+		bmdFrameFlagDefault, &decklinkOutputFrame);
 	if (result != S_OK) {
 	if (result != S_OK) {
 		blog(LOG_ERROR, "failed to make frame 0x%X", result);
 		blog(LOG_ERROR, "failed to make frame 0x%X", result);
 		return false;
 		return false;
@@ -571,8 +560,7 @@ bool DeckLinkDeviceInstance::StopOutput()
 	output->DisableVideoOutput();
 	output->DisableVideoOutput();
 	output->DisableAudioOutput();
 	output->DisableAudioOutput();
 
 
-	if (decklinkOutputFrame != nullptr)
-		decklinkOutputFrame = nullptr;
+	decklinkOutputFrame.Clear();
 
 
 	return true;
 	return true;
 }
 }
@@ -588,12 +576,9 @@ void DeckLinkDeviceInstance::DisplayVideoFrame(video_data *frame)
 
 
 	uint8_t *outData = frame->data[0];
 	uint8_t *outData = frame->data[0];
 
 
-	int rowBytes = decklinkOutput->GetWidth() * 2;
-	if (device->GetKeyerMode()) {
-		rowBytes = decklinkOutput->GetWidth() * 4;
-	}
-
-	std::copy(outData, outData + (decklinkOutput->GetHeight() * rowBytes),
+	std::copy(outData,
+		  outData + (decklinkOutput->GetWidth() *
+			     decklinkOutput->GetHeight() * 4),
 		  destData);
 		  destData);
 
 
 	output->DisplayVideoFrameSync(decklinkOutputFrame);
 	output->DisplayVideoFrameSync(decklinkOutputFrame);

+ 2 - 8
plugins/decklink/decklink-output.cpp

@@ -81,16 +81,10 @@ static bool decklink_output_start(void *data)
 	decklink->SetSize(mode->GetWidth(), mode->GetHeight());
 	decklink->SetSize(mode->GetWidth(), mode->GetHeight());
 
 
 	struct video_scale_info to = {};
 	struct video_scale_info to = {};
-
-	if (decklink->keyerMode != 0) {
-		to.format = VIDEO_FORMAT_BGRA;
-		to.range = VIDEO_RANGE_FULL;
-	} else {
-		to.format = VIDEO_FORMAT_UYVY;
-		to.range = VIDEO_RANGE_PARTIAL;
-	}
+	to.format = VIDEO_FORMAT_BGRA;
 	to.width = mode->GetWidth();
 	to.width = mode->GetWidth();
 	to.height = mode->GetHeight();
 	to.height = mode->GetHeight();
+	to.range = VIDEO_RANGE_FULL;
 	to.colorspace = VIDEO_CS_709;
 	to.colorspace = VIDEO_CS_709;
 
 
 	obs_output_set_video_conversion(decklink->GetOutput(), &to);
 	obs_output_set_video_conversion(decklink->GetOutput(), &to);