<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Before it can be useful, however, I need input about the API design.<br>
The plan is to have a low-level C++ template based compression<br>
library, allowing to code raw 8/16 bit RGB(A) pixel image data from/to<br>
memory, where the layout of the pixels (RGB vs. BGR, ARGB vs. RGBA,<br>
etc.) and the resulting code stream (bytes vs. machine words) can be<br>
customized via custom templates or template arguments.<br></blockquote><div><br>I can tell what we currently have. <br><br>Swapping<br>We have tiling, pooling and swapping at the level higher than the compression itself. Every tile, which is 64 by 64 pixels is compressed independently. The compressed data is written to a file mapped to RAM and OS decides when this mapped data should be actually swapped out to the hard drive. Of course the size of the mapped region is limited so the data is flushed automatically when the "sliding window" of the mapped region moves forward in the file. The size of the window is 16 MiB. It is chosen in consideration to house 8-bit RGBA image of size 2048x2048 pixels (not counting the reduction of size due to compression). No benchmarks were actually done, so the size of the window might be not optimal. Actually, I think we can make this window larger on modern machines, but I haven't finished the benchmark yet.<br>
<br>Compression<br>For the actual compression of the tile data we use LZF algorithm. I did some research on the compression times of LZO and LZF [0], [1]. It turned out that LZF has better times. It takes twice faster to compress the image with LZF while keeping almost the same compression rate. One more thing I found then is that it is faster to "linearize" colors before compression and then compress the image than compress the image directly (RGBARGBA -> RRGGBBAA). It boosts both the speed and the compression rate. The time of the "linearization" itself is negligible in comparison with the boost it give, so now we do it this way.<br>
<br>API<br>The compression is done at the level of the datamanager so it doesn't know the colorspace we work in. It knows the size of a tile and the size of a pixel. The algorithm is split into two classes:  KisTileCompressor2 [2] and KisLzfCompression<span class="br0"></span> [3]. The benchmarks are placed in [4].<br>
<br><br>[0] - <a href="http://dimula73.narod.ru/lzo_vs_lzf.pdf">http://dimula73.narod.ru/lzo_vs_lzf.pdf</a><br>       In "Linearized" column you see the total time of linearization + compression.<br><br>[1] - <a href="http://markmail.org/message/enjpz5lyiohy2y3k#query:+page:1+mid:enjpz5lyiohy2y3k+state:results">http://markmail.org/message/enjpz5lyiohy2y3k#query:+page:1+mid:enjpz5lyiohy2y3k+state:results</a><br clear="all">
</div></div><br>[2] - <a href="http://quickgit.kde.org/index.php?p=calligra.git&a=blob&h=c46843999c159f88553e1846e7d4681e375a7e3c&hb=194ee7c39975e0be1ce37bb9394456290b326019&f=krita%2Fimage%2Ftiles3%2Fswap%2Fkis_tile_compressor_2.cpp">http://quickgit.kde.org/index.php?p=calligra.git&a=blob&h=c46843999c159f88553e1846e7d4681e375a7e3c&hb=194ee7c39975e0be1ce37bb9394456290b326019&f=krita%2Fimage%2Ftiles3%2Fswap%2Fkis_tile_compressor_2.cpp</a><br>
[3] - <a href="http://quickgit.kde.org/index.php?p=calligra.git&a=blob&h=13910830b29418a81407078619a0c47e8d794d63&hb=194ee7c39975e0be1ce37bb9394456290b326019&f=krita%2Fimage%2Ftiles3%2Fswap%2Fkis_lzf_compression.cpp">http://quickgit.kde.org/index.php?p=calligra.git&a=blob&h=13910830b29418a81407078619a0c47e8d794d63&hb=194ee7c39975e0be1ce37bb9394456290b326019&f=krita%2Fimage%2Ftiles3%2Fswap%2Fkis_lzf_compression.cpp</a><br>
[4] - <a href="http://quickgit.kde.org/index.php?p=calligra.git&a=blob&h=13910830b29418a81407078619a0c47e8d794d63&hb=194ee7c39975e0be1ce37bb9394456290b326019&f=krita%2Fimage%2Ftiles3%2Fswap%2Fkis_lzf_compression.cpp">http://quickgit.kde.org/index.php?p=calligra.git&a=blob&h=13910830b29418a81407078619a0c47e8d794d63&hb=194ee7c39975e0be1ce37bb9394456290b326019&f=krita%2Fimage%2Ftiles3%2Fswap%2Fkis_lzf_compression.cpp</a><br>
<br>-- <br>Dmitry Kazakov<br>