Parcourir la source

decklink: Reset video capture on format change

Fixes black screen when toggling between 4K SDR and HDR on PS5.
jpark37 il y a 2 ans
Parent
commit
4fd595efe9
1 fichiers modifiés avec 16 ajouts et 9 suppressions
  1. 16 9
      plugins/decklink/decklink-device-instance.cpp

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

@@ -794,25 +794,32 @@ HRESULT STDMETHODCALLTYPE DeckLinkDeviceInstance::VideoInputFormatChanged(
 	BMDVideoInputFormatChangedEvents events, IDeckLinkDisplayMode *newMode,
 	BMDVideoInputFormatChangedEvents events, IDeckLinkDisplayMode *newMode,
 	BMDDetectedVideoInputFormatFlags detectedSignalFlags)
 	BMDDetectedVideoInputFormatFlags detectedSignalFlags)
 {
 {
+	bool formatChanged = false;
 	if (events & bmdVideoInputColorspaceChanged) {
 	if (events & bmdVideoInputColorspaceChanged) {
 		constexpr BMDDetectedVideoInputFormatFlags highBitFlags =
 		constexpr BMDDetectedVideoInputFormatFlags highBitFlags =
 			(bmdDetectedVideoInput12BitDepth |
 			(bmdDetectedVideoInput12BitDepth |
 			 bmdDetectedVideoInput10BitDepth);
 			 bmdDetectedVideoInput10BitDepth);
 		if (detectedSignalFlags & bmdDetectedVideoInputRGB444) {
 		if (detectedSignalFlags & bmdDetectedVideoInputRGB444) {
-			pixelFormat = ((detectedSignalFlags & highBitFlags) &&
-				       allow10Bit)
-					      ? bmdFormat10BitRGBXLE
-					      : bmdFormat8BitBGRA;
+			const BMDPixelFormat nextFormat =
+				((detectedSignalFlags & highBitFlags) &&
+				 allow10Bit)
+					? bmdFormat10BitRGBXLE
+					: bmdFormat8BitBGRA;
+			formatChanged = pixelFormat != nextFormat;
+			pixelFormat = nextFormat;
 		}
 		}
 		if (detectedSignalFlags & bmdDetectedVideoInputYCbCr422) {
 		if (detectedSignalFlags & bmdDetectedVideoInputYCbCr422) {
-			pixelFormat = ((detectedSignalFlags & highBitFlags) &&
-				       allow10Bit)
-					      ? bmdFormat10BitYUV
-					      : bmdFormat8BitYUV;
+			const BMDPixelFormat nextFormat =
+				((detectedSignalFlags & highBitFlags) &&
+				 allow10Bit)
+					? bmdFormat10BitYUV
+					: bmdFormat8BitYUV;
+			formatChanged = pixelFormat != nextFormat;
+			pixelFormat = nextFormat;
 		}
 		}
 	}
 	}
 
 
-	if (events & bmdVideoInputDisplayModeChanged) {
+	if (formatChanged || (events & bmdVideoInputDisplayModeChanged)) {
 		input->PauseStreams();
 		input->PauseStreams();
 		mode->SetMode(newMode);
 		mode->SetMode(newMode);
 		displayMode = mode->GetDisplayMode();
 		displayMode = mode->GetDisplayMode();