@@ -2735,36 +2735,19 @@ namespace video {
27352735
27362736 // Test HDR and YUV444 support
27372737 {
2738- // H.264 is special because encoders may support YUV 4:4:4 without supporting 10-bit color depth
2739- if (encoder.flags & YUV444_SUPPORT) {
2740- config_t config_h264_yuv444 {1920 , 1080 , 60 , 6000 , 1000 , 1 , 0 , 1 , 0 , 0 , 1 };
2741- encoder.h264 [encoder_t ::YUV444] = disp->is_codec_supported (encoder.h264 .name , config_h264_yuv444) &&
2742- validate_config (disp, encoder, config_h264_yuv444) >= 0 ;
2743- } else {
2744- encoder.h264 [encoder_t ::YUV444] = false ;
2745- }
2746-
27472738 auto test_yuv444 = [&](auto &flag_map, auto video_format) {
2748- const config_t sdr_yuv444_config = {1920 , 1080 , 60 , 6000 , 1000 , 1 , 0 , 1 , 1 , 0 , 1 };
2749-
2750- auto config = sdr_yuv444_config;
2739+ const config_t config = {1920 , 1080 , 60 , 6000 , 1000 , 1 , 0 , 1 , video_format, 0 , 1 };
27512740
2752- // Reset the display
27532741 reset_display (disp, encoder.platform_formats ->dev_type , output_name, config);
27542742 if (!disp) {
27552743 return ;
27562744 }
2757-
2758- config.videoFormat = video_format;
2759-
27602745 if (!flag_map[encoder_t ::PASSED]) {
27612746 return ;
27622747 }
27632748
27642749 auto encoder_codec_name = encoder.codec_from_config (config).name ;
27652750
2766- // Test 4:4:4 SDR first
2767- config.chromaSamplingType = 1 ;
27682751 if ((encoder.flags & YUV444_SUPPORT) &&
27692752 disp->is_codec_supported (encoder_codec_name, config) &&
27702753 validate_config (disp, encoder, config) >= 0 ) {
@@ -2774,53 +2757,59 @@ namespace video {
27742757 }
27752758 };
27762759
2777- auto test_hdr = [&](auto &flag_map, auto video_format) {
2778-
2779- const config_t generic_hdr_config = {1920 , 1080 , 60 , 6000 , 1000 , 1 , 0 , 3 , 1 , 1 , 0 };
2780-
2781- auto config = generic_hdr_config;
2760+ auto test_yuv420_hdr = [&](auto &flag_map, auto video_format) {
2761+ const config_t config = {1920 , 1080 , 60 , 6000 , 1000 , 1 , 0 , 3 , video_format, 1 , 0 };
27822762
2783- // Reset the display
27842763 reset_display (disp, encoder.platform_formats ->dev_type , output_name, config);
27852764 if (!disp) {
27862765 return ;
27872766 }
2767+ if (!flag_map[encoder_t ::PASSED]) {
2768+ return ;
2769+ }
2770+
2771+ auto encoder_codec_name = encoder.codec_from_config (config).name ;
2772+
2773+ if (disp->is_codec_supported (encoder_codec_name, config) && validate_config (disp, encoder, config) >= 0 ) {
2774+ flag_map[encoder_t ::DYNAMIC_RANGE] = true ;
2775+ } else {
2776+ flag_map[encoder_t ::DYNAMIC_RANGE] = false ;
2777+ }
2778+ };
27882779
2789- config.videoFormat = video_format;
2780+ auto test_yuv444_hdr = [&](auto &flag_map, auto video_format) {
2781+ const config_t config = {1920 , 1080 , 60 , 6000 , 1000 , 1 , 0 , 3 , video_format, 1 , 1 };
27902782
2783+ reset_display (disp, encoder.platform_formats ->dev_type , output_name, config);
2784+ if (!disp) {
2785+ return ;
2786+ }
27912787 if (!flag_map[encoder_t ::PASSED]) {
27922788 return ;
27932789 }
27942790
27952791 auto encoder_codec_name = encoder.codec_from_config (config).name ;
27962792
2797- // Test 4:4:4 HDR first.
2798- config.chromaSamplingType = 1 ;
27992793 if ((encoder.flags & YUV444_SUPPORT) &&
28002794 disp->is_codec_supported (encoder_codec_name, config) &&
28012795 validate_config (disp, encoder, config) >= 0 ) {
28022796 flag_map[encoder_t ::DYNAMIC_RANGE_YUV444] = true ;
28032797 } else {
28042798 flag_map[encoder_t ::DYNAMIC_RANGE_YUV444] = false ;
28052799 }
2806-
2807- // Test 4:2:0 HDR
2808- config.chromaSamplingType = 0 ;
2809- if (disp->is_codec_supported (encoder_codec_name, config) && validate_config (disp, encoder, config) >= 0 ) {
2810- flag_map[encoder_t ::DYNAMIC_RANGE] = true ;
2811- } else {
2812- flag_map[encoder_t ::DYNAMIC_RANGE] = false ;
2813- }
28142800 };
28152801
2802+ test_yuv444 (encoder.h264 , 0 );
28162803 // HDR is not supported with H.264. Don't bother even trying it.
28172804 encoder.h264 [encoder_t ::DYNAMIC_RANGE] = false ;
28182805 encoder.h264 [encoder_t ::DYNAMIC_RANGE_YUV444] = false ;
28192806
28202807 test_yuv444 (encoder.hevc , 1 );
2821- test_hdr (encoder.hevc , 1 );
2808+ test_yuv420_hdr (encoder.hevc , 1 );
2809+ test_yuv444_hdr (encoder.hevc , 1 );
28222810 test_yuv444 (encoder.av1 , 2 );
2823- test_hdr (encoder.av1 , 2 );
2811+ test_yuv420_hdr (encoder.av1 , 2 );
2812+ test_yuv444_hdr (encoder.av1 , 2 );
28242813 }
28252814
28262815 encoder.h264 [encoder_t ::VUI_PARAMETERS] = encoder.h264 [encoder_t ::VUI_PARAMETERS] && !config::sunshine.flags [config::flag::FORCE_VIDEO_HEADER_REPLACE];
@@ -2857,7 +2846,7 @@ namespace video {
28572846 active_av1_mode = config::video.av1_mode ;
28582847 last_encoder_probe_supported_ref_frames_invalidation = false ;
28592848
2860- auto adjust_encoder_constraints = [&](encoder_t *encoder) {
2849+ auto adjust_encoder_constraints_hevc = [&](encoder_t *encoder) {
28612850 // If we can't satisfy both the encoder and codec requirement, prefer the encoder over codec support
28622851 if (active_hevc_mode == 5 && !encoder->hevc [encoder_t ::DYNAMIC_RANGE] && !encoder->hevc [encoder_t ::DYNAMIC_RANGE_YUV444]) {
28632852 BOOST_LOG (warning) << " Encoder [" sv << encoder->name << " ] does not support HEVC Main10 Rext10_444 on this system" sv;
@@ -2872,7 +2861,10 @@ namespace video {
28722861 BOOST_LOG (warning) << " Encoder [" sv << encoder->name << " ] does not support HEVC on this system" sv;
28732862 active_hevc_mode = 0 ;
28742863 }
2864+ };
28752865
2866+ auto adjust_encoder_constraints_av1 = [&](encoder_t *encoder) {
2867+ // If we can't satisfy both the encoder and codec requirement, prefer the encoder over codec support
28762868 if (active_av1_mode == 5 && !encoder->av1 [encoder_t ::DYNAMIC_RANGE] && !encoder->av1 [encoder_t ::DYNAMIC_RANGE_YUV444]) {
28772869 BOOST_LOG (warning) << " Encoder [" sv << encoder->name << " ] does not support AV1 Main10 Rext10_444 on this system" sv;
28782870 active_av1_mode = 0 ;
@@ -2901,7 +2893,8 @@ namespace video {
29012893 }
29022894
29032895 // We will return an encoder here even if it fails one of the codec requirements specified by the user
2904- adjust_encoder_constraints (encoder);
2896+ adjust_encoder_constraints_hevc (encoder);
2897+ adjust_encoder_constraints_av1 (encoder);
29052898
29062899 chosen_encoder = encoder;
29072900 break ;
@@ -2980,7 +2973,8 @@ namespace video {
29802973 }
29812974
29822975 // We will return an encoder here even if it fails one of the codec requirements specified by the user
2983- adjust_encoder_constraints (encoder);
2976+ adjust_encoder_constraints_hevc (encoder);
2977+ adjust_encoder_constraints_av1 (encoder);
29842978
29852979 chosen_encoder = encoder;
29862980 break ;
0 commit comments