diff --git a/src/app/stream/session.c b/src/app/stream/session.c index 961a25ba..0571ba80 100644 --- a/src/app/stream/session.c +++ b/src/app/stream/session.c @@ -29,6 +29,8 @@ static bool streaming_sops_supported(PDISPLAY_MODE modes, int w, int h, int fps) static void session_config_init(app_t *app, session_config_t *config, const SERVER_DATA *server, const CONFIGURATION *app_config); +static void populate_hdr_info_vui(SS4S_VideoHDRInfo *info, const STREAM_CONFIGURATION *config); + session_t *session_create(app_t *app, const CONFIGURATION *config, const SERVER_DATA *server, const APP_LIST *gs_app) { session_t *session = malloc(sizeof(session_t)); SDL_memset(session, 0, sizeof(session_t)); @@ -200,6 +202,7 @@ void streaming_set_hdr(session_t *session, bool hdr) { .maxContentLightLevel = hdr_metadata.maxContentLightLevel, .maxPicAverageLightLevel = hdr_metadata.maxFrameAverageLightLevel, }; + populate_hdr_info_vui(&info, &session->config.stream); SS4S_PlayerVideoSetHDRInfo(session->player, &info); } else { SS4S_VideoHDRInfo info = { @@ -212,6 +215,7 @@ void streaming_set_hdr(session_t *session, bool hdr) { .maxContentLightLevel = 1000, .maxPicAverageLightLevel = 400, }; + populate_hdr_info_vui(&info, &session->config.stream); SS4S_PlayerVideoSetHDRInfo(session->player, &info); } } @@ -313,3 +317,32 @@ void session_config_init(app_t *app, session_config_t *config, const SERVER_DATA config->stream.encryptionFlags = ENCFLG_AUDIO; } +/** + * Populate HDR info from stream configuration. + * Corresponds to @p avcodec_colorspace_from_sunshine_colorspace in video_colorspace.cpp in Sunshine. + * + * @param info Info for SS4S_PlayerVideoSetHDRInfo + * @param config Moonlight stream configuration + */ +static void populate_hdr_info_vui(SS4S_VideoHDRInfo *info, const STREAM_CONFIGURATION *config) { + switch (config->colorSpace) { + case COLORSPACE_REC_601: + info->colorPrimaries = 6 /* SMPTE 170M */; + info->transferCharacteristics = 6 /* SMPTE 170M */; + info->matrixCoefficients = 6 /* SMPTE 170M */; + break; + case COLORSPACE_REC_709: + info->colorPrimaries = 1 /* BT.709 */; + info->transferCharacteristics = 1 /* BT.709 */; + info->matrixCoefficients = 1 /* BT.709 */; + break; + case COLORSPACE_REC_2020: { + info->colorPrimaries = 9 /* BT.2020 */; + info->transferCharacteristics = 16 /* SMPTE ST 2084 */; + info->matrixCoefficients = 9 /* BT.2020 NCL */; + break; + } + } + info->videoFullRange = config->colorRange == COLOR_RANGE_FULL; +} + diff --git a/third_party/ss4s b/third_party/ss4s index d519091e..92b0e99e 160000 --- a/third_party/ss4s +++ b/third_party/ss4s @@ -1 +1 @@ -Subproject commit d519091e166279f54e04af197de9991a9258ac0a +Subproject commit 92b0e99e764e83c47ac8e1af088abc4a0e9099b1