home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
lzo100.zip
/
lzo-1.00
/
doc
/
LZO.FAQ
< prev
next >
Wrap
Text File
|
1997-07-11
|
7KB
|
188 lines
============================================================================
LZO Frequently Asked Questions
============================================================================
Can you explain the naming conventions of the algorithms ?
==========================================================
Let's take a look at LZO1X:
The algorithm name is LZO1X.
The algorithm category is LZO1.
Various compression levels are implemented.
LZO1X-999
!---------- algorithm category
!--------- algorithm type
!!!----- compression level (1-9, 99, 999)
LZO1X-1(11)
!---------- algorithm category
!--------- algorithm type
!------- compression level (1-9, 99, 999)
!!---- memory level (memory requirements for compression)
All compression/memory levels generate the same compressed data format,
so e.g. the LZO1X decompressor handles all LZO1X-* compression levels
(for more information about the decompressors see below).
Category LZO1 algorithms: compressed data format is strictly byte aligned
Category LZO2 algorithms: uses bit-shifting, slower decompression
Why are there so many algorithms ?
==================================
Because of historical reasons - I want to support unlimited
backwards compatibility.
Don't get misleaded by the size of the library - using one algorithm
increases the size of your application by only a few kB.
If you just want too add a little bit of data compression to your
application you may be looking for miniLZO.
See minilzo/00readme.txt for more information.
Which algorithm should I use ?
==============================
LZO1X seems to be best choice in many cases, so:
- when going for speed use LZO1X-1
- when generating pre-compressed data use LZO1X-999
- if you have little memory available for compression use LZO1X-1(11)
Of course, your mileage may vary, and you are encouraged to run your
own experiments. Try LZO1Y and LZO1F next.
You can also try LZO1X-1(15) if you need even a little bit more
compression speed.
What's the difference beetween the decompressors per algorithm ?
================================================================
Once again let's use LZO1X for explanation:
- lzo1x_decompress
The `standard' decompressor. Pretty fast - use this whenever possible.
This decompressor expects valid compressed data.
If the compressed data gets corrupted somehow (e.g transmission
via an errornous channel, disk errors, ...) it will probably crash
your application because absolutely no additional checks are done.
- lzo1x_decompress_safe
The `safe' decompressor. Somewhat slower.
This decompressor will catch all compressed data violations and
return an error code in this case - it will never crash.
- lzo1x_decompress_asm
Same as lzo1x_decompress - written in assembler.
- lzo1x_decompress_asm_safe
Same as lzo1x_decompress_safe - written in assembler.
- lzo1x_decompress_asm_fast
Similiar to lzo1x_decompress_asm - but even faster.
For reasons of speed this decompressor can write 1 to 3 bytes
past the end of the decompressed (output) block.
Use this when you are decompressing from one memory block to
another memory block - just provide output space for 3 extra bytes.
You shouldn't use it if e.g. you are directly decompressing to video
memory (because the extra bytes will be visible on screen).
- lzo1x_decompress_asm_fast_safe
This is the safe version of lzo1x_decompress_asm_fast.
Notes:
------
- When using a safe decompressor you must pass the number of
bytes available in `dst' via the parameter `dst_len'.
- If you want to be sure that your data is not corrupted you must
use a checksum - just using the safe decompressor is not enough,
because many data errors will not result in a compressed data violation.
- Assembler versions are only available for the i386 family yet.
- You should test if the assembler decompressors are actually faster
than the C version on your machine - some compilers (like Watcom C)
can do a very good optimization job and they also can optimize the code
for a specific processor like the PentiumPro.
What is this optimization thing ?
=================================
The compressors use a heuristic approach - they sometimes code
information that doesn't improve compression ratio.
Optimization removes this superfluos information in order to
increase decompression speed.
Optimization works similiar to decompression except that the
compressed data is modified as well. The lenght of the compressed
data block will not change - only the compressed data-bytes will
get rearranged a little bit.
Don't expect too much, though - my tests have shown that the
optimization step improves decompression speed by about 1-3%.
I need even more decompression speed...
=======================================
Many modern processors (DEC Alpha, MIPS, ...) can transfer 32bit words
much faster than bytes - this can significantly speed up decompression.
So after verifying that everything works fine you can try if activating
the LZO_ALIGNED_OK_4 macro improves LZO1X and LZO1Y decompression
performance. Change the file config.h accordingly and recompile everything.
On a i386/i486/Pentium you should definitely use the assembler versions.
Can you give a cookbook for using pre-compressed data ?
=======================================================
Let's assume you use LZO1X-999.
1) pre-compression step
- call lzo_init()
- call lzo1x_999_compress()
- call lzo1x_optimize()
- compute an adler32 checksum of the *compressed* data
- store the compressed data and the checksum in a file
- if you are paranoid you can verify decompression now
2) decompression step within your application
- call lzo_init()
- load your compressed data and the checksum
- verify the checksum of the compressed data
(so that you can use the standard decompressor)
- decompress
How much can my data expand during compression ?
================================================
LZO will expand incompressible data by a little amount.
I still haven't computed the exact values, but I suggest these
formulas for a worst-case expansion calculation:
LZO1* algorithms:
-----------------
output_block_size = input_block_size + (input_block_size / 64) + 16 + 3
This is about 101.6% for a large block size.
LZO2* algorithms:
-----------------
output_block_size = input_block_size + (input_block_size / 8) + 128 + 3