Merge remote-tracking branch 'origin/master' into vdisplay

This commit is contained in:
Yukino Song
2024-08-20 19:27:45 +08:00
12 changed files with 98 additions and 58 deletions

View File

@@ -1455,9 +1455,7 @@ namespace video {
bool hardware = platform_formats->avcodec_base_dev_type != AV_HWDEVICE_TYPE_NONE;
auto &video_format = config.videoFormat == 0 ? encoder.h264 :
config.videoFormat == 1 ? encoder.hevc :
encoder.av1;
auto &video_format = encoder.codec_from_config(config);
if (!video_format[encoder_t::PASSED] || !disp->is_codec_supported(video_format.name, config)) {
BOOST_LOG(error) << encoder.name << ": "sv << video_format.name << " mode not supported"sv;
return nullptr;
@@ -1971,10 +1969,7 @@ namespace video {
}
{
auto encoder_name = config.videoFormat == 0 ? encoder.h264.name :
config.videoFormat == 1 ? encoder.hevc.name :
config.videoFormat == 2 ? encoder.av1.name :
"unknown";
auto encoder_name = encoder.codec_from_config(config).name;
BOOST_LOG(info) << "Creating encoder " << logging::bracket(encoder_name);
@@ -2537,7 +2532,8 @@ namespace video {
// H.264 is special because encoders may support YUV 4:4:4 without supporting 10-bit color depth
if (encoder.flags & YUV444_SUPPORT) {
config_t config_h264_yuv444 { 1920, 1080, 60, 1000, 1, 0, 1, 0, 0, 1 };
encoder.h264[encoder_t::YUV444] = validate_config(disp, encoder, config_h264_yuv444);
encoder.h264[encoder_t::YUV444] = disp->is_codec_supported(encoder.h264.name, config_h264_yuv444) &&
validate_config(disp, encoder, config_h264_yuv444) >= 0;
}
else {
encoder.h264[encoder_t::YUV444] = false;
@@ -2557,17 +2553,30 @@ namespace video {
if (!flag_map[encoder_t::PASSED]) return;
auto encoder_codec_name = encoder.codec_from_config(config).name;
// Test 4:4:4 HDR first. If 4:4:4 is supported, 4:2:0 should also be supported.
config.chromaSamplingType = 1;
if ((encoder.flags & YUV444_SUPPORT) && validate_config(disp, encoder, config) >= 0) {
if ((encoder.flags & YUV444_SUPPORT) &&
disp->is_codec_supported(encoder_codec_name, config) &&
validate_config(disp, encoder, config) >= 0) {
flag_map[encoder_t::DYNAMIC_RANGE] = true;
flag_map[encoder_t::YUV444] = true;
return;
}
else {
flag_map[encoder_t::YUV444] = false;
}
// Test 4:2:0 HDR
config.chromaSamplingType = 0;
flag_map[encoder_t::DYNAMIC_RANGE] = validate_config(disp, encoder, config) >= 0;
if (disp->is_codec_supported(encoder_codec_name, config) &&
validate_config(disp, encoder, config) >= 0) {
flag_map[encoder_t::DYNAMIC_RANGE] = true;
}
else {
flag_map[encoder_t::DYNAMIC_RANGE] = false;
}
};
// HDR is not supported with H.264. Don't bother even trying it.