Преглед на файлове

mac-capture: Support P3 for HDR recordings

jpark37 преди 3 години
родител
ревизия
d84a9dad8a
променени са 1 файла, в които са добавени 29 реда и са изтрити 10 реда
  1. 29 10
      plugins/mac-capture/mac-screen-capture.m

+ 29 - 10
plugins/mac-capture/mac-screen-capture.m

@@ -462,8 +462,8 @@ static bool init_screen_stream(struct screen_capture *sc)
 	os_sem_post(sc->shareable_content_available);
 	os_sem_post(sc->shareable_content_available);
 	[sc->stream_properties setQueueDepth:8];
 	[sc->stream_properties setQueueDepth:8];
 	[sc->stream_properties setShowsCursor:!sc->hide_cursor];
 	[sc->stream_properties setShowsCursor:!sc->hide_cursor];
-	[sc->stream_properties setColorSpaceName:kCGColorSpaceSRGB];
-	[sc->stream_properties setPixelFormat:'BGRA'];
+	[sc->stream_properties setColorSpaceName:kCGColorSpaceDisplayP3];
+	[sc->stream_properties setPixelFormat:'l10r'];
 #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 130000
 #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 130000
 	if (@available(macOS 13.0, *)) {
 	if (@available(macOS 13.0, *)) {
 		[sc->stream_properties setCapturesAudio:TRUE];
 		[sc->stream_properties setCapturesAudio:TRUE];
@@ -649,18 +649,13 @@ static void screen_capture_video_render(void *data, gs_effect_t *effect
 	if (!sc->tex)
 	if (!sc->tex)
 		return;
 		return;
 
 
-	const bool linear_srgb = gs_get_linear_srgb();
-
 	const bool previous = gs_framebuffer_srgb_enabled();
 	const bool previous = gs_framebuffer_srgb_enabled();
-	gs_enable_framebuffer_srgb(linear_srgb);
+	gs_enable_framebuffer_srgb(true);
 
 
 	gs_eparam_t *param = gs_effect_get_param_by_name(sc->effect, "image");
 	gs_eparam_t *param = gs_effect_get_param_by_name(sc->effect, "image");
-	if (linear_srgb)
-		gs_effect_set_texture_srgb(param, sc->tex);
-	else
-		gs_effect_set_texture(param, sc->tex);
+	gs_effect_set_texture(param, sc->tex);
 
 
-	while (gs_effect_loop(sc->effect, "Draw"))
+	while (gs_effect_loop(sc->effect, "DrawD65P3"))
 		gs_draw_sprite(sc->tex, 0, 0, 0);
 		gs_draw_sprite(sc->tex, 0, 0, 0);
 
 
 	gs_enable_framebuffer_srgb(previous);
 	gs_enable_framebuffer_srgb(previous);
@@ -1034,6 +1029,29 @@ static obs_properties_t *screen_capture_properties(void *data)
 	return props;
 	return props;
 }
 }
 
 
+enum gs_color_space screen_capture_video_get_color_space(
+	void *data, size_t count, const enum gs_color_space *preferred_spaces)
+{
+	UNUSED_PARAMETER(data);
+
+	for (size_t i = 0; i < count; ++i) {
+		if (preferred_spaces[i] == GS_CS_SRGB_16F)
+			return GS_CS_SRGB_16F;
+	}
+
+	for (size_t i = 0; i < count; ++i) {
+		if (preferred_spaces[i] == GS_CS_709_EXTENDED)
+			return GS_CS_709_EXTENDED;
+	}
+
+	for (size_t i = 0; i < count; ++i) {
+		if (preferred_spaces[i] == GS_CS_SRGB)
+			return GS_CS_SRGB;
+	}
+
+	return GS_CS_SRGB_16F;
+}
+
 struct obs_source_info screen_capture_info = {
 struct obs_source_info screen_capture_info = {
 	.id = "screen_capture",
 	.id = "screen_capture",
 	.type = OBS_SOURCE_TYPE_INPUT,
 	.type = OBS_SOURCE_TYPE_INPUT,
@@ -1055,6 +1073,7 @@ struct obs_source_info screen_capture_info = {
 	.get_properties = screen_capture_properties,
 	.get_properties = screen_capture_properties,
 	.update = screen_capture_update,
 	.update = screen_capture_update,
 	.icon_type = OBS_ICON_TYPE_DESKTOP_CAPTURE,
 	.icon_type = OBS_ICON_TYPE_DESKTOP_CAPTURE,
+	.video_get_color_space = screen_capture_video_get_color_space,
 };
 };
 
 
 @implementation ScreenCaptureDelegate
 @implementation ScreenCaptureDelegate