[GRASS-dev] Grass SVN in Android, display issue

Sören Gebbert soerengebbert at googlemail.com
Sun Sep 23 13:06:23 PDT 2012


Hi Glynn,

2012/9/23 Glynn Clements <glynn at gclements.plus.com>:
>
> Sören Gebbert wrote:
>
>> i have tested the raster3d library and most of the related modules intensively.
>> I rediscovered an ugly bug in the 3D raster run length encoding (RLE)
>> compression implementation  and modified the library test to catch it.
>> I am unable to fix the RLE compression bug.
>
> Can you elaborate on this RLE bug?

As far as i understand the RLE encoding/decoding algorithm in
lib/raster3d/rle.c is buggy.
The functions rle_length2code() and rle_code2length implement wrong
length computation for strings larger than 129031 characters.
I have put some comments in the code.

The length computation:
length = 254 ^ c + 254 * b + a; b, a < 254
works only for c <= 2. For c == 3 the implementation should be:
length = 254 ^ 3 + 254 ^ 2 * c + 254 * b + a; c, b, a < 254

You can reproduce the bug with the test in lib/raster3d/test. Simply
compile the test and call it.

Setting the maximum tile size to 2048KB using RLE and LZ77 compression
(-rl) fails:
test.g3d.lib unit=large rows=130 cols=100 depths=100 tile=2048 -rl

When disabling RLE, enabling LZ77 compression only the test succeeds:
test.g3d.lib unit=large rows=130 cols=100 depths=100 tile=2048 -l

The RLE bug does not appear when the tile size is 1024KB:
test.g3d.lib unit=large rows=130 cols=100 depths=100 tile=1024 -lr


However, i do not understand the advantage of having RLE first and a
LZ77 or LZ78 compression afterwards.
Shouldn't be the LZ77/78 compression sufficient for compression of
float/double values?

>
>> But it seems to me that
>> the existing
>> LZW tile compression is sufficient without using RLE. As consequence i
>> have switched off the use of RLE, only compression using LZW  is now
>> supported.
>
> The raster3d library uses zlib (LZ77) compression, not LZW. It has a
> compile-time option to use LZW, but the relevant G_lzw_* functions
> don't exist.

Oh well, i did not know that the G_lzw_* functions don't exist.
Its a bit confusing that the option that switches on the LZ77
compression is called RASTER3D_USE_LZW ... .

Best regards
Soeren

>
> --
> Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list