mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-11 06:15:05 +00:00
ffmpeg/tools: Allow overriding option context
This commit is contained in:
parent
5223d3980f
commit
e2c83f546e
2 changed files with 48 additions and 17 deletions
|
@ -308,39 +308,65 @@ const char* tools::get_thread_type_name(int thread_type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tools::print_av_option_bool(AVCodecContext* context, const char* option, std::string text)
|
void tools::print_av_option_bool(AVCodecContext* ctx_codec, const char* option, std::string text)
|
||||||
|
{
|
||||||
|
print_av_option_bool(ctx_codec, ctx_codec, option, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ffmpeg::tools::print_av_option_bool(AVCodecContext* ctx_codec, void* ctx_option, const char* option,
|
||||||
|
std::string text)
|
||||||
{
|
{
|
||||||
int64_t v = 0;
|
int64_t v = 0;
|
||||||
if (av_opt_get_int(context, option, AV_OPT_SEARCH_CHILDREN, &v) == 0) {
|
if (int err = av_opt_get_int(ctx_option, option, AV_OPT_SEARCH_CHILDREN, &v); err != 0) {
|
||||||
LOG_INFO("[%s] %s: %s%s", context->codec->name, text.c_str(), v == 0 ? "Disabled" : "Enabled",
|
LOG_INFO("[%s] %s: <Error: %s>", ctx_codec->codec->name, text.c_str(),
|
||||||
av_opt_is_set_to_default_by_name(context, option, AV_OPT_SEARCH_CHILDREN) == 0 ? " <Default>" : "");
|
ffmpeg::tools::get_error_description(err));
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO("[%s] %s: <Error>", context->codec->name, text.c_str());
|
LOG_INFO("[%s] %s: %s%s", ctx_codec->codec->name, text.c_str(), v == 0 ? "Disabled" : "Enabled",
|
||||||
|
av_opt_is_set_to_default_by_name(ctx_option, option, AV_OPT_SEARCH_CHILDREN) > 0 ? " <Default>" : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tools::print_av_option_int(AVCodecContext* context, const char* option, std::string text, std::string suffix)
|
void tools::print_av_option_int(AVCodecContext* ctx_codec, const char* option, std::string text, std::string suffix)
|
||||||
{
|
{
|
||||||
int64_t v = 0;
|
print_av_option_int(ctx_codec, ctx_codec, option, text, suffix);
|
||||||
if (av_opt_get_int(context, option, AV_OPT_SEARCH_CHILDREN, &v) == 0) {
|
}
|
||||||
LOG_INFO("[%s] %s: %lld %s%s", context->codec->name, text.c_str(), v, suffix.c_str(),
|
|
||||||
av_opt_is_set_to_default_by_name(context, option, AV_OPT_SEARCH_CHILDREN) == 0 ? " <Default>" : "");
|
void ffmpeg::tools::print_av_option_int(AVCodecContext* ctx_codec, void* ctx_option, const char* option,
|
||||||
|
std::string text, std::string suffix)
|
||||||
|
{
|
||||||
|
int64_t v = 0;
|
||||||
|
bool is_default = av_opt_is_set_to_default_by_name(ctx_option, option, AV_OPT_SEARCH_CHILDREN) > 0;
|
||||||
|
if (int err = av_opt_get_int(ctx_option, option, AV_OPT_SEARCH_CHILDREN, &v); err != 0) {
|
||||||
|
if (is_default) {
|
||||||
|
LOG_INFO("[%s] %s: <Default>", ctx_codec->codec->name, text.c_str());
|
||||||
|
} else {
|
||||||
|
LOG_INFO("[%s] %s: <Error: %s>", ctx_codec->codec->name, text.c_str(),
|
||||||
|
ffmpeg::tools::get_error_description(err));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO("[%s] %s: <Error>", context->codec->name, text.c_str());
|
LOG_INFO("[%s] %s: %lld %s%s", ctx_codec->codec->name, text.c_str(), v, suffix.c_str(),
|
||||||
|
is_default ? " <Default>" : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tools::print_av_option_string(AVCodecContext* context, const char* option, std::string text,
|
void tools::print_av_option_string(AVCodecContext* ctx_codec, const char* option, std::string text,
|
||||||
std::function<std::string(int64_t)> decoder)
|
std::function<std::string(int64_t)> decoder)
|
||||||
|
{
|
||||||
|
print_av_option_string(ctx_codec, ctx_codec, option, text, decoder);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ffmpeg::tools::print_av_option_string(AVCodecContext* ctx_codec, void* ctx_option, const char* option,
|
||||||
|
std::string text, std::function<std::string(int64_t)> decoder)
|
||||||
{
|
{
|
||||||
int64_t v = 0;
|
int64_t v = 0;
|
||||||
if (av_opt_get_int(context, option, AV_OPT_SEARCH_CHILDREN, &v) == 0) {
|
if (int err = av_opt_get_int(ctx_option, option, AV_OPT_SEARCH_CHILDREN, &v); err != 0) {
|
||||||
|
LOG_INFO("[%s] %s: <Error: %s>", ctx_codec->codec->name, text.c_str(),
|
||||||
|
ffmpeg::tools::get_error_description(err));
|
||||||
|
} else {
|
||||||
std::string name = "<Unknown>";
|
std::string name = "<Unknown>";
|
||||||
if (decoder)
|
if (decoder)
|
||||||
name = decoder(v);
|
name = decoder(v);
|
||||||
LOG_INFO("[%s] %s: %s%s", context->codec->name, text.c_str(), name.c_str(),
|
LOG_INFO("[%s] %s: %s%s", ctx_codec->codec->name, text.c_str(), name.c_str(),
|
||||||
av_opt_is_set_to_default_by_name(context, option, AV_OPT_SEARCH_CHILDREN) == 0 ? " <Default>" : "");
|
av_opt_is_set_to_default_by_name(ctx_option, option, AV_OPT_SEARCH_CHILDREN) > 0 ? " <Default>" : "");
|
||||||
} else {
|
|
||||||
LOG_INFO("[%s] %s: <Error>", context->codec->name, text.c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,10 +60,15 @@ namespace ffmpeg::tools {
|
||||||
const char* get_thread_type_name(int thread_type);
|
const char* get_thread_type_name(int thread_type);
|
||||||
|
|
||||||
void print_av_option_bool(AVCodecContext* context, const char* option, std::string text);
|
void print_av_option_bool(AVCodecContext* context, const char* option, std::string text);
|
||||||
|
void print_av_option_bool(AVCodecContext* ctx_codec, void* ctx_option, const char* option, std::string text);
|
||||||
|
|
||||||
void print_av_option_int(AVCodecContext* context, const char* option, std::string text, std::string suffix);
|
void print_av_option_int(AVCodecContext* context, const char* option, std::string text, std::string suffix);
|
||||||
|
void print_av_option_int(AVCodecContext* ctx_codec, void* ctx_option, const char* option, std::string text,
|
||||||
|
std::string suffix);
|
||||||
|
|
||||||
void print_av_option_string(AVCodecContext* context, const char* option, std::string text,
|
void print_av_option_string(AVCodecContext* context, const char* option, std::string text,
|
||||||
std::function<std::string(int64_t)> decoder);
|
std::function<std::string(int64_t)> decoder);
|
||||||
|
void print_av_option_string(AVCodecContext* ctx_codec, void* ctx_option, const char* option, std::string text,
|
||||||
|
std::function<std::string(int64_t)> decoder);
|
||||||
|
|
||||||
} // namespace ffmpeg::tools
|
} // namespace ffmpeg::tools
|
||||||
|
|
Loading…
Reference in a new issue