mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-10 22:05:06 +00:00
encoders/handlers/nvenc: Make code C++ standard compliant again
This commit is contained in:
parent
c445865111
commit
ab9d9e8443
3 changed files with 10 additions and 10 deletions
|
@ -45,14 +45,14 @@ extern "C" {
|
||||||
using namespace streamfx::encoder::ffmpeg::handler;
|
using namespace streamfx::encoder::ffmpeg::handler;
|
||||||
using namespace streamfx::encoder::codec::h264;
|
using namespace streamfx::encoder::codec::h264;
|
||||||
|
|
||||||
std::map<profile, std::string> profiles{
|
static std::map<profile, std::string> profiles{
|
||||||
{profile::BASELINE, "baseline"},
|
{profile::BASELINE, "baseline"},
|
||||||
{profile::MAIN, "main"},
|
{profile::MAIN, "main"},
|
||||||
{profile::HIGH, "high"},
|
{profile::HIGH, "high"},
|
||||||
{profile::HIGH444_PREDICTIVE, "high444p"},
|
{profile::HIGH444_PREDICTIVE, "high444p"},
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<level, std::string> levels{
|
static std::map<level, std::string> levels{
|
||||||
{level::L1_0, "1.0"}, {level::L1_0b, "1.0b"}, {level::L1_1, "1.1"}, {level::L1_2, "1.2"},
|
{level::L1_0, "1.0"}, {level::L1_0b, "1.0b"}, {level::L1_1, "1.1"}, {level::L1_2, "1.2"},
|
||||||
{level::L1_3, "1.3"}, {level::L2_0, "2.0"}, {level::L2_1, "2.1"}, {level::L2_2, "2.2"},
|
{level::L1_3, "1.3"}, {level::L2_0, "2.0"}, {level::L2_1, "2.1"}, {level::L2_2, "2.2"},
|
||||||
{level::L3_0, "3.0"}, {level::L3_1, "3.1"}, {level::L3_2, "3.2"}, {level::L4_0, "4.0"},
|
{level::L3_0, "3.0"}, {level::L3_1, "3.1"}, {level::L3_2, "3.2"}, {level::L4_0, "4.0"},
|
||||||
|
|
|
@ -42,18 +42,18 @@ extern "C" {
|
||||||
using namespace streamfx::encoder::ffmpeg::handler;
|
using namespace streamfx::encoder::ffmpeg::handler;
|
||||||
using namespace streamfx::encoder::codec::hevc;
|
using namespace streamfx::encoder::codec::hevc;
|
||||||
|
|
||||||
std::map<profile, std::string> profiles{
|
static std::map<profile, std::string> profiles{
|
||||||
{profile::MAIN, "main"},
|
{profile::MAIN, "main"},
|
||||||
{profile::MAIN10, "main10"},
|
{profile::MAIN10, "main10"},
|
||||||
{profile::RANGE_EXTENDED, "rext"},
|
{profile::RANGE_EXTENDED, "rext"},
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<tier, std::string> tiers{
|
static std::map<tier, std::string> tiers{
|
||||||
{tier::MAIN, "main"},
|
{tier::MAIN, "main"},
|
||||||
{tier::HIGH, "high"},
|
{tier::HIGH, "high"},
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<level, std::string> levels{
|
static std::map<level, std::string> levels{
|
||||||
{level::L1_0, "1.0"}, {level::L2_0, "2.0"}, {level::L2_1, "2.1"}, {level::L3_0, "3.0"}, {level::L3_1, "3.1"},
|
{level::L1_0, "1.0"}, {level::L2_0, "2.0"}, {level::L2_1, "2.1"}, {level::L3_0, "3.0"}, {level::L3_1, "3.1"},
|
||||||
{level::L4_0, "4.0"}, {level::L4_1, "4.1"}, {level::L5_0, "5.0"}, {level::L5_1, "5.1"}, {level::L5_2, "5.2"},
|
{level::L4_0, "4.0"}, {level::L4_1, "4.1"}, {level::L5_0, "5.0"}, {level::L5_1, "5.1"}, {level::L5_2, "5.2"},
|
||||||
{level::L6_0, "6.0"}, {level::L6_1, "6.1"}, {level::L6_2, "6.2"},
|
{level::L6_0, "6.0"}, {level::L6_1, "6.1"}, {level::L6_2, "6.2"},
|
||||||
|
|
|
@ -169,11 +169,11 @@ void nvenc::override_update(ffmpeg_instance* instance, obs_data_t*)
|
||||||
|
|
||||||
// Calculate and set the number of surfaces to allocate (if not user overridden).
|
// Calculate and set the number of surfaces to allocate (if not user overridden).
|
||||||
if (surfaces == 0) {
|
if (surfaces == 0) {
|
||||||
surfaces = std::max(4ll, (context->max_b_frames + 1ll) * 4ll);
|
surfaces = std::max<int64_t>(4ll, (context->max_b_frames + 1ll) * 4ll);
|
||||||
if (rclookahead > 0) {
|
if (rclookahead > 0) {
|
||||||
surfaces = std::max(1ll, std::max(surfaces, rclookahead + (context->max_b_frames + 5ll)));
|
surfaces = std::max<int64_t>(1ll, std::max<int64_t>(surfaces, rclookahead + (context->max_b_frames + 5ll)));
|
||||||
} else if (context->max_b_frames > 0) {
|
} else if (context->max_b_frames > 0) {
|
||||||
surfaces = std::max(4ll, (context->max_b_frames + 1ll) * 4ll);
|
surfaces = std::max<int64_t>(4ll, (context->max_b_frames + 1ll) * 4ll);
|
||||||
} else {
|
} else {
|
||||||
surfaces = 4;
|
surfaces = 4;
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ void nvenc::override_update(ffmpeg_instance* instance, obs_data_t*)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set delay
|
// Set delay
|
||||||
context->delay = static_cast<int>(std::min(std::max(async_depth, 3ll), surfaces - 1));
|
context->delay = std::min<int>(std::max<int64_t>(async_depth, 3ll), surfaces - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nvenc::get_defaults(obs_data_t* settings, const AVCodec*, AVCodecContext*)
|
void nvenc::get_defaults(obs_data_t* settings, const AVCodec*, AVCodecContext*)
|
||||||
|
@ -440,7 +440,7 @@ void nvenc::get_properties_post(obs_properties_t* props, const AVCodec* codec)
|
||||||
obs_properties_add_list(grp, KEY_OTHER_BFRAMEREFERENCEMODE, D_TRANSLATE(ST_OTHER_BFRAMEREFERENCEMODE),
|
obs_properties_add_list(grp, KEY_OTHER_BFRAMEREFERENCEMODE, D_TRANSLATE(ST_OTHER_BFRAMEREFERENCEMODE),
|
||||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||||
for (auto kv : b_ref_modes) {
|
for (auto kv : b_ref_modes) {
|
||||||
if (kv.first == nvenc::b_ref_mode::EACH && (static std::string_view("h264_nvenc") == codec->name)) {
|
if (kv.first == nvenc::b_ref_mode::EACH && (std::string_view("h264_nvenc") == codec->name)) {
|
||||||
// H.264 does not support using all B-Frames as reference.
|
// H.264 does not support using all B-Frames as reference.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue