From 5c716ef1d1ed1962ffe2470a6d702759718f9875 Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Thu, 29 Nov 2012 19:04:12 +1100 Subject: Compress as blocks. The LZ77 compressor works with blocks. Each block is prefixed with a header that defines the output size of the block being compressed. --- rld-compression.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'rld-compression.h') diff --git a/rld-compression.h b/rld-compression.h index c6370dc..accc177 100644 --- a/rld-compression.h +++ b/rld-compression.h @@ -93,6 +93,14 @@ namespace rld size_t compressed () const; private: + + /** + * Output the block of data to the output file with the block header. + * + * @param forced If true output the buffer. + */ + void output (bool forced = false); + files::image& image; //< The image to read or write to or from. size_t size; //< The size of the buffer. bool compress; //< If true compress the data. @@ -114,7 +122,7 @@ namespace rld uint8_t bytes[sizeof (T)]; T v = value; int b = sizeof (T) - 1; - while (b > 0) + while (b >= 0) { bytes[b--] = (uint8_t) v; v >>= 8; -- cgit v1.2.3