Skip to content

Commit 52d82ab

Browse files
committed
Support RGB colorspaces and explicit tone mapping
1 parent 0518b7e commit 52d82ab

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

src/Limelight.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@ extern "C" {
2121

2222
// Values for the 'colorSpace' field below.
2323
// Rec. 2020 is not supported with H.264 video streams on GFE hosts.
24-
#define COLORSPACE_REC_601 0
25-
#define COLORSPACE_REC_709 1
26-
#define COLORSPACE_REC_2020 2
24+
// To use any of the RGB colorspaces, the following conditions must be satisfied:
25+
// 1. Server advertised SCM_MASK_RGB SCM flag in addition to individual SCM formats from SCM_MASK_YUV444
26+
// 2. Client included these 4:4:4 formats in 'supportedVideoFormats' field of STREAM_CONFIGURATION
27+
#define COLORSPACE_REC_601 0
28+
#define COLORSPACE_REC_709 1
29+
#define COLORSPACE_REC_2020 2
30+
#define COLORSPACE_RGB_SRGB 3
31+
#define COLORSPACE_RGB_P3_D65 4
2732

2833
// Values for the 'colorRange' field below
2934
#define COLOR_RANGE_LIMITED 0
@@ -276,6 +281,10 @@ typedef struct _DECODE_UNIT {
276281
// supports reference frame invalidation for AV1 streams. This flag is only valid on video renderers.
277282
#define CAPABILITY_REFERENCE_FRAME_INVALIDATION_AV1 0x40
278283

284+
// If set in the video renderer capabilities field, this flag indicates that the renderer
285+
// wants HDR content to be tone-mapped to SDR on the server side.
286+
#define CAPABILITY_PREFERS_TONE_MAPPED_SDR_OVER_HDR 0x80
287+
279288
// If set in the video renderer capabilities field, this macro specifies that the renderer
280289
// supports slicing to increase decoding performance. The parameter specifies the desired
281290
// number of slices per frame. This capability is only valid on video renderers.
@@ -520,6 +529,8 @@ void LiInitializeConnectionCallbacks(PCONNECTION_LISTENER_CALLBACKS clCallbacks)
520529
#define SCM_MASK_AV1 (SCM_AV1_MAIN8 | SCM_AV1_MAIN10 | SCM_AV1_HIGH8_444 | SCM_AV1_HIGH10_444)
521530
#define SCM_MASK_10BIT (SCM_HEVC_MAIN10 | SCM_HEVC_REXT10_444 | SCM_AV1_MAIN10 | SCM_AV1_HIGH10_444)
522531
#define SCM_MASK_YUV444 (SCM_H264_HIGH8_444 | SCM_HEVC_REXT8_444 | SCM_HEVC_REXT10_444 | SCM_AV1_HIGH8_444 | SCM_AV1_HIGH10_444)
532+
#define SCM_MASK_RGB 0x80000000 // Indicates that YUV444 profiles support RGB payload
533+
#define SCM_MASK_RECOMB 0x40000000 // Indicates that YUV420 profiles support recombined YUV444 payload
523534

524535
typedef struct _SERVER_INFORMATION {
525536
// Server host name or IP address in text form

src/SdpGenerator.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,14 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) {
309309
else {
310310
err |= addAttributeString(&optionHead, "x-ss-video[0].chromaSamplingType", "0");
311311
}
312+
313+
// Enable server-side HDR tone mapping if requested by video renderer
314+
if (VideoCallbacks.capabilities & CAPABILITY_PREFERS_TONE_MAPPED_SDR_OVER_HDR) {
315+
err |= addAttributeString(&optionHead, "x-ml-video[0].toneMapHDR", "1");
316+
}
317+
else {
318+
err |= addAttributeString(&optionHead, "x-ml-video[0].toneMapHDR", "0");
319+
}
312320
}
313321

314322
snprintf(payloadStr, sizeof(payloadStr), "%d", StreamConfig.width);

0 commit comments

Comments
 (0)