From c91c40e79f5fa5c1ed3d771cef38c84eefb9b20e Mon Sep 17 00:00:00 2001 From: Acaki Date: Thu, 20 Feb 2025 00:00:22 +0800 Subject: [PATCH] feat: update supportedVideoFormats according to YUV444 setting --- Limelight/Stream/Connection.m | 20 +++++++++++ Limelight/Stream/StreamConfiguration.h | 1 + Limelight/Stream/StreamConfiguration.m | 2 +- .../ViewControllers/MainFrameViewController.m | 35 ++++++++++++++++--- 4 files changed, 52 insertions(+), 6 deletions(-) diff --git a/Limelight/Stream/Connection.m b/Limelight/Stream/Connection.m index 846add93..60d52880 100644 --- a/Limelight/Stream/Connection.m +++ b/Limelight/Stream/Connection.m @@ -86,8 +86,12 @@ void DrStop(void) { case VIDEO_FORMAT_H264: return @"H.264"; + case VIDEO_FORMAT_H264_HIGH8_444: + return @"H.264 YUV444"; case VIDEO_FORMAT_H265: return @"HEVC"; + case VIDEO_FORMAT_H265_REXT8_444: + return @"HEVC YUV444"; case VIDEO_FORMAT_H265_MAIN10: if (LiGetCurrentHostDisplayHdrMode()) { return @"HEVC Main 10 HDR"; @@ -95,8 +99,17 @@ void DrStop(void) else { return @"HEVC Main 10 SDR"; } + case VIDEO_FORMAT_H265_REXT10_444: + if (LiGetCurrentHostDisplayHdrMode()) { + return @"HEVC Main 10 YUV444 HDR"; + } + else { + return @"HEVC Main 10 YUV444 SDR"; + } case VIDEO_FORMAT_AV1_MAIN8: return @"AV1"; + case VIDEO_FORMAT_AV1_HIGH8_444: + return @"AV1 YUV444"; case VIDEO_FORMAT_AV1_MAIN10: if (LiGetCurrentHostDisplayHdrMode()) { return @"AV1 10-bit HDR"; @@ -104,6 +117,13 @@ void DrStop(void) else { return @"AV1 10-bit SDR"; } + case VIDEO_FORMAT_AV1_HIGH10_444: + if (LiGetCurrentHostDisplayHdrMode()) { + return @"AV1 10-bit YUV444 HDR"; + } + else { + return @"AV1 10-bit YUV444 SDR"; + } default: return @"UNKNOWN"; } diff --git a/Limelight/Stream/StreamConfiguration.h b/Limelight/Stream/StreamConfiguration.h index 05d9fc13..559cde62 100644 --- a/Limelight/Stream/StreamConfiguration.h +++ b/Limelight/Stream/StreamConfiguration.h @@ -16,6 +16,7 @@ @property NSString* appName; @property NSString* rtspSessionUrl; @property int serverCodecModeSupport; +@property BOOL enableYUV444; @property int width; @property int height; @property int frameRate; diff --git a/Limelight/Stream/StreamConfiguration.m b/Limelight/Stream/StreamConfiguration.m index 4d308cd8..306f9ced 100644 --- a/Limelight/Stream/StreamConfiguration.m +++ b/Limelight/Stream/StreamConfiguration.m @@ -9,5 +9,5 @@ #import "StreamConfiguration.h" @implementation StreamConfiguration -@synthesize host, httpsPort, appID, width, height, frameRate, bitRate, riKeyId, riKey, gamepadMask, appName, optimizeGameSettings, playAudioOnPC, swapABXYButtons, audioConfiguration, supportedVideoFormats, multiController, serverCert, rtspSessionUrl, serverCodecModeSupport; +@synthesize host, httpsPort, appID, width, height, frameRate, bitRate, riKeyId, riKey, gamepadMask, appName, optimizeGameSettings, playAudioOnPC, swapABXYButtons, audioConfiguration, supportedVideoFormats, multiController, serverCert, rtspSessionUrl, serverCodecModeSupport, enableYUV444; @end diff --git a/Limelight/ViewControllers/MainFrameViewController.m b/Limelight/ViewControllers/MainFrameViewController.m index dd43e32d..a1bd84bc 100644 --- a/Limelight/ViewControllers/MainFrameViewController.m +++ b/Limelight/ViewControllers/MainFrameViewController.m @@ -660,6 +660,7 @@ static NSMutableSet* hostList; } #endif + _streamConfig.enableYUV444 = streamSettings.enableYUV444; _streamConfig.bitRate = [streamSettings.bitrate intValue]; _streamConfig.optimizeGameSettings = streamSettings.optimizeGames; _streamConfig.playAudioOnPC = streamSettings.playAudioOnPC; @@ -693,7 +694,12 @@ static NSMutableSet* hostList; case CODEC_PREF_AV1: #if defined(__IPHONE_16_0) || defined(__TVOS_16_0) if (VTIsHardwareDecodeSupported(kCMVideoCodecType_AV1)) { - _streamConfig.supportedVideoFormats |= VIDEO_FORMAT_AV1_MAIN8; + if (streamSettings.enableYUV444) { + _streamConfig.supportedVideoFormats |= VIDEO_FORMAT_AV1_HIGH8_444; + } + else { + _streamConfig.supportedVideoFormats |= VIDEO_FORMAT_AV1_MAIN8; + } } #endif // Fall-through @@ -701,12 +707,21 @@ static NSMutableSet* hostList; case CODEC_PREF_AUTO: case CODEC_PREF_HEVC: if (VTIsHardwareDecodeSupported(kCMVideoCodecType_HEVC)) { - _streamConfig.supportedVideoFormats |= VIDEO_FORMAT_H265; + if (streamSettings.enableYUV444) { + _streamConfig.supportedVideoFormats |= VIDEO_FORMAT_H265_REXT8_444; + } + else { + _streamConfig.supportedVideoFormats |= VIDEO_FORMAT_H265; + } } // Fall-through case CODEC_PREF_H264: - _streamConfig.supportedVideoFormats |= VIDEO_FORMAT_H264; + if (streamSettings.enableYUV444) { + _streamConfig.supportedVideoFormats |= VIDEO_FORMAT_H264_HIGH8_444; + } else { + _streamConfig.supportedVideoFormats |= VIDEO_FORMAT_H264; + } break; } @@ -716,7 +731,12 @@ static NSMutableSet* hostList; // HEVC Main10 is supported if the user wants it and the display supports it if (streamSettings.enableHdr && (AVPlayer.availableHDRModes & AVPlayerHDRModeHDR10) != 0) { - _streamConfig.supportedVideoFormats |= VIDEO_FORMAT_H265_MAIN10; + if (streamSettings.enableYUV444) { + _streamConfig.supportedVideoFormats |= VIDEO_FORMAT_H265_REXT10_444; + } + else { + _streamConfig.supportedVideoFormats |= VIDEO_FORMAT_H265_MAIN10; + } } } @@ -724,7 +744,11 @@ static NSMutableSet* hostList; // Add the AV1 Main10 format if AV1 and HDR are both enabled and supported if ((_streamConfig.supportedVideoFormats & VIDEO_FORMAT_MASK_AV1) && streamSettings.enableHdr && VTIsHardwareDecodeSupported(kCMVideoCodecType_AV1) && (AVPlayer.availableHDRModes & AVPlayerHDRModeHDR10) != 0) { - _streamConfig.supportedVideoFormats |= VIDEO_FORMAT_AV1_MAIN10; + if (streamSettings.enableYUV444) { + _streamConfig.supportedVideoFormats |= VIDEO_FORMAT_AV1_HIGH10_444; + } else { + _streamConfig.supportedVideoFormats |= VIDEO_FORMAT_AV1_MAIN10; + } } #endif } @@ -947,6 +971,7 @@ static NSMutableSet* hostList; [settingsViewController.optimizeSettingsSelector setEnabled:!self.settingsExpandedInStreamView]; [settingsViewController.audioOnPCSelector setEnabled:!self.settingsExpandedInStreamView]; [settingsViewController.codecSelector setEnabled:!self.settingsExpandedInStreamView]; + [settingsViewController.yuv444Selector setEnabled:!self.settingsExpandedInStreamView]; [settingsViewController.hdrSelector setEnabled:!self.settingsExpandedInStreamView]; [settingsViewController.framePacingSelector setEnabled:!self.settingsExpandedInStreamView]; [settingsViewController.btMouseSelector setEnabled:!self.settingsExpandedInStreamView];