diff --git a/include/views/view_information.hpp b/include/views/view_information.hpp index 31dcf1c0e..c8c704987 100644 --- a/include/views/view_information.hpp +++ b/include/views/view_information.hpp @@ -23,6 +23,7 @@ namespace hex { prv::Provider* &m_dataProvider; bool m_windowOpen = true; + u32 m_blockSize = 0; float m_averageEntropy = 0; float m_highestBlockEntropy = 0; std::vector m_blockEntropy; diff --git a/source/views/view_information.cpp b/source/views/view_information.cpp index 406fd285e..2d6202c58 100644 --- a/source/views/view_information.cpp +++ b/source/views/view_information.cpp @@ -55,19 +55,20 @@ namespace hex { if (this->m_shouldInvalidate) { { - std::vector buffer(512, 0x00); + this->m_blockSize = std::ceil(this->m_dataProvider->getSize() / 2048.0F); + std::vector buffer(this->m_blockSize, 0x00); std::memset(this->m_valueCounts.data(), 0x00, this->m_valueCounts.size() * sizeof(u32)); this->m_blockEntropy.clear(); - for (u64 i = 0; i < this->m_dataProvider->getSize(); i += 512) { + for (u64 i = 0; i < this->m_dataProvider->getSize(); i += this->m_blockSize) { std::array blockValueCounts = { 0 }; - this->m_dataProvider->read(i, buffer.data(), std::min(size_t(512), this->m_dataProvider->getSize() - i)); + this->m_dataProvider->read(i, buffer.data(), std::min(size_t(this->m_blockSize), this->m_dataProvider->getSize() - i)); - for (u16 j = 0; j < 512; j++) { + for (size_t j = 0; j < this->m_blockSize; j++) { blockValueCounts[buffer[j]]++; this->m_valueCounts[buffer[j]]++; } - this->m_blockEntropy.push_back(calculateEntropy(blockValueCounts, 512)); + this->m_blockEntropy.push_back(calculateEntropy(blockValueCounts, this->m_blockSize)); } this->m_averageEntropy = calculateEntropy(this->m_valueCounts, this->m_dataProvider->getSize()); @@ -138,6 +139,7 @@ namespace hex { ImGui::NewLine(); + ImGui::LabelText("Block size", "2048 blocks à %lu bytes", this->m_blockSize); ImGui::LabelText("Average entropy", "%.8f", this->m_averageEntropy); ImGui::LabelText("Highest entropy block", "%.8f", this->m_highestBlockEntropy);