From db1b60f020627708240c9ce26bbc350ff8015f81 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Sun, 28 Aug 2022 15:49:21 +0200 Subject: [PATCH] ffmpeg/tools: Revert #836 It is not valid to pass std::string_view to snprintf's %s. --- source/ffmpeg/tools.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/source/ffmpeg/tools.cpp b/source/ffmpeg/tools.cpp index fc65be428e..7f94303b5e 100644 --- a/source/ffmpeg/tools.cpp +++ b/source/ffmpeg/tools.cpp @@ -367,10 +367,11 @@ void tools::print_av_option_bool(AVCodecContext* ctx_codec, void* ctx_option, co { int64_t v = 0; if (int err = av_opt_get_int(ctx_option, option, AV_OPT_SEARCH_CHILDREN, &v); err != 0) { - DLOG_INFO("[%s] %s: ", ctx_codec->codec->name, text, + DLOG_INFO("[%s] %s: ", ctx_codec->codec->name, text.data(), streamfx::ffmpeg::tools::get_error_description(err)); } else { - DLOG_INFO("[%s] %s: %s%s", ctx_codec->codec->name, text, (inverse ? v != 0 : v == 0) ? "Disabled" : "Enabled", + DLOG_INFO("[%s] %s: %s%s", ctx_codec->codec->name, text.data(), + (inverse ? v != 0 : v == 0) ? "Disabled" : "Enabled", av_opt_is_set_to_default_by_name(ctx_option, option, AV_OPT_SEARCH_CHILDREN) > 0 ? " " : ""); } } @@ -388,13 +389,14 @@ void tools::print_av_option_int(AVCodecContext* ctx_codec, void* ctx_option, con 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) { - DLOG_INFO("[%s] %s: ", ctx_codec->codec->name, text); + DLOG_INFO("[%s] %s: ", ctx_codec->codec->name, text.data()); } else { - DLOG_INFO("[%s] %s: ", ctx_codec->codec->name, text, + DLOG_INFO("[%s] %s: ", ctx_codec->codec->name, text.data(), streamfx::ffmpeg::tools::get_error_description(err)); } } else { - DLOG_INFO("[%s] %s: %" PRId64 " %s%s", ctx_codec->codec->name, text, v, suffix, is_default ? " " : ""); + DLOG_INFO("[%s] %s: %" PRId64 " %s%s", ctx_codec->codec->name, text.data(), v, suffix.data(), + is_default ? " " : ""); } } @@ -409,13 +411,13 @@ void tools::print_av_option_string(AVCodecContext* ctx_codec, void* ctx_option, { int64_t v = 0; if (int err = av_opt_get_int(ctx_option, option, AV_OPT_SEARCH_CHILDREN, &v); err != 0) { - DLOG_INFO("[%s] %s: ", ctx_codec->codec->name, text, + DLOG_INFO("[%s] %s: ", ctx_codec->codec->name, text.data(), streamfx::ffmpeg::tools::get_error_description(err)); } else { std::string name = ""; if (decoder) name = decoder(v); - DLOG_INFO("[%s] %s: %s%s", ctx_codec->codec->name, text, name.c_str(), + DLOG_INFO("[%s] %s: %s%s", ctx_codec->codec->name, text.data(), name.c_str(), av_opt_is_set_to_default_by_name(ctx_option, option, AV_OPT_SEARCH_CHILDREN) > 0 ? " " : ""); } }