Example of Using Intel IPP ZLIB Coding Functions

The following code example  demonstrates how the model of a compressor can be implemented using the Intel IPP ZLIB functions ippsEncodeLZ77_8u and ippsDecodeLZ77_8u and an arbitrary bit encoding/decoding methods for the pairs.

Using the ippsEncodeLZ77 and ippsDecodeLZ77 functions

#include <stdio.h>
#include <stdlib.h>
#include "ippdc.h"
#define BUFLEN 1000
...............
int 
main(int argc, char* argv[])    
{
    int len;
    int lenr;
    Ipp8u* pSrc;
    int srcLen;
    IppLZ77Pair* pDst;
    int dstLen;  
    IppLZ77Pair* pSrcr;
    int srcLenr;
    Ipp8u* pDstr;
    int dstLenr; 
    IppStatus status;
    IppLZ77State_8u* pLZ77State;
    ....................
    /* LZ77 encoding */
    status = ippsEncodeLZ77InitAlloc_8u(IppLZ77FastCompr, IppLZ77CRC32,
                                            &pLZ77State);
    /* Reading the srcLen bytes of input data from the input data file to pSrc */        
    ....................
    len = dstLen; 
    status = ippsEncodeLZ77_8u(&pSrc, &srcLen, &pDst, &dstLen,
                                 IppLZ77FinishFlush, pLZ77State);



    /* Here we have the array of Pairs in pDst of (len - dstLen)  */ 
    /* In this point the arbitrary bit coding method can be used, */
    /* for example LZSS algorithm.                                */
    ....................
    ....................
    /* Writing the compressed data to the output file             */
    ippsLZ77Free_8u(pLZ77State);
    /* LZ77 decoding */
    status = ippsDecodeLZ77InitAlloc_8u(IppLZ77CRC32, &pLZ77State);
    
    /* Reading the compressed data from the file                  */
    ....................
    /* On this point the bit decoding method, corresponding to the above   */
    /* selected bit encoding method (LZSS for example) must be used        */
    ....................
    ....................
    /* After bit decoding the pairs restored placed to the pSrcr of srcLenr */
    /*  for further performing of LZ77 decoding                             */
    lenr = dstLenr;  
    status = ippsDecodeLZ77_8u(&pSrcr, &srcLenr, &pDstr, &dstLenr,
                                 IppLZ77FinishFlush, pLZ77State); 
    /* Writing the (lenr - dstLenr) bytes of decompressed data to the output file */  
    ippsLZ77Free_8u(pLZ77State);
   
    return 0;
} /* main */




Submit feedback on this help topic

Copyright © 2000 - 2011, Intel Corporation. All rights reserved.