From 5183131b69e400d1ea75cc6b4e06883800442bd0 Mon Sep 17 00:00:00 2001 From: Joshua Scott Date: Sat, 20 Oct 2018 12:59:39 +0100 Subject: [PATCH] util: Base BitStream buffer expansion on the current position rather than the buffer size --- src/util/BitStream.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/BitStream.cpp b/src/util/BitStream.cpp index 9163b63..61f9b5c 100644 --- a/src/util/BitStream.cpp +++ b/src/util/BitStream.cpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace ki { @@ -148,7 +149,7 @@ namespace ki void BitStream::expand_buffer() { // Work out a new buffer size - auto new_size = (m_buffer_size << 1) + 2; + auto new_size = (2 << (uint64_t)log2(m_position.get_byte())) + 2; if (new_size < m_buffer_size) new_size = std::numeric_limits::max();