Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions src/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1929,21 +1929,28 @@ namespace video {
return nullptr;
}

// may be downgraded below if the device can't deliver HDR (e.g. NvFBC's CUDA path is NV12/YUV444P only)
bool dynamicRange = config.dynamicRange;

if (config.chromaSamplingType == 1) {
if (!video_format[encoder_t::YUV444]) {
BOOST_LOG(error) << video_format.name << ": YUV 4:4:4 not supported"sv;
return nullptr;
}

if (config.dynamicRange && !video_format[encoder_t::DYNAMIC_RANGE_YUV444]) {
BOOST_LOG(error) << video_format.name << ": YUV 4:4:4 dynamic range not supported"sv;
return nullptr;
if (dynamicRange && !video_format[encoder_t::DYNAMIC_RANGE_YUV444]) {
BOOST_LOG(warning) << video_format.name << ": YUV 4:4:4 dynamic range not supported, falling back to SDR"sv;
dynamicRange = false;
encode_device->colorspace.colorspace = colorspace_e::rec709;
encode_device->colorspace.bit_depth = 8;
}

} else {
if (config.dynamicRange && !video_format[encoder_t::DYNAMIC_RANGE]) {
BOOST_LOG(error) << video_format.name << ": dynamic range not supported"sv;
return nullptr;
if (dynamicRange && !video_format[encoder_t::DYNAMIC_RANGE]) {
BOOST_LOG(warning) << video_format.name << ": dynamic range not supported, falling back to SDR"sv;
dynamicRange = false;
encode_device->colorspace.colorspace = colorspace_e::rec709;
encode_device->colorspace.bit_depth = 8;
}
}

Expand Down Expand Up @@ -1987,7 +1994,7 @@ namespace video {
// HEVC uses the same RExt profile for both 8 and 10 bit YUV 4:4:4 encoding
ctx->profile = AV_PROFILE_HEVC_REXT;
} else {
ctx->profile = config.dynamicRange ? AV_PROFILE_HEVC_MAIN_10 : AV_PROFILE_HEVC_MAIN;
ctx->profile = dynamicRange ? AV_PROFILE_HEVC_MAIN_10 : AV_PROFILE_HEVC_MAIN;
}
break;

Expand Down Expand Up @@ -2147,11 +2154,11 @@ namespace video {
for (auto &option : video_format.common_options) {
handle_option(option);
}
for (auto &option : (config.dynamicRange ? video_format.hdr_options : video_format.sdr_options)) {
for (auto &option : (dynamicRange ? video_format.hdr_options : video_format.sdr_options)) {
handle_option(option);
}
if (config.chromaSamplingType == 1) {
for (auto &option : (config.dynamicRange ? video_format.hdr444_options : video_format.sdr444_options)) {
for (auto &option : (dynamicRange ? video_format.hdr444_options : video_format.sdr444_options)) {
handle_option(option);
}
}
Expand Down