Skip to content

Commit

Permalink
fix(win/qsv): skip unsupported 4:4:4 codecs
Browse files Browse the repository at this point in the history
Skip particular QSV 4:4:4 codecs bypassing ffmpeg
  • Loading branch information
ns6089 committed Aug 17, 2024
1 parent c8d0d2b commit 6b907ac
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/platform/windows/display_vram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1871,6 +1871,13 @@ namespace platf::dxgi {
if (!boost::algorithm::ends_with(name, "_qsv")) {
return false;
}
if (config.chromaSamplingType == 1) {
if (config.videoFormat == 0 || config.videoFormat == 2) {
// QSV doesn't support 4:4:4 in H.264 or AV1
return false;
}
// TODO: Blacklist HEVC 4:4:4 based on adapter model
}
}
else if (adapter_desc.VendorId == 0x10de) { // Nvidia
// If it's not an NVENC encoder, it's not compatible with an Nvidia GPU
Expand Down
20 changes: 18 additions & 2 deletions src/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2536,17 +2536,33 @@ namespace video {

if (!flag_map[encoder_t::PASSED]) return;

auto encoder_codec_name = (video_format == 0) ? encoder.h264.name :
(video_format == 1) ? encoder.hevc.name :
(video_format == 2) ? encoder.av1.name :
"unknown"s;

// 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.
Expand Down

0 comments on commit 6b907ac

Please sign in to comment.