mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-27 13:53:01 +00:00
ffmpeg/tools: Improve helper functions for AVOption lists
This commit is contained in:
parent
0da1e77b22
commit
378f2b3f0e
2 changed files with 9 additions and 39 deletions
|
@ -209,8 +209,8 @@ bool tools::avoption_exists(const void* obj, std::string_view name)
|
|||
return false;
|
||||
}
|
||||
|
||||
void tools::avoption_list_add_entries_unnamed(const void* obj, std::string_view unit, obs_property_t* prop,
|
||||
std::function<bool(const AVOption*)> filter)
|
||||
void tools::avoption_list_add_entries(const void* obj, std::string_view unit,
|
||||
std::function<void(const AVOption*)> inserter)
|
||||
{
|
||||
for (const AVOption* opt = nullptr; (opt = av_opt_next(obj, opt)) != nullptr;) {
|
||||
// Skip all irrelevant options.
|
||||
|
@ -225,39 +225,12 @@ void tools::avoption_list_add_entries_unnamed(const void* obj, std::string_view
|
|||
if (opt->flags & AV_OPT_FLAG_DEPRECATED)
|
||||
continue;
|
||||
|
||||
if (filter && filter(opt))
|
||||
continue;
|
||||
|
||||
// Generate name and add to list.
|
||||
obs_property_list_add_int(prop, opt->name, opt->default_val.i64);
|
||||
if (inserter) {
|
||||
inserter(opt);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void tools::avoption_list_add_entries(const void* obj, std::string_view unit, obs_property_t* prop,
|
||||
std::string_view prefix, std::function<bool(const AVOption*)> filter)
|
||||
{
|
||||
for (const AVOption* opt = nullptr; (opt = av_opt_next(obj, opt)) != nullptr;) {
|
||||
// Skip all irrelevant options.
|
||||
if (!opt->unit)
|
||||
continue;
|
||||
if (opt->unit != unit)
|
||||
continue;
|
||||
if (opt->name == unit)
|
||||
continue;
|
||||
|
||||
// Skip any deprecated options.
|
||||
if (opt->flags & AV_OPT_FLAG_DEPRECATED)
|
||||
continue;
|
||||
|
||||
// Skip based on filter function.
|
||||
if (filter && filter(opt))
|
||||
continue;
|
||||
|
||||
// Generate name and add to list.
|
||||
char buffer[1024];
|
||||
snprintf(buffer, sizeof(buffer), "%s.%s\0", prefix.data(), opt->name);
|
||||
obs_property_list_add_int(prop, D_TRANSLATE(buffer), opt->default_val.i64);
|
||||
}
|
||||
}
|
||||
|
||||
bool tools::can_hardware_encode(const AVCodec* codec)
|
||||
|
|
|
@ -85,10 +85,7 @@ namespace streamfx::ffmpeg::tools {
|
|||
|
||||
const char* avoption_name_from_unit_value(const void* obj, std::string_view unit, int64_t value);
|
||||
|
||||
void avoption_list_add_entries_unnamed(const void* obj, std::string_view unit, obs_property_t* prop,
|
||||
std::function<bool(const AVOption*)> filter = nullptr);
|
||||
|
||||
void avoption_list_add_entries(const void* obj, std::string_view unit, obs_property_t* prop,
|
||||
std::string_view prefix, std::function<bool(const AVOption*)> filter = nullptr);
|
||||
void avoption_list_add_entries(const void* obj, std::string_view unit,
|
||||
std::function<void(const AVOption*)> inserter = nullptr);
|
||||
|
||||
} // namespace streamfx::ffmpeg::tools
|
||||
|
|
Loading…
Reference in a new issue