Browse Source

decklink: Support 10-bit RGB capture

Don't drop to YUV if a pure RGB signal is available.
jpark37 2 years ago
parent
commit
f5f7ae3e7f
1 changed files with 15 additions and 15 deletions
  1. 15 15
      plugins/decklink/decklink-device-instance.cpp

+ 15 - 15
plugins/decklink/decklink-device-instance.cpp

@@ -66,6 +66,8 @@ static inline enum video_format ConvertPixelFormat(BMDPixelFormat format)
 	switch (format) {
 	switch (format) {
 	case bmdFormat8BitBGRA:
 	case bmdFormat8BitBGRA:
 		return VIDEO_FORMAT_BGRX;
 		return VIDEO_FORMAT_BGRX;
+	case bmdFormat10BitRGBXLE:
+		return VIDEO_FORMAT_R10L;
 	case bmdFormat10BitYUV:
 	case bmdFormat10BitYUV:
 		return VIDEO_FORMAT_V210;
 		return VIDEO_FORMAT_V210;
 	default:
 	default:
@@ -408,12 +410,12 @@ void DeckLinkDeviceInstance::SetupVideoFormat(DeckLinkDeviceMode *mode_)
 
 
 	BMDPixelFormat convertFormat;
 	BMDPixelFormat convertFormat;
 	switch (pixelFormat) {
 	switch (pixelFormat) {
-	case bmdFormat8BitBGRA:
 	case bmdFormat10BitYUV:
 	case bmdFormat10BitYUV:
+	case bmdFormat8BitBGRA:
+	case bmdFormat10BitRGBXLE:
 		convertFormat = pixelFormat;
 		convertFormat = pixelFormat;
 		break;
 		break;
 	default:
 	default:
-	case bmdFormat8BitYUV:;
 		convertFormat = bmdFormat8BitYUV;
 		convertFormat = bmdFormat8BitYUV;
 		break;
 		break;
 	}
 	}
@@ -774,22 +776,20 @@ HRESULT STDMETHODCALLTYPE DeckLinkDeviceInstance::VideoInputFormatChanged(
 	BMDDetectedVideoInputFormatFlags detectedSignalFlags)
 	BMDDetectedVideoInputFormatFlags detectedSignalFlags)
 {
 {
 	if (events & bmdVideoInputColorspaceChanged) {
 	if (events & bmdVideoInputColorspaceChanged) {
+		constexpr BMDDetectedVideoInputFormatFlags highBitFlags =
+			(bmdDetectedVideoInput12BitDepth |
+			 bmdDetectedVideoInput10BitDepth);
 		if (detectedSignalFlags & bmdDetectedVideoInputRGB444) {
 		if (detectedSignalFlags & bmdDetectedVideoInputRGB444) {
-			pixelFormat = bmdFormat8BitBGRA;
+			pixelFormat = ((detectedSignalFlags & highBitFlags) &&
+				       allow10Bit)
+					      ? bmdFormat10BitRGBXLE
+					      : bmdFormat8BitBGRA;
 		}
 		}
 		if (detectedSignalFlags & bmdDetectedVideoInputYCbCr422) {
 		if (detectedSignalFlags & bmdDetectedVideoInputYCbCr422) {
-			if (detectedSignalFlags &
-			    bmdDetectedVideoInput10BitDepth) {
-				if (allow10Bit) {
-					pixelFormat = bmdFormat10BitYUV;
-				} else {
-					pixelFormat = bmdFormat8BitYUV;
-				}
-			}
-			if (detectedSignalFlags &
-			    bmdDetectedVideoInput8BitDepth) {
-				pixelFormat = bmdFormat8BitYUV;
-			}
+			pixelFormat = ((detectedSignalFlags & highBitFlags) &&
+				       allow10Bit)
+					      ? bmdFormat10BitYUV
+					      : bmdFormat8BitYUV;
 		}
 		}
 	}
 	}