code: Disable useless alignment styling and update standard

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2023-05-13 14:35:46 +02:00 committed by Xaymar
parent c000061758
commit fa8d66b951
136 changed files with 969 additions and 2060 deletions

View File

@ -5,11 +5,12 @@
# Basic Formatting
TabWidth: 4
UseTab: ForContinuationAndIndentation
ColumnLimit: 120
ColumnLimit: 65535
#- 0 does not respect the original line breaks!
# Language
Language: Cpp
Standard: Cpp11
Standard: c++17
# Indentation
AccessModifierOffset: 0
@ -48,7 +49,7 @@ AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AlignTrailingComments: false
DerivePointerAlignment: false
PointerAlignment: Left

View File

@ -43,8 +43,7 @@ streamfx::configuration::configuration() : _config_path(), _data(), _task_lock()
if (!std::filesystem::exists(_config_path) || !std::filesystem::is_regular_file(_config_path)) {
throw std::runtime_error("Configuration does not exist.");
} else {
obs_data_t* data =
obs_data_create_from_json_file_safe(_config_path.u8string().c_str(), path_backup_ext.data());
obs_data_t* data = obs_data_create_from_json_file_safe(_config_path.u8string().c_str(), path_backup_ext.data());
if (!data) {
throw std::runtime_error("Failed to load configuration from disk.");
} else {
@ -70,8 +69,7 @@ void streamfx::configuration::save()
if (_config_path.has_parent_path()) {
std::filesystem::create_directories(_config_path.parent_path());
}
if (!obs_data_save_json_safe(_data.get(), _config_path.u8string().c_str(), ".tmp",
path_backup_ext.data())) {
if (!obs_data_save_json_safe(_data.get(), _config_path.u8string().c_str(), ".tmp", path_backup_ext.data())) {
D_LOG_ERROR("Failed to save configuration file.", nullptr);
}
});

View File

@ -181,8 +181,7 @@ void progress_parse(uint8_t*& ptr, uint8_t* end, size_t& sz)
sz = get_nal_size(ptr, end);
}
void hevc::extract_header_sei(uint8_t* data, std::size_t sz_data, std::vector<uint8_t>& header,
std::vector<uint8_t>& sei)
void hevc::extract_header_sei(uint8_t* data, std::size_t sz_data, std::vector<uint8_t>& header, std::vector<uint8_t>& sei)
{
uint8_t* ptr = data;
uint8_t* end = data + sz_data;

View File

@ -42,6 +42,5 @@ namespace streamfx::encoder::codec::hevc {
UNKNOWN = -1,
};
void extract_header_sei(uint8_t* data, std::size_t sz_data, std::vector<uint8_t>& header,
std::vector<uint8_t>& sei);
void extract_header_sei(uint8_t* data, std::size_t sz_data, std::vector<uint8_t>& header, std::vector<uint8_t>& sei);
} // namespace streamfx::encoder::codec::hevc

View File

@ -97,10 +97,8 @@ ffmpeg_instance::ffmpeg_instance(obs_data_t* settings, obs_encoder_t* self, bool
// Initialize GPU Stuff
if (is_hw) {
// Abort if user specified manual override.
if ((obs_data_get_int(settings, ST_KEY_FFMPEG_GPU) != -1) || (obs_encoder_scaling_enabled(_self))
|| (video_output_get_info(obs_encoder_video(_self))->format != VIDEO_FORMAT_NV12)) {
throw std::runtime_error(
"Selected settings prevent the use of hardware encoding, falling back to software.");
if ((obs_data_get_int(settings, ST_KEY_FFMPEG_GPU) != -1) || (obs_encoder_scaling_enabled(_self)) || (video_output_get_info(obs_encoder_video(_self))->format != VIDEO_FORMAT_NV12)) {
throw std::runtime_error("Selected settings prevent the use of hardware encoding, falling back to software.");
}
#ifdef WIN32
@ -201,8 +199,7 @@ bool ffmpeg_instance::update(obs_data_t* settings)
bool support_reconfig_gpu = false;
bool support_reconfig_keyframes = false;
if (_handler) {
support_reconfig = _handler->supports_reconfigure(_factory, support_reconfig_threads, support_reconfig_gpu,
support_reconfig_keyframes);
support_reconfig = _handler->supports_reconfigure(_factory, support_reconfig_threads, support_reconfig_gpu, support_reconfig_keyframes);
}
if (!_context->internal) {
@ -259,10 +256,8 @@ bool ffmpeg_instance::update(obs_data_t* settings)
bool is_seconds = (kf_type == 0);
if (is_seconds) {
double framerate =
static_cast<double>(ovi.fps_num) / (static_cast<double>(ovi.fps_den) * _framerate_divisor);
_context->gop_size =
static_cast<int>(obs_data_get_double(settings, ST_KEY_KEYFRAMES_INTERVAL_SECONDS) * framerate);
double framerate = static_cast<double>(ovi.fps_num) / (static_cast<double>(ovi.fps_den) * _framerate_divisor);
_context->gop_size = static_cast<int>(obs_data_get_double(settings, ST_KEY_KEYFRAMES_INTERVAL_SECONDS) * framerate);
} else {
_context->gop_size = static_cast<int>(obs_data_get_int(settings, ST_KEY_KEYFRAMES_INTERVAL_FRAMES));
}
@ -291,36 +286,20 @@ bool ffmpeg_instance::update(obs_data_t* settings)
if (!_context->internal || support_reconfig) {
DLOG_INFO("[%s] Configuration:", _codec->name);
DLOG_INFO("[%s] FFmpeg:", _codec->name);
DLOG_INFO("[%s] Custom Settings: %s", _codec->name,
obs_data_get_string(settings, ST_KEY_FFMPEG_CUSTOMSETTINGS));
DLOG_INFO("[%s] Standard Compliance: %s", _codec->name,
::streamfx::ffmpeg::tools::get_std_compliance_name(_context->strict_std_compliance));
DLOG_INFO("[%s] Threading: %s (with %i threads)", _codec->name,
::streamfx::ffmpeg::tools::get_thread_type_name(_context->thread_type), _context->thread_count);
DLOG_INFO("[%s] Custom Settings: %s", _codec->name, obs_data_get_string(settings, ST_KEY_FFMPEG_CUSTOMSETTINGS));
DLOG_INFO("[%s] Standard Compliance: %s", _codec->name, ::streamfx::ffmpeg::tools::get_std_compliance_name(_context->strict_std_compliance));
DLOG_INFO("[%s] Threading: %s (with %i threads)", _codec->name, ::streamfx::ffmpeg::tools::get_thread_type_name(_context->thread_type), _context->thread_count);
DLOG_INFO("[%s] Video:", _codec->name);
if (_hwinst) {
DLOG_INFO("[%s] Texture: %" PRId32 "x%" PRId32 " %s %s %s", _codec->name, _context->width,
_context->height, ::streamfx::ffmpeg::tools::get_pixel_format_name(_context->sw_pix_fmt),
::streamfx::ffmpeg::tools::get_color_space_name(_context->colorspace),
av_color_range_name(_context->color_range));
DLOG_INFO("[%s] Texture: %" PRId32 "x%" PRId32 " %s %s %s", _codec->name, _context->width, _context->height, ::streamfx::ffmpeg::tools::get_pixel_format_name(_context->sw_pix_fmt), ::streamfx::ffmpeg::tools::get_color_space_name(_context->colorspace), av_color_range_name(_context->color_range));
} else {
DLOG_INFO("[%s] Input: %" PRId32 "x%" PRId32 " %s %s %s", _codec->name, _scaler.get_source_width(),
_scaler.get_source_height(),
::streamfx::ffmpeg::tools::get_pixel_format_name(_scaler.get_source_format()),
::streamfx::ffmpeg::tools::get_color_space_name(_scaler.get_source_colorspace()),
_scaler.is_source_full_range() ? "Full" : "Partial");
DLOG_INFO("[%s] Output: %" PRId32 "x%" PRId32 " %s %s %s", _codec->name, _scaler.get_target_width(),
_scaler.get_target_height(),
::streamfx::ffmpeg::tools::get_pixel_format_name(_scaler.get_target_format()),
::streamfx::ffmpeg::tools::get_color_space_name(_scaler.get_target_colorspace()),
_scaler.is_target_full_range() ? "Full" : "Partial");
DLOG_INFO("[%s] Input: %" PRId32 "x%" PRId32 " %s %s %s", _codec->name, _scaler.get_source_width(), _scaler.get_source_height(), ::streamfx::ffmpeg::tools::get_pixel_format_name(_scaler.get_source_format()), ::streamfx::ffmpeg::tools::get_color_space_name(_scaler.get_source_colorspace()), _scaler.is_source_full_range() ? "Full" : "Partial");
DLOG_INFO("[%s] Output: %" PRId32 "x%" PRId32 " %s %s %s", _codec->name, _scaler.get_target_width(), _scaler.get_target_height(), ::streamfx::ffmpeg::tools::get_pixel_format_name(_scaler.get_target_format()), ::streamfx::ffmpeg::tools::get_color_space_name(_scaler.get_target_colorspace()), _scaler.is_target_full_range() ? "Full" : "Partial");
if (!_hwinst)
DLOG_INFO("[%s] On GPU Index: %lli", _codec->name, obs_data_get_int(settings, ST_KEY_FFMPEG_GPU));
}
DLOG_INFO("[%s] Framerate: %" PRId32 "/%" PRId32 " (%f FPS)", _codec->name, _context->time_base.den,
_context->time_base.num,
static_cast<double_t>(_context->time_base.den) / static_cast<double_t>(_context->time_base.num));
DLOG_INFO("[%s] Framerate: %" PRId32 "/%" PRId32 " (%f FPS)", _codec->name, _context->time_base.den, _context->time_base.num, static_cast<double_t>(_context->time_base.den) / static_cast<double_t>(_context->time_base.num));
DLOG_INFO("[%s] Keyframes: ", _codec->name);
if (_context->keyint_min != _context->gop_size) {
@ -391,16 +370,12 @@ bool ffmpeg_instance::encode_video(struct encoder_frame* frame, struct encoder_p
vframe->color_trc = _context->color_trc;
vframe->pts = frame->pts;
if ((_scaler.is_source_full_range() == _scaler.is_target_full_range())
&& (_scaler.get_source_colorspace() == _scaler.get_target_colorspace())
&& (_scaler.get_source_format() == _scaler.get_target_format())) {
if ((_scaler.is_source_full_range() == _scaler.is_target_full_range()) && (_scaler.get_source_colorspace() == _scaler.get_target_colorspace()) && (_scaler.get_source_format() == _scaler.get_target_format())) {
copy_data(frame, vframe.get());
} else {
int res = _scaler.convert(reinterpret_cast<uint8_t**>(frame->data), reinterpret_cast<int*>(frame->linesize),
0, _context->height, vframe->data, vframe->linesize);
int res = _scaler.convert(reinterpret_cast<uint8_t**>(frame->data), reinterpret_cast<int*>(frame->linesize), 0, _context->height, vframe->data, vframe->linesize);
if (res <= 0) {
DLOG_ERROR("Failed to convert frame: %s (%" PRId32 ").",
::streamfx::ffmpeg::tools::get_error_description(res), res);
DLOG_ERROR("Failed to convert frame: %s (%" PRId32 ").", ::streamfx::ffmpeg::tools::get_error_description(res), res);
return false;
}
}
@ -412,8 +387,7 @@ bool ffmpeg_instance::encode_video(struct encoder_frame* frame, struct encoder_p
return true;
}
bool ffmpeg_instance::encode_video(uint32_t handle, int64_t pts, uint64_t lock_key, uint64_t* next_key,
struct encoder_packet* packet, bool* received_packet)
bool ffmpeg_instance::encode_video(uint32_t handle, int64_t pts, uint64_t lock_key, uint64_t* next_key, struct encoder_packet* packet, bool* received_packet)
{
if ((_framerate_divisor > 1) && (pts % _framerate_divisor != 0)) {
*next_key = lock_key;
@ -486,12 +460,7 @@ void ffmpeg_instance::initialize_sw(obs_data_t* settings)
// Create Scaler
if (!_scaler.initialize(SWS_SINC | SWS_FULL_CHR_H_INT | SWS_FULL_CHR_H_INP | SWS_ACCURATE_RND | SWS_BITEXACT)) {
std::stringstream sstr;
sstr << "Initializing scaler failed for conversion from '"
<< ::streamfx::ffmpeg::tools::get_pixel_format_name(_scaler.get_source_format()) << "' to '"
<< ::streamfx::ffmpeg::tools::get_pixel_format_name(_scaler.get_target_format())
<< "' with color space '"
<< ::streamfx::ffmpeg::tools::get_color_space_name(_scaler.get_source_colorspace()) << "' and "
<< (_scaler.is_source_full_range() ? "full" : "partial") << " range.";
sstr << "Initializing scaler failed for conversion from '" << ::streamfx::ffmpeg::tools::get_pixel_format_name(_scaler.get_source_format()) << "' to '" << ::streamfx::ffmpeg::tools::get_pixel_format_name(_scaler.get_target_format()) << "' with color space '" << ::streamfx::ffmpeg::tools::get_color_space_name(_scaler.get_source_colorspace()) << "' and " << (_scaler.is_source_full_range() ? "full" : "partial") << " range.";
throw std::runtime_error(sstr.str());
}
}
@ -526,8 +495,7 @@ void ffmpeg_instance::initialize_hw(obs_data_t*)
if (int32_t res = av_hwframe_ctx_init(_context->hw_frames_ctx); res < 0) {
std::array<char, 4096> buffer;
int len = snprintf(buffer.data(), buffer.size(), "Failed initialize hardware context: %s (%" PRIu32 ")",
::streamfx::ffmpeg::tools::get_error_description(res), res);
int len = snprintf(buffer.data(), buffer.size(), "Failed initialize hardware context: %s (%" PRIu32 ")", ::streamfx::ffmpeg::tools::get_error_description(res), res);
throw std::runtime_error(std::string(buffer.data(), buffer.data() + len));
}
#endif
@ -637,8 +605,7 @@ int ffmpeg_instance::receive_packet(bool* received_packet, struct encoder_packet
uint8_t* tmp_sei;
std::size_t sz_packet, sz_header, sz_sei;
obs_extract_avc_headers(_packet->data, static_cast<size_t>(_packet->size), &tmp_packet, &sz_packet,
&tmp_header, &sz_header, &tmp_sei, &sz_sei);
obs_extract_avc_headers(_packet->data, static_cast<size_t>(_packet->size), &tmp_packet, &sz_packet, &tmp_header, &sz_header, &tmp_sei, &sz_sei);
if (sz_header) {
_extra_data.resize(sz_header);
@ -691,7 +658,7 @@ int ffmpeg_instance::receive_packet(bool* received_packet, struct encoder_packet
} else if (side_data.type == AV_PKT_DATA_QUALITY_STATS) {
// Decisions based on picture type, if present.
switch (side_data.data[sizeof(uint32_t)]) {
case AV_PICTURE_TYPE_I: // I-Frame
case AV_PICTURE_TYPE_I: // I-Frame
case AV_PICTURE_TYPE_SI: // Switching I-Frame
if (_packet->flags & AV_PKT_FLAG_KEY) {
// Recovery only via IDR-Frame.
@ -703,23 +670,23 @@ int ffmpeg_instance::receive_packet(bool* received_packet, struct encoder_packet
packet->drop_priority = 2; // OBS_NAL_PRIORITY_HIGH
}
break;
case AV_PICTURE_TYPE_P: // P-Frame
case AV_PICTURE_TYPE_P: // P-Frame
case AV_PICTURE_TYPE_SP: // Switching P-Frame
// Recovery via I- or IDR-Frame.
packet->priority = 1; // OBS_NAL_PRIORITY_LOW
packet->drop_priority = 2; // OBS_NAL_PRIORITY_HIGH
break;
case AV_PICTURE_TYPE_B: // B-Frame
case AV_PICTURE_TYPE_B: // B-Frame
// Recovery via I- or IDR-Frame.
packet->priority = 0; // OBS_NAL_PRIORITY_DISPOSABLE
packet->drop_priority = 2; // OBS_NAL_PRIORITY_HIGH
break;
case AV_PICTURE_TYPE_BI: // BI-Frame, theoretically identical to I-Frame.
case AV_PICTURE_TYPE_BI: // BI-Frame, theoretically identical to I-Frame.
// Recovery via I- or IDR-Frame.
packet->priority = 2; // OBS_NAL_PRIORITY_HIGH
packet->drop_priority = 2; // OBS_NAL_PRIORITY_HIGH
break;
default: // Unknown picture type.
default: // Unknown picture type.
// Recovery only via IDR-Frame
packet->priority = 2; // OBS_NAL_PRIORITY_HIGH
packet->drop_priority = 3; // OBS_NAL_PRIORITY_HIGHEST
@ -781,8 +748,7 @@ bool ffmpeg_instance::encode_avframe(std::shared_ptr<AVFrame> frame, encoder_pac
sent_frame = true;
break;
default:
DLOG_ERROR("Failed to encode frame: %s (%" PRId32 ").",
::streamfx::ffmpeg::tools::get_error_description(res), res);
DLOG_ERROR("Failed to encode frame: %s (%" PRId32 ").", ::streamfx::ffmpeg::tools::get_error_description(res), res);
return false;
}
}
@ -807,8 +773,7 @@ bool ffmpeg_instance::encode_avframe(std::shared_ptr<AVFrame> frame, encoder_pac
}
break;
default:
DLOG_ERROR("Failed to receive packet: %s (%" PRId32 ").",
::streamfx::ffmpeg::tools::get_error_description(res), res);
DLOG_ERROR("Failed to receive packet: %s (%" PRId32 ").", ::streamfx::ffmpeg::tools::get_error_description(res), res);
return false;
}
}
@ -867,7 +832,7 @@ void ffmpeg_instance::parse_ffmpeg_commandline(std::string_view text)
// Not supported yet.
p += 3;
} else if (here2 == 'u') { // 4 or 8 wide Unicode.
// Not supported yet.
// Not supported yet.
} else if (here2 == 'a') {
opt_stream << '\a';
p++;
@ -955,8 +920,7 @@ void ffmpeg_instance::parse_ffmpeg_commandline(std::string_view text)
int res = av_opt_set(_context, key.c_str(), value.c_str(), AV_OPT_SEARCH_CHILDREN);
if (res < 0) {
DLOG_WARNING("Option '%s' (key: '%s', value: '%s') encountered error: %s", opt.c_str(), key.c_str(),
value.c_str(), ::streamfx::ffmpeg::tools::get_error_description(res));
DLOG_WARNING("Option '%s' (key: '%s', value: '%s') encountered error: %s", opt.c_str(), key.c_str(), value.c_str(), ::streamfx::ffmpeg::tools::get_error_description(res));
}
} catch (const std::exception& ex) {
DLOG_ERROR("Option '%s' encountered exception: %s", opt.c_str(), ex.what());
@ -1088,8 +1052,7 @@ obs_properties_t* ffmpeg_factory::get_properties2(instance_t* data)
#ifdef ENABLE_FRONTEND
{
obs_properties_add_button2(props, S_MANUAL_OPEN, D_TRANSLATE(S_MANUAL_OPEN),
streamfx::encoder::ffmpeg::ffmpeg_factory::on_manual_open, this);
obs_properties_add_button2(props, S_MANUAL_OPEN, D_TRANSLATE(S_MANUAL_OPEN), streamfx::encoder::ffmpeg::ffmpeg_factory::on_manual_open, this);
}
#endif
@ -1109,23 +1072,17 @@ obs_properties_t* ffmpeg_factory::get_properties2(instance_t* data)
}
{ // Key-Frame Interval Type
auto p =
obs_properties_add_list(grp, ST_KEY_KEYFRAMES_INTERVALTYPE, D_TRANSLATE(ST_I18N_KEYFRAMES_INTERVALTYPE),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
auto p = obs_properties_add_list(grp, ST_KEY_KEYFRAMES_INTERVALTYPE, D_TRANSLATE(ST_I18N_KEYFRAMES_INTERVALTYPE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
obs_property_set_modified_callback(p, modified_keyframes);
obs_property_list_add_int(p, D_TRANSLATE(ST_I18N_KEYFRAMES_INTERVALTYPE_("Seconds")), 0);
obs_property_list_add_int(p, D_TRANSLATE(ST_I18N_KEYFRAMES_INTERVALTYPE_("Frames")), 1);
}
{ // Key-Frame Interval Seconds
auto p = obs_properties_add_float(grp, ST_KEY_KEYFRAMES_INTERVAL_SECONDS,
D_TRANSLATE(ST_I18N_KEYFRAMES_INTERVAL), 0.00,
std::numeric_limits<int16_t>::max(), 0.01);
auto p = obs_properties_add_float(grp, ST_KEY_KEYFRAMES_INTERVAL_SECONDS, D_TRANSLATE(ST_I18N_KEYFRAMES_INTERVAL), 0.00, std::numeric_limits<int16_t>::max(), 0.01);
obs_property_float_set_suffix(p, " seconds");
}
{ // Key-Frame Interval Frames
auto p =
obs_properties_add_int(grp, ST_KEY_KEYFRAMES_INTERVAL_FRAMES, D_TRANSLATE(ST_I18N_KEYFRAMES_INTERVAL),
0, std::numeric_limits<int32_t>::max(), 1);
auto p = obs_properties_add_int(grp, ST_KEY_KEYFRAMES_INTERVAL_FRAMES, D_TRANSLATE(ST_I18N_KEYFRAMES_INTERVAL), 0, std::numeric_limits<int32_t>::max(), 1);
obs_property_int_set_suffix(p, " frames");
}
}
@ -1139,19 +1096,15 @@ obs_properties_t* ffmpeg_factory::get_properties2(instance_t* data)
}
{ // Custom Settings
auto p =
obs_properties_add_text(grp, ST_KEY_FFMPEG_CUSTOMSETTINGS, D_TRANSLATE(ST_I18N_FFMPEG_CUSTOMSETTINGS),
obs_text_type::OBS_TEXT_DEFAULT);
auto p = obs_properties_add_text(grp, ST_KEY_FFMPEG_CUSTOMSETTINGS, D_TRANSLATE(ST_I18N_FFMPEG_CUSTOMSETTINGS), obs_text_type::OBS_TEXT_DEFAULT);
}
if (_handler && _handler->is_hardware_encoder(this)) {
auto p = obs_properties_add_int(grp, ST_KEY_FFMPEG_GPU, D_TRANSLATE(ST_I18N_FFMPEG_GPU), -1,
std::numeric_limits<uint8_t>::max(), 1);
auto p = obs_properties_add_int(grp, ST_KEY_FFMPEG_GPU, D_TRANSLATE(ST_I18N_FFMPEG_GPU), -1, std::numeric_limits<uint8_t>::max(), 1);
}
if (_handler && _handler->has_threading_support(this)) {
auto p = obs_properties_add_int_slider(grp, ST_KEY_FFMPEG_THREADS, D_TRANSLATE(ST_I18N_FFMPEG_THREADS), 0,
static_cast<int64_t>(std::thread::hardware_concurrency()) * 2, 1);
auto p = obs_properties_add_int_slider(grp, ST_KEY_FFMPEG_THREADS, D_TRANSLATE(ST_I18N_FFMPEG_THREADS), 0, static_cast<int64_t>(std::thread::hardware_concurrency()) * 2, 1);
}
{ // Frame Skipping
@ -1160,15 +1113,13 @@ obs_properties_t* ffmpeg_factory::get_properties2(instance_t* data)
throw std::runtime_error("obs_get_video_info failed unexpectedly.");
}
auto p = obs_properties_add_list(grp, ST_KEY_FFMPEG_FRAMERATE, D_TRANSLATE(ST_I18N_FFMPEG_FRAMERATE),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
auto p = obs_properties_add_list(grp, ST_KEY_FFMPEG_FRAMERATE, D_TRANSLATE(ST_I18N_FFMPEG_FRAMERATE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
// For now, an arbitrary limit of 1/10th the Framerate should be fine.
std::vector<char> buf{size_t{256}, 0, std::allocator<char>()};
for (uint32_t divisor = 1; divisor <= 10; divisor++) {
double fps_num = static_cast<double>(ovi.fps_num) / static_cast<double>(divisor);
double fps = fps_num / static_cast<double>(ovi.fps_den);
snprintf(buf.data(), buf.size(), "%8.2f (%" PRIu32 "/%" PRIu32 ")", fps, ovi.fps_num,
ovi.fps_den * divisor);
snprintf(buf.data(), buf.size(), "%8.2f (%" PRIu32 "/%" PRIu32 ")", fps, ovi.fps_num, ovi.fps_den * divisor);
obs_property_list_add_int(p, buf.data(), divisor);
}
}

View File

@ -73,8 +73,7 @@ namespace streamfx::encoder::ffmpeg {
bool encode_video(struct encoder_frame* frame, struct encoder_packet* packet, bool* received_packet) override;
bool encode_video(uint32_t handle, int64_t pts, uint64_t lock_key, uint64_t* next_key,
struct encoder_packet* packet, bool* received_packet) override;
bool encode_video(uint32_t handle, int64_t pts, uint64_t lock_key, uint64_t* next_key, struct encoder_packet* packet, bool* received_packet) override;
bool get_extra_data(uint8_t** extra_data, size_t* size) override;

View File

@ -32,14 +32,10 @@ static std::map<profile, std::string> profiles{
};
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_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::L4_1, "4.1"}, {level::L4_2, "4.2"}, {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::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::L3_0, "3.0"}, {level::L3_1, "3.1"}, {level::L3_2, "3.2"}, {level::L4_0, "4.0"}, {level::L4_1, "4.1"}, {level::L4_2, "4.2"}, {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"},
};
void amf_h264_handler::adjust_info(ffmpeg_factory* factory, const AVCodec* codec, std::string& id, std::string& name,
std::string& codec_id)
void amf_h264_handler::adjust_info(ffmpeg_factory* factory, const AVCodec* codec, std::string& id, std::string& name, std::string& codec_id)
{
name = "AMD AMF H.264/AVC (via FFmpeg)";
if (!amf::is_available())
@ -75,8 +71,7 @@ bool amf_h264_handler::has_pixel_format_support(ffmpeg_factory* instance)
return false;
}
void amf_h264_handler::get_properties(obs_properties_t* props, const AVCodec* codec, AVCodecContext* context,
bool hw_encode)
void amf_h264_handler::get_properties(obs_properties_t* props, const AVCodec* codec, AVCodecContext* context, bool hw_encode)
{
if (!context) {
this->get_encoder_properties(props, codec);
@ -116,10 +111,8 @@ void amf_h264_handler::log_options(obs_data_t* settings, const AVCodec* codec, A
amf::log_options(settings, codec, context);
DLOG_INFO("[%s] H.264/AVC:", codec->name);
::streamfx::ffmpeg::tools::print_av_option_string2(context, context->priv_data, "profile", " Profile",
[](int64_t v, std::string_view o) { return std::string(o); });
::streamfx::ffmpeg::tools::print_av_option_string2(context, context->priv_data, "level", " Level",
[](int64_t v, std::string_view o) { return std::string(o); });
::streamfx::ffmpeg::tools::print_av_option_string2(context, context->priv_data, "profile", " Profile", [](int64_t v, std::string_view o) { return std::string(o); });
::streamfx::ffmpeg::tools::print_av_option_string2(context, context->priv_data, "level", " Level", [](int64_t v, std::string_view o) { return std::string(o); });
}
void amf_h264_handler::get_encoder_properties(obs_properties_t* props, const AVCodec* codec)
@ -131,8 +124,7 @@ void amf_h264_handler::get_encoder_properties(obs_properties_t* props, const AVC
obs_properties_add_group(props, S_CODEC_H264, D_TRANSLATE(S_CODEC_H264), OBS_GROUP_NORMAL, grp);
{
auto p = obs_properties_add_list(grp, ST_KEY_PROFILE, D_TRANSLATE(S_CODEC_H264_PROFILE),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
auto p = obs_properties_add_list(grp, ST_KEY_PROFILE, D_TRANSLATE(S_CODEC_H264_PROFILE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
obs_property_list_add_int(p, D_TRANSLATE(S_STATE_DEFAULT), static_cast<int64_t>(profile::UNKNOWN));
for (auto const kv : profiles) {
std::string trans = std::string(S_CODEC_H264_PROFILE) + "." + kv.second;
@ -140,8 +132,7 @@ void amf_h264_handler::get_encoder_properties(obs_properties_t* props, const AVC
}
}
{
auto p = obs_properties_add_list(grp, ST_KEY_LEVEL, D_TRANSLATE(S_CODEC_H264_LEVEL), OBS_COMBO_TYPE_LIST,
OBS_COMBO_FORMAT_INT);
auto p = obs_properties_add_list(grp, ST_KEY_LEVEL, D_TRANSLATE(S_CODEC_H264_LEVEL), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
obs_property_list_add_int(p, D_TRANSLATE(S_STATE_AUTOMATIC), static_cast<int64_t>(level::UNKNOWN));
for (auto const kv : levels) {
obs_property_list_add_int(p, kv.second.c_str(), static_cast<int64_t>(kv.first));
@ -157,14 +148,12 @@ void amf_h264_handler::get_runtime_properties(obs_properties_t* props, const AVC
amf::get_runtime_properties(props, codec, context);
}
void amf_h264_handler::migrate(obs_data_t* settings, std::uint64_t version, const AVCodec* codec,
AVCodecContext* context)
void amf_h264_handler::migrate(obs_data_t* settings, std::uint64_t version, const AVCodec* codec, AVCodecContext* context)
{
amf::migrate(settings, version, codec, context);
}
void amf_h264_handler::override_colorformat(AVPixelFormat& target_format, obs_data_t* settings, const AVCodec* codec,
AVCodecContext* context)
void amf_h264_handler::override_colorformat(AVPixelFormat& target_format, obs_data_t* settings, const AVCodec* codec, AVCodecContext* context)
{
target_format = AV_PIX_FMT_NV12;
}

View File

@ -22,8 +22,7 @@ namespace streamfx::encoder::ffmpeg::handler {
virtual ~amf_h264_handler(){};
public /*factory*/:
void adjust_info(ffmpeg_factory* factory, const AVCodec* codec, std::string& id, std::string& name,
std::string& codec_id) override;
void adjust_info(ffmpeg_factory* factory, const AVCodec* codec, std::string& id, std::string& name, std::string& codec_id) override;
void get_defaults(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context, bool hw_encode) override;
@ -42,11 +41,9 @@ namespace streamfx::encoder::ffmpeg::handler {
bool has_pixel_format_support(ffmpeg_factory* instance) override;
public /*settings*/:
void get_properties(obs_properties_t* props, const AVCodec* codec, AVCodecContext* context,
bool hw_encode) override;
void get_properties(obs_properties_t* props, const AVCodec* codec, AVCodecContext* context, bool hw_encode) override;
void migrate(obs_data_t* settings, std::uint64_t version, const AVCodec* codec,
AVCodecContext* context) override;
void migrate(obs_data_t* settings, std::uint64_t version, const AVCodec* codec, AVCodecContext* context) override;
void update(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context) override;
@ -55,9 +52,7 @@ namespace streamfx::encoder::ffmpeg::handler {
void log_options(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context) override;
public /*instance*/:
void override_colorformat(AVPixelFormat& target_format, obs_data_t* settings, const AVCodec* codec,
AVCodecContext* context) override;
void override_colorformat(AVPixelFormat& target_format, obs_data_t* settings, const AVCodec* codec, AVCodecContext* context) override;
private:
void get_encoder_properties(obs_properties_t* props, const AVCodec* codec);

View File

@ -39,13 +39,10 @@ static std::map<tier, std::string> tiers{
};
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::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::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::L6_0, "6.0"}, {level::L6_1, "6.1"}, {level::L6_2, "6.2"},
};
void amf_hevc_handler::adjust_info(ffmpeg_factory* factory, const AVCodec* codec, std::string& id, std::string& name,
std::string& codec_id)
void amf_hevc_handler::adjust_info(ffmpeg_factory* factory, const AVCodec* codec, std::string& id, std::string& name, std::string& codec_id)
{
name = "AMD AMF H.265/HEVC (via FFmpeg)";
if (!amf::is_available())
@ -127,12 +124,9 @@ void amf_hevc_handler::log_options(obs_data_t* settings, const AVCodec* codec, A
amf::log_options(settings, codec, context);
DLOG_INFO("[%s] H.265/HEVC:", codec->name);
::streamfx::ffmpeg::tools::print_av_option_string2(context, "profile", " Profile",
[](int64_t v, std::string_view o) { return std::string(o); });
::streamfx::ffmpeg::tools::print_av_option_string2(context, "level", " Level",
[](int64_t v, std::string_view o) { return std::string(o); });
::streamfx::ffmpeg::tools::print_av_option_string2(context, "tier", " Tier",
[](int64_t v, std::string_view o) { return std::string(o); });
::streamfx::ffmpeg::tools::print_av_option_string2(context, "profile", " Profile", [](int64_t v, std::string_view o) { return std::string(o); });
::streamfx::ffmpeg::tools::print_av_option_string2(context, "level", " Level", [](int64_t v, std::string_view o) { return std::string(o); });
::streamfx::ffmpeg::tools::print_av_option_string2(context, "tier", " Tier", [](int64_t v, std::string_view o) { return std::string(o); });
}
void amf_hevc_handler::get_encoder_properties(obs_properties_t* props, const AVCodec* codec)
@ -144,8 +138,7 @@ void amf_hevc_handler::get_encoder_properties(obs_properties_t* props, const AVC
obs_properties_add_group(props, S_CODEC_HEVC, D_TRANSLATE(S_CODEC_HEVC), OBS_GROUP_NORMAL, grp);
{
auto p = obs_properties_add_list(grp, ST_KEY_PROFILE, D_TRANSLATE(S_CODEC_HEVC_PROFILE),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
auto p = obs_properties_add_list(grp, ST_KEY_PROFILE, D_TRANSLATE(S_CODEC_HEVC_PROFILE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
obs_property_list_add_int(p, D_TRANSLATE(S_STATE_DEFAULT), static_cast<int64_t>(profile::UNKNOWN));
for (auto const kv : profiles) {
std::string trans = std::string(S_CODEC_HEVC_PROFILE) + "." + kv.second;
@ -153,8 +146,7 @@ void amf_hevc_handler::get_encoder_properties(obs_properties_t* props, const AVC
}
}
{
auto p = obs_properties_add_list(grp, ST_KEY_TIER, D_TRANSLATE(S_CODEC_HEVC_TIER), OBS_COMBO_TYPE_LIST,
OBS_COMBO_FORMAT_INT);
auto p = obs_properties_add_list(grp, ST_KEY_TIER, D_TRANSLATE(S_CODEC_HEVC_TIER), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
obs_property_list_add_int(p, D_TRANSLATE(S_STATE_DEFAULT), static_cast<int64_t>(tier::UNKNOWN));
for (auto const kv : tiers) {
std::string trans = std::string(S_CODEC_HEVC_TIER) + "." + kv.second;
@ -162,8 +154,7 @@ void amf_hevc_handler::get_encoder_properties(obs_properties_t* props, const AVC
}
}
{
auto p = obs_properties_add_list(grp, ST_KEY_LEVEL, D_TRANSLATE(S_CODEC_HEVC_LEVEL), OBS_COMBO_TYPE_LIST,
OBS_COMBO_FORMAT_INT);
auto p = obs_properties_add_list(grp, ST_KEY_LEVEL, D_TRANSLATE(S_CODEC_HEVC_LEVEL), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
obs_property_list_add_int(p, D_TRANSLATE(S_STATE_AUTOMATIC), static_cast<int64_t>(level::UNKNOWN));
for (auto const kv : levels) {
obs_property_list_add_int(p, kv.second.c_str(), static_cast<int64_t>(kv.first));
@ -179,8 +170,7 @@ void amf_hevc_handler::get_runtime_properties(obs_properties_t* props, const AVC
amf::get_runtime_properties(props, codec, context);
}
void streamfx::encoder::ffmpeg::handler::amf_hevc_handler::migrate(obs_data_t* settings, std::uint64_t version,
const AVCodec* codec, AVCodecContext* context)
void streamfx::encoder::ffmpeg::handler::amf_hevc_handler::migrate(obs_data_t* settings, std::uint64_t version, const AVCodec* codec, AVCodecContext* context)
{
amf::migrate(settings, version, codec, context);
}

View File

@ -21,8 +21,7 @@ namespace streamfx::encoder::ffmpeg::handler {
virtual ~amf_hevc_handler(){};
public /*factory*/:
virtual void adjust_info(ffmpeg_factory* factory, const AVCodec* codec, std::string& id, std::string& name,
std::string& codec_id);
virtual void adjust_info(ffmpeg_factory* factory, const AVCodec* codec, std::string& id, std::string& name, std::string& codec_id);
virtual void get_defaults(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context, bool hw_encode);
@ -41,11 +40,9 @@ namespace streamfx::encoder::ffmpeg::handler {
virtual bool has_pixel_format_support(ffmpeg_factory* instance);
public /*settings*/:
virtual void get_properties(obs_properties_t* props, const AVCodec* codec, AVCodecContext* context,
bool hw_encode);
virtual void get_properties(obs_properties_t* props, const AVCodec* codec, AVCodecContext* context, bool hw_encode);
virtual void migrate(obs_data_t* settings, std::uint64_t version, const AVCodec* codec,
AVCodecContext* context);
virtual void migrate(obs_data_t* settings, std::uint64_t version, const AVCodec* codec, AVCodecContext* context);
virtual void update(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context);

View File

@ -181,8 +181,7 @@ void amf::get_properties_pre(obs_properties_t* props, const AVCodec* codec)
obs_property_text_set_info_word_wrap(p, true);
}
auto p = obs_properties_add_list(props, ST_KEY_PRESET, D_TRANSLATE(ST_I18N_PRESET), OBS_COMBO_TYPE_LIST,
OBS_COMBO_FORMAT_INT);
auto p = obs_properties_add_list(props, ST_KEY_PRESET, D_TRANSLATE(ST_I18N_PRESET), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
for (auto kv : presets) {
obs_property_list_add_int(p, D_TRANSLATE(kv.second.c_str()), static_cast<int64_t>(kv.first));
}
@ -195,58 +194,46 @@ void amf::get_properties_post(obs_properties_t* props, const AVCodec* codec)
obs_properties_add_group(props, ST_I18N_RATECONTROL, D_TRANSLATE(ST_I18N_RATECONTROL), OBS_GROUP_NORMAL, grp);
{
auto p = obs_properties_add_list(grp, ST_KEY_RATECONTROL_MODE, D_TRANSLATE(ST_I18N_RATECONTROL_MODE),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
auto p = obs_properties_add_list(grp, ST_KEY_RATECONTROL_MODE, D_TRANSLATE(ST_I18N_RATECONTROL_MODE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
obs_property_set_modified_callback(p, modified_ratecontrol);
for (auto kv : ratecontrolmodes) {
obs_property_list_add_int(p, D_TRANSLATE(kv.second.c_str()), static_cast<int64_t>(kv.first));
}
}
streamfx::util::obs_properties_add_tristate(grp, ST_KEY_RATECONTROL_LOOKAHEAD,
D_TRANSLATE(ST_I18N_RATECONTROL_LOOKAHEAD));
streamfx::util::obs_properties_add_tristate(grp, ST_KEY_RATECONTROL_FRAMESKIPPING,
D_TRANSLATE(ST_I18N_RATECONTROL_FRAMESKIPPING));
streamfx::util::obs_properties_add_tristate(grp, ST_KEY_RATECONTROL_LOOKAHEAD, D_TRANSLATE(ST_I18N_RATECONTROL_LOOKAHEAD));
streamfx::util::obs_properties_add_tristate(grp, ST_KEY_RATECONTROL_FRAMESKIPPING, D_TRANSLATE(ST_I18N_RATECONTROL_FRAMESKIPPING));
}
{
obs_properties_t* grp = obs_properties_create();
obs_properties_add_group(props, ST_I18N_RATECONTROL_LIMITS, D_TRANSLATE(ST_I18N_RATECONTROL_LIMITS),
OBS_GROUP_NORMAL, grp);
obs_properties_add_group(props, ST_I18N_RATECONTROL_LIMITS, D_TRANSLATE(ST_I18N_RATECONTROL_LIMITS), OBS_GROUP_NORMAL, grp);
{
auto p = obs_properties_add_int(grp, ST_KEY_RATECONTROL_LIMITS_BITRATE_TARGET,
D_TRANSLATE(ST_I18N_RATECONTROL_LIMITS_BITRATE_TARGET), -1,
std::numeric_limits<std::int32_t>::max(), 1);
auto p = obs_properties_add_int(grp, ST_KEY_RATECONTROL_LIMITS_BITRATE_TARGET, D_TRANSLATE(ST_I18N_RATECONTROL_LIMITS_BITRATE_TARGET), -1, std::numeric_limits<std::int32_t>::max(), 1);
obs_property_int_set_suffix(p, " kbit/s");
}
{
auto p = obs_properties_add_int(grp, ST_KEY_RATECONTROL_LIMITS_BITRATE_MAXIMUM,
D_TRANSLATE(ST_I18N_RATECONTROL_LIMITS_BITRATE_MAXIMUM), -1,
std::numeric_limits<std::int32_t>::max(), 1);
auto p = obs_properties_add_int(grp, ST_KEY_RATECONTROL_LIMITS_BITRATE_MAXIMUM, D_TRANSLATE(ST_I18N_RATECONTROL_LIMITS_BITRATE_MAXIMUM), -1, std::numeric_limits<std::int32_t>::max(), 1);
obs_property_int_set_suffix(p, " kbit/s");
}
{
auto p = obs_properties_add_int(grp, ST_KEY_RATECONTROL_LIMITS_BUFFERSIZE,
D_TRANSLATE(ST_I18N_RATECONTROL_LIMITS_BUFFERSIZE), 0,
std::numeric_limits<std::int32_t>::max(), 1);
auto p = obs_properties_add_int(grp, ST_KEY_RATECONTROL_LIMITS_BUFFERSIZE, D_TRANSLATE(ST_I18N_RATECONTROL_LIMITS_BUFFERSIZE), 0, std::numeric_limits<std::int32_t>::max(), 1);
obs_property_int_set_suffix(p, " kbit");
}
}
{
obs_properties_t* grp = obs_properties_create();
obs_properties_add_group(props, ST_I18N_RATECONTROL_QP, D_TRANSLATE(ST_I18N_RATECONTROL_QP), OBS_GROUP_NORMAL,
grp);
obs_properties_add_group(props, ST_I18N_RATECONTROL_QP, D_TRANSLATE(ST_I18N_RATECONTROL_QP), OBS_GROUP_NORMAL, grp);
obs_properties_add_int_slider(grp, ST_KEY_RATECONTROL_QP_I, D_TRANSLATE(ST_I18N_RATECONTROL_QP_I), -1, 51, 1);
obs_properties_add_int_slider(grp, ST_KEY_RATECONTROL_QP_P, D_TRANSLATE(ST_I18N_RATECONTROL_QP_P), -1, 51, 1);
if (std::string_view("amf_h264") == codec->name) {
obs_properties_add_int_slider(grp, ST_KEY_RATECONTROL_QP_B, D_TRANSLATE(ST_I18N_RATECONTROL_QP_B), -1, 51,
1);
obs_properties_add_int_slider(grp, ST_KEY_RATECONTROL_QP_B, D_TRANSLATE(ST_I18N_RATECONTROL_QP_B), -1, 51, 1);
}
}
@ -255,23 +242,18 @@ void amf::get_properties_post(obs_properties_t* props, const AVCodec* codec)
obs_properties_add_group(props, ST_I18N_OTHER, D_TRANSLATE(ST_I18N_OTHER), OBS_GROUP_NORMAL, grp);
{
auto p =
obs_properties_add_int_slider(grp, ST_KEY_OTHER_BFRAMES, D_TRANSLATE(ST_I18N_OTHER_BFRAMES), -1, 4, 1);
auto p = obs_properties_add_int_slider(grp, ST_KEY_OTHER_BFRAMES, D_TRANSLATE(ST_I18N_OTHER_BFRAMES), -1, 4, 1);
obs_property_int_set_suffix(p, " frames");
}
streamfx::util::obs_properties_add_tristate(grp, ST_KEY_OTHER_BFRAMEREFERENCES,
D_TRANSLATE(ST_I18N_OTHER_BFRAMEREFERENCES));
streamfx::util::obs_properties_add_tristate(grp, ST_KEY_OTHER_BFRAMEREFERENCES, D_TRANSLATE(ST_I18N_OTHER_BFRAMEREFERENCES));
{
auto p = obs_properties_add_int_slider(grp, ST_KEY_OTHER_REFERENCEFRAMES,
D_TRANSLATE(ST_I18N_OTHER_REFERENCEFRAMES), -1, 16, 1);
auto p = obs_properties_add_int_slider(grp, ST_KEY_OTHER_REFERENCEFRAMES, D_TRANSLATE(ST_I18N_OTHER_REFERENCEFRAMES), -1, 16, 1);
obs_property_int_set_suffix(p, " frames");
}
streamfx::util::obs_properties_add_tristate(grp, ST_KEY_OTHER_ENFORCEHRD,
D_TRANSLATE(ST_I18N_OTHER_ENFORCEHRD));
streamfx::util::obs_properties_add_tristate(grp, ST_KEY_OTHER_ENFORCEHRD, D_TRANSLATE(ST_I18N_OTHER_ENFORCEHRD));
streamfx::util::obs_properties_add_tristate(grp, ST_KEY_OTHER_VBAQ, D_TRANSLATE(ST_I18N_OTHER_VBAQ));
streamfx::util::obs_properties_add_tristate(grp, ST_KEY_OTHER_ACCESSUNITDELIMITER,
D_TRANSLATE(ST_I18N_OTHER_ACCESSUNITDELIMITER));
streamfx::util::obs_properties_add_tristate(grp, ST_KEY_OTHER_ACCESSUNITDELIMITER, D_TRANSLATE(ST_I18N_OTHER_ACCESSUNITDELIMITER));
}
}
@ -325,14 +307,12 @@ void amf::update(obs_data_t* settings, const AVCodec* codec, AVCodecContext* con
}
// Look Ahead (Pre-analysis, single frame lookahead)
if (int la = static_cast<int>(obs_data_get_int(settings, ST_KEY_RATECONTROL_LOOKAHEAD));
!streamfx::util::is_tristate_default(la)) {
if (int la = static_cast<int>(obs_data_get_int(settings, ST_KEY_RATECONTROL_LOOKAHEAD)); !streamfx::util::is_tristate_default(la)) {
av_opt_set_int(context->priv_data, "preanalysis", la, AV_OPT_SEARCH_CHILDREN);
}
// Frame Skipping (Drop frames to maintain bitrate limits)
if (int la = static_cast<int>(obs_data_get_int(settings, ST_KEY_RATECONTROL_FRAMESKIPPING));
!streamfx::util::is_tristate_default(la)) {
if (int la = static_cast<int>(obs_data_get_int(settings, ST_KEY_RATECONTROL_FRAMESKIPPING)); !streamfx::util::is_tristate_default(la)) {
if (std::string_view("amf_h264") == codec->name) {
av_opt_set_int(context->priv_data, "frame_skipping", la, AV_OPT_SEARCH_CHILDREN);
} else {
@ -390,8 +370,7 @@ void amf::update(obs_data_t* settings, const AVCodec* codec, AVCodecContext* con
if (int64_t bf = obs_data_get_int(settings, ST_KEY_OTHER_BFRAMES); bf > -1) {
context->max_b_frames = static_cast<int>(bf);
}
if (int64_t zl = obs_data_get_int(settings, ST_KEY_OTHER_BFRAMEREFERENCES);
!streamfx::util::is_tristate_default(zl)) {
if (int64_t zl = obs_data_get_int(settings, ST_KEY_OTHER_BFRAMEREFERENCES); !streamfx::util::is_tristate_default(zl)) {
av_opt_set_int(context->priv_data, "bf_ref", zl, AV_OPT_SEARCH_CHILDREN);
}
}
@ -408,8 +387,7 @@ void amf::update(obs_data_t* settings, const AVCodec* codec, AVCodecContext* con
av_opt_set_int(context->priv_data, "vbaq", v, AV_OPT_SEARCH_CHILDREN);
}
if (int64_t v = obs_data_get_int(settings, ST_KEY_OTHER_ACCESSUNITDELIMITER);
!streamfx::util::is_tristate_default(v)) {
if (int64_t v = obs_data_get_int(settings, ST_KEY_OTHER_ACCESSUNITDELIMITER); !streamfx::util::is_tristate_default(v)) {
av_opt_set_int(context->priv_data, "aud", v, AV_OPT_SEARCH_CHILDREN);
}
@ -423,12 +401,9 @@ void amf::log_options(obs_data_t* settings, const AVCodec* codec, AVCodecContext
using namespace ::streamfx::ffmpeg;
DLOG_INFO("[%s] AMD AMF:", codec->name);
tools::print_av_option_string2(context, "usage", " Usage",
[](int64_t v, std::string_view o) { return std::string(o); });
tools::print_av_option_string2(context, "quality", " Preset",
[](int64_t v, std::string_view o) { return std::string(o); });
tools::print_av_option_string2(context, "rc", " Rate Control",
[](int64_t v, std::string_view o) { return std::string(o); });
tools::print_av_option_string2(context, "usage", " Usage", [](int64_t v, std::string_view o) { return std::string(o); });
tools::print_av_option_string2(context, "quality", " Preset", [](int64_t v, std::string_view o) { return std::string(o); });
tools::print_av_option_string2(context, "rc", " Rate Control", [](int64_t v, std::string_view o) { return std::string(o); });
tools::print_av_option_bool(context, "preanalysis", " Look-Ahead");
if (std::string_view("amf_h264") == codec->name) {
tools::print_av_option_bool(context, "frame_skipping", " Frame Skipping");
@ -463,12 +438,8 @@ void amf::log_options(obs_data_t* settings, const AVCodec* codec, AVCodecContext
tools::print_av_option_bool(context, "me_quarter_pel", " Quarter-Pel Motion Estimation");
}
void streamfx::encoder::ffmpeg::handler::amf::get_runtime_properties(obs_properties_t* props, const AVCodec* codec,
AVCodecContext* context)
{}
void streamfx::encoder::ffmpeg::handler::amf::get_runtime_properties(obs_properties_t* props, const AVCodec* codec, AVCodecContext* context) {}
void streamfx::encoder::ffmpeg::handler::amf::migrate(obs_data_t* settings, uint64_t version, const AVCodec* codec,
AVCodecContext* context)
{}
void streamfx::encoder::ffmpeg::handler::amf::migrate(obs_data_t* settings, uint64_t version, const AVCodec* codec, AVCodecContext* context) {}
void streamfx::encoder::ffmpeg::handler::amf::override_update(ffmpeg_instance* instance, obs_data_t* settings) {}

View File

@ -69,25 +69,7 @@ void debug_handler::get_properties(obs_properties_t*, const AVCodec* codec, AVCo
DLOG_INFO("Options for '%s':", codec->name);
std::pair<AVOptionType, std::string> opt_type_name[] = {
{AV_OPT_TYPE_FLAGS, "Flags"},
{AV_OPT_TYPE_INT, "Int"},
{AV_OPT_TYPE_INT64, "Int64"},
{AV_OPT_TYPE_DOUBLE, "Double"},
{AV_OPT_TYPE_FLOAT, "Float"},
{AV_OPT_TYPE_STRING, "String"},
{AV_OPT_TYPE_RATIONAL, "Rational"},
{AV_OPT_TYPE_BINARY, "Binary"},
{AV_OPT_TYPE_DICT, "Dictionary"},
{AV_OPT_TYPE_UINT64, "Unsigned Int64"},
{AV_OPT_TYPE_CONST, "Constant"},
{AV_OPT_TYPE_IMAGE_SIZE, "Image Size"},
{AV_OPT_TYPE_PIXEL_FMT, "Pixel Format"},
{AV_OPT_TYPE_SAMPLE_FMT, "Sample Format"},
{AV_OPT_TYPE_VIDEO_RATE, "Video Rate"},
{AV_OPT_TYPE_DURATION, "Duration"},
{AV_OPT_TYPE_COLOR, "Color"},
{AV_OPT_TYPE_CHANNEL_LAYOUT, "Layout"},
{AV_OPT_TYPE_BOOL, "Bool"},
{AV_OPT_TYPE_FLAGS, "Flags"}, {AV_OPT_TYPE_INT, "Int"}, {AV_OPT_TYPE_INT64, "Int64"}, {AV_OPT_TYPE_DOUBLE, "Double"}, {AV_OPT_TYPE_FLOAT, "Float"}, {AV_OPT_TYPE_STRING, "String"}, {AV_OPT_TYPE_RATIONAL, "Rational"}, {AV_OPT_TYPE_BINARY, "Binary"}, {AV_OPT_TYPE_DICT, "Dictionary"}, {AV_OPT_TYPE_UINT64, "Unsigned Int64"}, {AV_OPT_TYPE_CONST, "Constant"}, {AV_OPT_TYPE_IMAGE_SIZE, "Image Size"}, {AV_OPT_TYPE_PIXEL_FMT, "Pixel Format"}, {AV_OPT_TYPE_SAMPLE_FMT, "Sample Format"}, {AV_OPT_TYPE_VIDEO_RATE, "Video Rate"}, {AV_OPT_TYPE_DURATION, "Duration"}, {AV_OPT_TYPE_COLOR, "Color"}, {AV_OPT_TYPE_CHANNEL_LAYOUT, "Layout"}, {AV_OPT_TYPE_BOOL, "Bool"},
};
std::map<std::string, AVOptionType> unit_types;
@ -107,8 +89,7 @@ void debug_handler::get_properties(obs_properties_t*, const AVCodec* codec, AVCo
} else {
auto unit_type = unit_types.find(opt->unit);
if (unit_type == unit_types.end()) {
DLOG_INFO(" [%s] Flag '%s' and help text '%s' with value '%" PRId64 "'.", opt->unit, opt->name,
opt->help, opt->default_val.i64);
DLOG_INFO(" [%s] Flag '%s' and help text '%s' with value '%" PRId64 "'.", opt->unit, opt->name, opt->help, opt->default_val.i64);
} else {
std::string out;
switch (unit_type->second) {
@ -135,8 +116,7 @@ void debug_handler::get_properties(obs_properties_t*, const AVCodec* codec, AVCo
break;
}
DLOG_INFO(" [%s] Constant '%s' and help text '%s' with value '%s'.", opt->unit, opt->name,
opt->help, out.c_str());
DLOG_INFO(" [%s] Constant '%s' and help text '%s' with value '%s'.", opt->unit, opt->name, opt->help, out.c_str());
}
}
} else {
@ -176,8 +156,7 @@ void debug_handler::get_properties(obs_properties_t*, const AVCodec* codec, AVCo
DLOG_INFO(
" Option '%s'%s%s%s with help '%s' of type '%s' with default value '%s', minimum '%s' and maximum "
"'%s'.",
opt->name, opt->unit ? " with unit (" : "", opt->unit ? opt->unit : "", opt->unit ? ")" : "", opt->help,
type_name.c_str(), out.c_str(), minimum.c_str(), maximum.c_str());
opt->name, opt->unit ? " with unit (" : "", opt->unit ? opt->unit : "", opt->unit ? ")" : "", opt->help, type_name.c_str(), out.c_str(), minimum.c_str(), maximum.c_str());
}
}
}

View File

@ -10,11 +10,9 @@ namespace streamfx::encoder::ffmpeg::handler {
public:
virtual ~debug_handler(){};
virtual void get_defaults(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context,
bool hw_encode) override;
virtual void get_defaults(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context, bool hw_encode) override;
virtual void get_properties(obs_properties_t* props, const AVCodec* codec, AVCodecContext* context,
bool hw_encode) override;
virtual void get_properties(obs_properties_t* props, const AVCodec* codec, AVCodecContext* context, bool hw_encode) override;
virtual void update(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context) override;
};

View File

@ -24,13 +24,9 @@ void dnxhd_handler::adjust_info(ffmpeg_factory* fac, const AVCodec*, std::string
name = "Avid DNxHR (via FFmpeg)";
}
void dnxhd_handler::override_colorformat(AVPixelFormat& target_format, obs_data_t* settings, const AVCodec* codec,
AVCodecContext*)
void dnxhd_handler::override_colorformat(AVPixelFormat& target_format, obs_data_t* settings, const AVCodec* codec, AVCodecContext*)
{
static const std::array<std::pair<const char*, AVPixelFormat>, static_cast<size_t>(5)> profile_to_format_map{
std::pair{"dnxhr_lb", AV_PIX_FMT_YUV422P}, std::pair{"dnxhr_sq", AV_PIX_FMT_YUV422P},
std::pair{"dnxhr_hq", AV_PIX_FMT_YUV422P}, std::pair{"dnxhr_hqx", AV_PIX_FMT_YUV422P10},
std::pair{"dnxhr_444", AV_PIX_FMT_YUV444P10}};
static const std::array<std::pair<const char*, AVPixelFormat>, static_cast<size_t>(5)> profile_to_format_map{std::pair{"dnxhr_lb", AV_PIX_FMT_YUV422P}, std::pair{"dnxhr_sq", AV_PIX_FMT_YUV422P}, std::pair{"dnxhr_hq", AV_PIX_FMT_YUV422P}, std::pair{"dnxhr_hqx", AV_PIX_FMT_YUV422P10}, std::pair{"dnxhr_444", AV_PIX_FMT_YUV444P10}};
const char* selected_profile = obs_data_get_string(settings, S_CODEC_DNXHR_PROFILE);
for (const auto& kv : profile_to_format_map) {
@ -78,8 +74,7 @@ void dnxhd_handler::get_properties(obs_properties_t* props, const AVCodec* codec
return;
}
}
auto p = obs_properties_add_list(props, S_CODEC_DNXHR_PROFILE, D_TRANSLATE(S_CODEC_DNXHR_PROFILE),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
auto p = obs_properties_add_list(props, S_CODEC_DNXHR_PROFILE, D_TRANSLATE(S_CODEC_DNXHR_PROFILE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
streamfx::ffmpeg::tools::avoption_list_add_entries(ctx->priv_data, "profile", [&p](const AVOption* opt) {
if (strcmp(opt->name, "dnxhd") == 0) {
@ -109,6 +104,5 @@ void dnxhd_handler::update(obs_data_t* settings, const AVCodec* codec, AVCodecCo
void dnxhd_handler::log_options(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context)
{
DLOG_INFO("[%s] Avid DNxHR:", codec->name);
streamfx::ffmpeg::tools::print_av_option_string2(context, "profile", " Profile",
[](int64_t v, std::string_view o) { return std::string(o); });
streamfx::ffmpeg::tools::print_av_option_string2(context, "profile", " Profile", [](int64_t v, std::string_view o) { return std::string(o); });
}

View File

@ -18,8 +18,7 @@ namespace streamfx::encoder::ffmpeg::handler {
virtual ~dnxhd_handler(){};
public /*factory*/:
virtual void adjust_info(ffmpeg_factory* factory, const AVCodec* codec, std::string& id, std::string& name,
std::string& codec_id);
virtual void adjust_info(ffmpeg_factory* factory, const AVCodec* codec, std::string& id, std::string& name, std::string& codec_id);
public /*factory*/:
void get_defaults(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context, bool hw_encode) override;
@ -36,15 +35,13 @@ namespace streamfx::encoder::ffmpeg::handler {
bool has_pixel_format_support(ffmpeg_factory* instance) override;
public /*settings*/:
void get_properties(obs_properties_t* props, const AVCodec* codec, AVCodecContext* context,
bool hw_encode) override;
void get_properties(obs_properties_t* props, const AVCodec* codec, AVCodecContext* context, bool hw_encode) override;
void update(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context) override;
void log_options(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context) override;
public /*instance*/:
void override_colorformat(AVPixelFormat& target_format, obs_data_t* settings, const AVCodec* codec,
AVCodecContext* context) override;
void override_colorformat(AVPixelFormat& target_format, obs_data_t* settings, const AVCodec* codec, AVCodecContext* context) override;
};
} // namespace streamfx::encoder::ffmpeg::handler

View File

@ -23,11 +23,9 @@ namespace streamfx::encoder::ffmpeg {
virtual ~handler(){};
public /*factory*/:
virtual void adjust_info(ffmpeg_factory* factory, const AVCodec* codec, std::string& id, std::string& name,
std::string& codec_id){};
virtual void adjust_info(ffmpeg_factory* factory, const AVCodec* codec, std::string& id, std::string& name, std::string& codec_id){};
virtual void get_defaults(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context,
bool hw_encode){};
virtual void get_defaults(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context, bool hw_encode){};
virtual std::string_view get_help_url(const AVCodec* codec)
{
@ -46,11 +44,9 @@ namespace streamfx::encoder::ffmpeg {
virtual bool supports_reconfigure(ffmpeg_factory* instance, bool& threads, bool& gpu, bool& keyframes);
public /*settings*/:
virtual void get_properties(obs_properties_t* props, const AVCodec* codec, AVCodecContext* context,
bool hw_encode){};
virtual void get_properties(obs_properties_t* props, const AVCodec* codec, AVCodecContext* context, bool hw_encode){};
virtual void migrate(obs_data_t* settings, uint64_t version, const AVCodec* codec,
AVCodecContext* context){};
virtual void migrate(obs_data_t* settings, uint64_t version, const AVCodec* codec, AVCodecContext* context){};
virtual void update(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context){};
@ -59,12 +55,9 @@ namespace streamfx::encoder::ffmpeg {
virtual void log_options(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context){};
public /*instance*/:
virtual void override_colorformat(AVPixelFormat& target_format, obs_data_t* settings, const AVCodec* codec, AVCodecContext* context){};
virtual void override_colorformat(AVPixelFormat& target_format, obs_data_t* settings, const AVCodec* codec,
AVCodecContext* context){};
virtual void process_avpacket(std::shared_ptr<AVPacket> packet, const AVCodec* codec,
AVCodecContext* context){};
virtual void process_avpacket(std::shared_ptr<AVPacket> packet, const AVCodec* codec, AVCodecContext* context){};
};
} // namespace handler
} // namespace streamfx::encoder::ffmpeg

View File

@ -92,10 +92,8 @@ void nvenc_h264_handler::log_options(obs_data_t* settings, const AVCodec* codec,
nvenc::log_options(settings, codec, context);
DLOG_INFO("[%s] H.264/AVC:", codec->name);
::streamfx::ffmpeg::tools::print_av_option_string2(context, context->priv_data, "profile", " Profile",
[](int64_t v, std::string_view o) { return std::string(o); });
::streamfx::ffmpeg::tools::print_av_option_string2(context, context->priv_data, "level", " Level",
[](int64_t v, std::string_view o) { return std::string(o); });
::streamfx::ffmpeg::tools::print_av_option_string2(context, context->priv_data, "profile", " Profile", [](int64_t v, std::string_view o) { return std::string(o); });
::streamfx::ffmpeg::tools::print_av_option_string2(context, context->priv_data, "level", " Level", [](int64_t v, std::string_view o) { return std::string(o); });
}
void nvenc_h264_handler::get_encoder_properties(obs_properties_t* props, const AVCodec* codec)
@ -116,19 +114,16 @@ void nvenc_h264_handler::get_encoder_properties(obs_properties_t* props, const A
}
{
auto p = obs_properties_add_list(grp, ST_KEY_PROFILE, D_TRANSLATE(S_CODEC_H264_PROFILE),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
auto p = obs_properties_add_list(grp, ST_KEY_PROFILE, D_TRANSLATE(S_CODEC_H264_PROFILE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
obs_property_list_add_string(p, D_TRANSLATE(S_STATE_DEFAULT), "");
streamfx::ffmpeg::tools::avoption_list_add_entries(
context->priv_data, "profile", [&p](const AVOption* opt) {
char buffer[1024];
snprintf(buffer, sizeof(buffer), "%s.%s", S_CODEC_H264_PROFILE, opt->name);
obs_property_list_add_string(p, D_TRANSLATE(buffer), opt->name);
});
streamfx::ffmpeg::tools::avoption_list_add_entries(context->priv_data, "profile", [&p](const AVOption* opt) {
char buffer[1024];
snprintf(buffer, sizeof(buffer), "%s.%s", S_CODEC_H264_PROFILE, opt->name);
obs_property_list_add_string(p, D_TRANSLATE(buffer), opt->name);
});
}
{
auto p = obs_properties_add_list(grp, ST_KEY_LEVEL, D_TRANSLATE(S_CODEC_H264_LEVEL), OBS_COMBO_TYPE_LIST,
OBS_COMBO_FORMAT_STRING);
auto p = obs_properties_add_list(grp, ST_KEY_LEVEL, D_TRANSLATE(S_CODEC_H264_LEVEL), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
streamfx::ffmpeg::tools::avoption_list_add_entries(context->priv_data, "level", [&p](const AVOption* opt) {
if (opt->default_val.i64 == 0) {
@ -152,8 +147,7 @@ void nvenc_h264_handler::get_runtime_properties(obs_properties_t* props, const A
nvenc::get_runtime_properties(props, codec, context);
}
void streamfx::encoder::ffmpeg::handler::nvenc_h264_handler::migrate(obs_data_t* settings, uint64_t version,
const AVCodec* codec, AVCodecContext* context)
void streamfx::encoder::ffmpeg::handler::nvenc_h264_handler::migrate(obs_data_t* settings, uint64_t version, const AVCodec* codec, AVCodecContext* context)
{
nvenc::migrate(settings, version, codec, context);

View File

@ -17,8 +17,7 @@ namespace streamfx::encoder::ffmpeg::handler {
virtual ~nvenc_h264_handler(){};
public /*factory*/: