瀏覽代碼

decklink, win-dshow: Use obs_source_output_video2

Allows the ability to override and use partial range RGB with the
DirectShow and Decklink device sources when partial range RGB is
implemented.  Fixes certain cases where devices could capture RGB in
limited range via HDMI (per the HDMI specs).
jp9000 6 年之前
父節點
當前提交
7d136c3ce1

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

@@ -135,7 +135,7 @@ void DeckLinkDeviceInstance::HandleVideoFrame(
 	currentFrame.height      = (uint32_t)videoFrame->GetHeight();
 	currentFrame.height      = (uint32_t)videoFrame->GetHeight();
 	currentFrame.timestamp   = timestamp;
 	currentFrame.timestamp   = timestamp;
 
 
-	obs_source_output_video(static_cast<DeckLinkInput*>(decklink)->GetSource(), &currentFrame);
+	obs_source_output_video2(static_cast<DeckLinkInput*>(decklink)->GetSource(), &currentFrame);
 }
 }
 
 
 void DeckLinkDeviceInstance::FinalizeStream()
 void DeckLinkDeviceInstance::FinalizeStream()
@@ -177,7 +177,7 @@ void DeckLinkDeviceInstance::SetupVideoFormat(DeckLinkDeviceMode *mode_)
 	}
 	}
 
 
 	colorRange = static_cast<DeckLinkInput*>(decklink)->GetColorRange();
 	colorRange = static_cast<DeckLinkInput*>(decklink)->GetColorRange();
-	currentFrame.full_range = colorRange == VIDEO_RANGE_FULL;
+	currentFrame.range = colorRange;
 
 
 	video_format_get_parameters(activeColorSpace, colorRange,
 	video_format_get_parameters(activeColorSpace, colorRange,
 			currentFrame.color_matrix, currentFrame.color_range_min,
 			currentFrame.color_matrix, currentFrame.color_range_min,

+ 1 - 1
plugins/decklink/decklink-device-instance.hpp

@@ -11,7 +11,7 @@ class DecklinkBase;
 
 
 class DeckLinkDeviceInstance : public IDeckLinkInputCallback {
 class DeckLinkDeviceInstance : public IDeckLinkInputCallback {
 protected:
 protected:
-	struct obs_source_frame currentFrame;
+	struct obs_source_frame2 currentFrame;
 	struct obs_source_audio currentPacket;
 	struct obs_source_audio currentPacket;
 	DecklinkBase            *decklink = nullptr;
 	DecklinkBase            *decklink = nullptr;
 	DeckLinkDevice          *device = nullptr;
 	DeckLinkDevice          *device = nullptr;

+ 5 - 8
plugins/win-dshow/ffmpeg-decode.c

@@ -181,7 +181,7 @@ bool ffmpeg_decode_audio(struct ffmpeg_decode *decode,
 
 
 bool ffmpeg_decode_video(struct ffmpeg_decode *decode,
 bool ffmpeg_decode_video(struct ffmpeg_decode *decode,
 		uint8_t *data, size_t size, long long *ts,
 		uint8_t *data, size_t size, long long *ts,
-		struct obs_source_frame *frame,
+		struct obs_source_frame2 *frame,
 		bool *got_output)
 		bool *got_output)
 {
 {
 	AVPacket packet = {0};
 	AVPacket packet = {0};
@@ -230,17 +230,14 @@ bool ffmpeg_decode_video(struct ffmpeg_decode *decode,
 	new_format = convert_pixel_format(decode->frame->format);
 	new_format = convert_pixel_format(decode->frame->format);
 	if (new_format != frame->format) {
 	if (new_format != frame->format) {
 		bool success;
 		bool success;
-		enum video_range_type range;
 
 
 		frame->format = new_format;
 		frame->format = new_format;
-		frame->full_range =
-			decode->frame->color_range == AVCOL_RANGE_JPEG;
-
-		range = frame->full_range ?
-			VIDEO_RANGE_FULL : VIDEO_RANGE_PARTIAL;
+		frame->range = decode->frame->color_range == AVCOL_RANGE_JPEG
+			? VIDEO_RANGE_FULL
+			: VIDEO_RANGE_DEFAULT;
 
 
 		success = video_format_get_parameters(VIDEO_CS_601,
 		success = video_format_get_parameters(VIDEO_CS_601,
-				range, frame->color_matrix,
+				frame->range, frame->color_matrix,
 				frame->color_range_min, frame->color_range_max);
 				frame->color_range_min, frame->color_range_max);
 		if (!success) {
 		if (!success) {
 			blog(LOG_ERROR, "Failed to get video format "
 			blog(LOG_ERROR, "Failed to get video format "

+ 1 - 1
plugins/win-dshow/ffmpeg-decode.h

@@ -56,7 +56,7 @@ extern bool ffmpeg_decode_audio(struct ffmpeg_decode *decode,
 
 
 extern bool ffmpeg_decode_video(struct ffmpeg_decode *decode,
 extern bool ffmpeg_decode_video(struct ffmpeg_decode *decode,
 		uint8_t *data, size_t size, long long *ts,
 		uint8_t *data, size_t size, long long *ts,
-		struct obs_source_frame *frame,
+		struct obs_source_frame2 *frame,
 		bool *got_output);
 		bool *got_output);
 
 
 static inline bool ffmpeg_decode_valid(struct ffmpeg_decode *decode)
 static inline bool ffmpeg_decode_valid(struct ffmpeg_decode *decode)

+ 7 - 9
plugins/win-dshow/win-dshow.cpp

@@ -176,7 +176,7 @@ struct DShowInput {
 	VideoConfig  videoConfig;
 	VideoConfig  videoConfig;
 	AudioConfig  audioConfig;
 	AudioConfig  audioConfig;
 
 
-	obs_source_frame frame;
+	obs_source_frame2 frame;
 	obs_source_audio audio;
 	obs_source_audio audio;
 
 
 	WinHandle semaphore;
 	WinHandle semaphore;
@@ -327,7 +327,7 @@ void DShowInput::DShowLoop()
 				obs_data_t *settings;
 				obs_data_t *settings;
 				settings = obs_source_get_settings(source);
 				settings = obs_source_get_settings(source);
 				if (!Activate(settings)) {
 				if (!Activate(settings)) {
-					obs_source_output_video(source,
+					obs_source_output_video2(source,
 							nullptr);
 							nullptr);
 				}
 				}
 				if (block)
 				if (block)
@@ -468,7 +468,7 @@ void DShowInput::OnEncodedVideoData(enum AVCodecID id,
 #if LOG_ENCODED_VIDEO_TS
 #if LOG_ENCODED_VIDEO_TS
 		blog(LOG_DEBUG, "video ts: %llu", frame.timestamp);
 		blog(LOG_DEBUG, "video ts: %llu", frame.timestamp);
 #endif
 #endif
-		obs_source_output_video(source, &frame);
+		obs_source_output_video2(source, &frame);
 	}
 	}
 }
 }
 
 
@@ -537,7 +537,7 @@ void DShowInput::OnVideoData(const VideoConfig &config,
 		return;
 		return;
 	}
 	}
 
 
-	obs_source_output_video(source, &frame);
+	obs_source_output_video2(source, &frame);
 
 
 	UNUSED_PARAMETER(endTime); /* it's the enndd tiimmes! */
 	UNUSED_PARAMETER(endTime); /* it's the enndd tiimmes! */
 	UNUSED_PARAMETER(size);
 	UNUSED_PARAMETER(size);
@@ -1040,15 +1040,13 @@ inline bool DShowInput::Activate(obs_data_t *settings)
 		return false;
 		return false;
 
 
 	enum video_colorspace cs = GetColorSpace(settings);
 	enum video_colorspace cs = GetColorSpace(settings);
-
-	video_range_type range = GetColorRange(settings);
-	frame.full_range = range == VIDEO_RANGE_FULL;
+	frame.range = GetColorRange(settings);
 
 
 	if (device.Start() != Result::Success)
 	if (device.Start() != Result::Success)
 		return false;
 		return false;
 
 
 	bool success = video_format_get_parameters(
 	bool success = video_format_get_parameters(
-			cs, range,
+			cs, frame.range,
 			frame.color_matrix,
 			frame.color_matrix,
 			frame.color_range_min,
 			frame.color_range_min,
 			frame.color_range_max);
 			frame.color_range_max);
@@ -1063,7 +1061,7 @@ inline bool DShowInput::Activate(obs_data_t *settings)
 inline void DShowInput::Deactivate()
 inline void DShowInput::Deactivate()
 {
 {
 	device.ResetGraph();
 	device.ResetGraph();
-	obs_source_output_video(source, nullptr);
+	obs_source_output_video2(source, nullptr);
 }
 }
 
 
 /* ------------------------------------------------------------------------- */
 /* ------------------------------------------------------------------------- */