From 7f7651b405368500ce28405ddf64f6968e05dc4f Mon Sep 17 00:00:00 2001 From: tt2468 Date: Sat, 24 Jul 2021 20:48:44 -0700 Subject: [PATCH] Utils: Attempt fix output timecode string --- src/utils/Obs.cpp | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/utils/Obs.cpp b/src/utils/Obs.cpp index 97f6d682..a3e3d702 100644 --- a/src/utils/Obs.cpp +++ b/src/utils/Obs.cpp @@ -1,7 +1,4 @@ #include -#include -#include -#include #include #include @@ -11,17 +8,6 @@ #define CASE(x) case x: return #x; -template -std::string string_format( const std::string& format, Args ... args ) -{ - int size_s = std::snprintf( nullptr, 0, format.c_str(), args ... ) + 1; - if( size_s <= 0 ){ throw std::runtime_error( "Error during formatting." ); } - auto size = static_cast( size_s ); - auto buf = std::make_unique( size ); - std::snprintf( buf.get(), size, format.c_str(), args ... ); - return std::string( buf.get(), buf.get() + size - 1 ); // We don't want the '\0' inside -} - std::vector ConvertStringArray(char **array) { std::vector ret; @@ -132,7 +118,7 @@ std::string Utils::Obs::StringHelper::GetOutputTimecodeString(obs_output_t *outp uint64_t frameTimeNs = video_output_get_frame_time(video); int totalFrames = obs_output_get_total_frames(output); - uint64_t ms = (((uint64_t)totalFrames) * frameTimeNs) / 1000000ULL; + uint64_t ms = util_mul_div64(totalFrames, frameTimeNs, 1000000ULL); uint64_t secs = ms / 1000ULL; uint64_t minutes = secs / 60ULL; @@ -141,7 +127,8 @@ std::string Utils::Obs::StringHelper::GetOutputTimecodeString(obs_output_t *outp uint64_t secsPart = secs % 60ULL; uint64_t msPart = ms % 1000ULL; - return string_format("%02" PRIu64 ":%02" PRIu64 ":%02" PRIu64 ".%03" PRIu64, hoursPart, minutesPart, secsPart, msPart); + QString formatted = QString::asprintf("%02" PRIu64 ":%02" PRIu64 ":%02" PRIu64 ".%03" PRIu64, hoursPart, minutesPart, secsPart, msPart); + return formatted.toStdString(); } uint64_t Utils::Obs::NumberHelper::GetOutputDuration(obs_output_t *output) @@ -154,7 +141,6 @@ uint64_t Utils::Obs::NumberHelper::GetOutputDuration(obs_output_t *output) int totalFrames = obs_output_get_total_frames(output); return util_mul_div64(totalFrames, frameTimeNs, 1000000ULL); - //return (((uint64_t)totalFrames) * frameTimeNs) / ; } std::vector Utils::Obs::ListHelper::GetSceneCollectionList()