mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-11 06:15:05 +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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tools::avoption_list_add_entries_unnamed(const void* obj, std::string_view unit, obs_property_t* prop,
|
void tools::avoption_list_add_entries(const void* obj, std::string_view unit,
|
||||||
std::function<bool(const AVOption*)> filter)
|
std::function<void(const AVOption*)> inserter)
|
||||||
{
|
{
|
||||||
for (const AVOption* opt = nullptr; (opt = av_opt_next(obj, opt)) != nullptr;) {
|
for (const AVOption* opt = nullptr; (opt = av_opt_next(obj, opt)) != nullptr;) {
|
||||||
// Skip all irrelevant options.
|
// 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)
|
if (opt->flags & AV_OPT_FLAG_DEPRECATED)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (filter && filter(opt))
|
if (inserter) {
|
||||||
continue;
|
inserter(opt);
|
||||||
|
} else {
|
||||||
// Generate name and add to list.
|
break;
|
||||||
obs_property_list_add_int(prop, opt->name, opt->default_val.i64);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
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);
|
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,
|
void avoption_list_add_entries(const void* obj, std::string_view unit,
|
||||||
std::function<bool(const AVOption*)> filter = nullptr);
|
std::function<void(const AVOption*)> inserter = 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);
|
|
||||||
|
|
||||||
} // namespace streamfx::ffmpeg::tools
|
} // namespace streamfx::ffmpeg::tools
|
||||||
|
|
Loading…
Reference in a new issue