diff --git a/ImGuiToolkit.cpp b/ImGuiToolkit.cpp index 7a41f62..ad19173 100644 --- a/ImGuiToolkit.cpp +++ b/ImGuiToolkit.cpp @@ -25,6 +25,7 @@ #include "GstToolkit.h" #include "SystemToolkit.h" + unsigned int textureicons = 0; std::map fontmap; @@ -870,6 +871,7 @@ void ImGuiToolkit::ShowStats(bool *p_open, int* p_corner, bool *p_timer) ImGui::Text("Refresh %.1f FPS", io.Framerate); ImGui::Text("Memory %s", SystemToolkit::byte_to_string( SystemToolkit::memory_usage()).c_str() ); ImGui::PopFont(); + } if (ImGui::BeginPopupContextWindow()) @@ -884,6 +886,24 @@ void ImGuiToolkit::ShowStats(bool *p_open, int* p_corner, bool *p_timer) } } +// BHBN : TODO stats on video decoding : would be useful if we could know which is HW or SW decoder +//#include "MediaPlayer.h" +//ImGuiToolkit::PushFont(ImGuiToolkit::FONT_MONO); +//uint bitrate_ = 0; +//uint pixels_ = 0; +//uint videos_ = 0; +//uint images_ = 0; +//for (auto it = MediaPlayer::begin(); it != MediaPlayer::end(); it++) +//{ +// MediaInfo info = (*it)->media(); +// bitrate_ += info.bitrate; +// pixels_ += info.height * info.width * 4; +// if (info.isimage) images_++; else videos_++; +//} +//ImGui::Text("%d video%s %d image%s", videos_, videos_>1?"s":" ", images_, images_>1?"s":" "); +//ImGui::Text("Bitrate %s/s", SystemToolkit::bits_to_string( bitrate_ ).c_str() ); +//ImGui::Text("Texture %s", SystemToolkit::byte_to_string( pixels_ ).c_str() ); +//ImGui::PopFont(); void ImGuiToolkit::WindowText(const char* window_name, ImVec2 window_pos, const char* text) { diff --git a/SystemToolkit.cpp b/SystemToolkit.cpp index ce2abee..eeaafc8 100644 --- a/SystemToolkit.cpp +++ b/SystemToolkit.cpp @@ -109,6 +109,24 @@ string SystemToolkit::byte_to_string(long b) return oss.str(); } +string SystemToolkit::bits_to_string(long b) +{ + double numbytes = static_cast(b); + ostringstream oss; + + std::list list = {" bit", " Kbit", " Mbit", " Gbit", " Tbit"}; + std::list::iterator i = list.begin(); + + while(numbytes >= 1000.0 && i != list.end()) + { + i++; + numbytes /= 1000.0; + } + oss << std::fixed << std::setprecision(2) << numbytes << *i; + return oss.str(); +} + + string SystemToolkit::date_time_string() { diff --git a/SystemToolkit.h b/SystemToolkit.h index f0bd0fe..a9ee644 100644 --- a/SystemToolkit.h +++ b/SystemToolkit.h @@ -76,6 +76,9 @@ namespace SystemToolkit // get a string to display memory size with unit KB, MB, GB, TB std::string byte_to_string(long b); + // get a string to display bit size with unit Kbit, MBit, Gbit, Tbit + std::string bits_to_string(long b); + // get a transliteration to Latin of any string std::string transliterate(std::string input); }