TABLE OF CONTENTS

BCL

[ Top ] [ Modules ]

DESCRIPTION

 From the BCL-Documentation:
 The Basic Compression Library is a set of open source implementations of several well known lossless
 Compression algorithms, such As Huffman And RLE, written in portable ANSI c.
 The Library itself is Not intended To serve As a competitor To advanced general purpose Compression
 tools, but rather As a reference Or a set of building blocks For custom Compression algorithms.
 An example of a field where customized Compression algorithms can be be useful is The Compression of
 digitized media (such As images Or audio), For which you usually have lots of apriori information, And
 can tailor An efficient method based on entropy reduction (e.g. differentiation) followed by simple
 entropy coding (e.g. Huffman coding).
 in many cases entropy reduction results in Data that is Not easily compressed With advanced dictionary
 based general purpose entropy coders, such As gzip Or bzip2, since Data often becomes very noisy after
 entropy reduction. Even a simple Huffman coder can give better Compression results than The most
 advanced dictionary based coders under these circumstances.

 For usage in Purebasic :
 I found this nice Library, and made it avaiable for PureBaic. I think ther is allways a need for it.
 The Library is compiled as a 'static library' and imported with the Import-Feature of PureBasic.
 
 I choose a 'Structure' to deploy the Library, that i found with a bunch of Includes from ts-soft.
 So you have not much work to use it, and it is also easy to actualize.

 Why not as User-Lib ? 
   I have bad experiences with UserLibs. It is also more work to make it available. 
   If you want this as UserLib, you have to change the Sources - what is bad at first, write
   write a Import-definition-File. And Use the Library-Maker from PB. Good Luck !

 Examples ?
   I provide only one example (Huffman-Compile) in this Doku. But there als 2 Example for Usage 
   as Source-Code. Please use them to learn. And also use the BCL-Library-Doku if you want to know
   more about the Compression-Algorithms.

Huffman_Compress

[ Top ] [ BCL ] [ Functions ]

NAME

    Huffman_Compress - Compress with Huffman-Algorithm

SYNOPSIS

  ;    outsize.l = Huffman_Compress(*in.l,*out.l,insize.l)

INPUTS

  *in .l     - Pointer to the input buffer (uncompressed Data)
  *out.l    - Pointer to the output buffer (compressed Data)
  insize.l - Size of input Buffer

RESULTS

   outsize.l  -   outsize Size of output Buffer after compression

FUNCTION

   Compress the Data with the Huffman-Alorithm.
  the output Buffer must be able To hold insize × (101/ 100) + 320 Bytes.

EXAMPLE

; XIncludeFile #PB_Compiler_Home + "Includes\Imports\BCL_Import.pbi"
; 
; filename.s="test.dat"
; insize.l = FileSize(filename)
; If insize > 0
;   *in.l = AllocateMemory(insize)
;   fp.l = OpenFile(#PB_Any,filename) 
;   If fp 
;     ReadData(fp,*in,insize)
;     CloseFile(fp)
; 
;     outbuflen.l = insize*(101/100) + 320
;     *out = AllocateMemory(outbuflen)
;     outlen.l = Huffman_Compress(*in,*out,insize) 
; 
;   EndIf
;   FreeMemory(*in)
; EndIf

NOTES

Huffman_Uncompress

[ Top ] [ BCL ] [ Functions ]

NAME

    Huffman_Uncompress - Uncompress with Huffman-Algorithm

SYNOPSIS

;    Huffman_Uncompress(*in.l,*out.l,insize.l,outsize.l)

INPUTS

  *in .l     - Pointer to the input buffer (uncompressed Data)
  *out.l    - Pointer to the output buffer (compressed Data)
  insize.l - Size of input Buffer
  outsize.l - Size of output Buffer

RESULTS

   nothing

FUNCTION

   Compress the Data with the Huffman-Alorithm.
  The output buffer must be able to hold outsize bytes.

EXAMPLE

NOTES

LZ_Compress

[ Top ] [ BCL ] [ Functions ]

NAME

    LZ_Compress - Compress with LZ-Algorithm

SYNOPSIS

;    outsize.l = LZ_Compress(*in.l,*out.l,insize.l)

INPUTS

  *in .l     - Pointer to the input buffer (uncompressed Data)
  *out.l    - Pointer to the output buffer (compressed Data)
  insize.l - Size of input Buffer

RESULTS

   outsize.l  -   outsize Size of output Buffer after compression

FUNCTION

   Compress the Data with the LZ-Algorithm.
  The output buffer must be able to hold insize × (257/256) + 1 Bytes.

EXAMPLE

NOTES

LZ_CompressFast

[ Top ] [ BCL ] [ Functions ]

NAME

    LZ_CompressFast - Compress with LZ-Algorithm

SYNOPSIS

;    outsize.l = LZ_CompressFast(*in.l,*out.l,insize.l,*Work.l)

INPUTS

  *in .l     - Pointer to the input buffer (uncompressed Data)
  *out.l    - Pointer to the output buffer (compressed Data)
  insize.l - Size of input Buffer
 *Work.l - Pointer to a temporary buffer (internal working buffer)

RESULTS

   outsize.l  -   outsize Size of output Buffer after compression

FUNCTION

   Compress the Data with the LZ-Algorithm.
  The output buffer must be able to hold insize × (257/256) + 1 Bytes, And the work Buffer must be able To hold
   insize + 65536 unsigned integers.

EXAMPLE

NOTES

LZ_Uncompress

[ Top ] [ BCL ] [ Functions ]

NAME

    LZ_Uncompress - Uncompress with LZ-Algorithm

SYNOPSIS

;    LZ_Uncompress(*in.l,*out.l,insize.l)

INPUTS

  *in .l     - Pointer to the input buffer (uncompressed Data)
  *out.l    - Pointer to the output buffer (compressed Data)
  insize.l - Size of input Buffer

RESULTS

   nothing

FUNCTION

   Unompress the Data with the LZ-Algorithm.
  The output buffer must be able to hold the entire uncompressed data stream.

EXAMPLE

NOTES

Rice_Compress

[ Top ] [ BCL ] [ Functions ]

NAME

    Rice_Compress - Compress with Rice-Algorithm

SYNOPSIS

;    outsize.l = Rice_Compress(*in.l,*out.l,insize.l,format.l)

INPUTS

  *in .l     - Pointer to the input buffer (uncompressed Data)
  *out.l    - Pointer to the output buffer (compressed Data)
  insize.l; - Size of input Buffer
  format.l - One of the following Formats (Constants) :
               #BCL_RICE_FMT_INT8    -  signed 8-bit integer 
               #BCL_RICE_FMT_UINT8  - unsigned 8-bit integer 
               #BCL_RICE_FMT_INT16  - signed 16-bit integer 
               #BCL_RICE_FMT_UINT16  - unsigned 16-bit integer 
               #BCL_RICE_FMT_INT32  - signed 32-bit integer 
               #BCL_RICE_FMT_UINT32  - unsigned 32-bit integer ;     

RESULTS

   outsize.l  -   outsize Size of output Buffer after compression

FUNCTION

   Compress the Data with the Rice-Algorithm.
  The output buffer must be able to hold insize + 1 bytes.

EXAMPLE

NOTES

Rice_Uncompress

[ Top ] [ BCL ] [ Functions ]

NAME

    Rice_Uncompress - Uncompress with Rice-Algorithm

SYNOPSIS

;    Rice_Uncompress(*in.l,*out.l,insize.l,outsize.l, format.l)

INPUTS

  *in .l     - Pointer to the input buffer (uncompressed Data)
  *out.l    - Pointer to the output buffer (compressed Data)
  insize.l - Size of input Buffer
  outsize.l - Size of output Buffer
  format.l - One of the following Formats (Constants) :
               #BCL_RICE_FMT_INT8    -  signed 8-bit integer 
               #BCL_RICE_FMT_UINT8  - unsigned 8-bit integer 
               #BCL_RICE_FMT_INT16  - signed 16-bit integer 
               #BCL_RICE_FMT_UINT16  - unsigned 16-bit integer 
               #BCL_RICE_FMT_INT32  - signed 32-bit integer 
               #BCL_RICE_FMT_UINT32  - unsigned 32-bit integer ;     

RESULTS

   nothing

FUNCTION

   Unompress the Data with the Rice-Algorithm.
  The output buffer must be able to hold outsize bytes.

EXAMPLE

NOTES

RLE_Compress

[ Top ] [ BCL ] [ Functions ]

NAME

    RLE_Compress - Compress with RLE-Algorithm

SYNOPSIS

;    outsize.l = RLE_Compress(*in.l,*out.l,insize.l)

INPUTS

  *in .l     - Pointer to the input buffer (uncompressed Data)
  *out.l    - Pointer to the output buffer (compressed Data)
  insize.l; - Size of input Buffer

RESULTS

   outsize.l  -   outsize Size of output Buffer after compression

FUNCTION

   Compress the Data with the RLE-Algorithm.
  The output buffer must be able to hold insize × (257/256) + 1 Bytes.

EXAMPLE

NOTES

RLE_Uncompress

[ Top ] [ BCL ] [ Functions ]

NAME

    RLE_Uncompress - Uncompress with RLE-Algorithm

SYNOPSIS

;    RLE_Uncompress(*in.l,*out.l,insize.l)

INPUTS

  *in .l     - Pointer to the input buffer (uncompressed Data)
  *out.l    - Pointer to the output buffer (compressed Data)
  insize.l - Size of input Buffer

RESULTS

   nothing

FUNCTION

   Unompress the Data with the RLE-Algorithm.
  The output buffer must be able to hold outsize bytes.

EXAMPLE

NOTES

SF_Compress

[ Top ] [ BCL ] [ Functions ]

NAME

    SF_Compress - Compress with Shannon-Fano-Algorithm

SYNOPSIS

;    outsize.l = SF_Compress(*in.l,*out.l,insize.l)

INPUTS

  *in .l     - Pointer to the input buffer (uncompressed Data)
  *out.l    - Pointer to the output buffer (compressed Data)
  insize.l - Size of input Buffer

RESULTS

   outsize.l  -   outsize Size of output Buffer after compression

FUNCTION

   Compress the Data with the Shannon-Fano-Algorithm.
  the output Buffer must be able To hold insize × (101/ 100) + 384 Bytes.

EXAMPLE

NOTES

SF_Uncompress

[ Top ] [ BCL ] [ Functions ]

NAME

    SF_Uncompress - Uncompress with Shannon-Fano-Algorithm

SYNOPSIS

;    SF_Uncompress(*in.l,*out.l,insize.l,outsize.l)

INPUTS

  *in .l     - Pointer to the input buffer (uncompressed Data)
  *out.l    - Pointer to the output buffer (compressed Data)
  insize.l - Size of input Buffer
  outsize.l - Size of output Buffer

RESULTS

   nothing

FUNCTION

   Unompress the Data with the Shannon-Fano-Algorithm.
  The output buffer must be able to hold outsize bytes.

EXAMPLE

NOTES