DecodeLZSS

Performs LZSS decoding.

Syntax

IppStatus ippsDecodeLZSS_8u (Ipp8u* ppSrc, int* pSrcLen, Ipp8u*8 ppDst, int* pDstLen, IppLZSSState_8u* pLZSSState);

Parameters

ppSrc

Double pointer to the source buffer.

pSrcLen

Pointer to the length of the source buffer.

ppDst

Double pointer to the destination buffer.

pDstLen

Pointer to the length of the destination buffer.

pLZSSState

Pointer to the LZSS decoding state structure.

Description

The function ippsDecodeLZSS is declared in the ippdc.h file. This function performs LZSS decoding of the pSrcLen elements of the ppSrc source buffer and stores the result in the pDst destination vector. The length of the destination vector is stored in pDstLen. The LZSS decoder state structure pLZSSState must be initialized by the functions ippsDecodeLZSSInitAlloc or ippsDecodeLZSSInit beforehand.

After decoding the function returns the pointers to source and destination buffers shifted by the number of successfully read and decoded bytes respectively. The function updates pSrcLen so it is equal to the actual number of elements in the source buffer.

Example below shows how to use the ippsDecodeLZSS_8u function and supporting functions.

Return Values

ippStsNoErr

Indicates no error.

ippStsNullPtrErr

Indicates an error if one of the specified pointers is NULL.

ippStsSizeErr

Indicates an error if pSrcLen or pDstLen is negative.

ippStsDstSizeLessExpected

Indicates a warning that the size of the destination buffer is insufficient for completing the operation.

Using the Function ippsDecodeLZSS and Supporting functions

#define INBLOCKSIZE 65536
#define OUTBLOCKSIZE 16384      
..................
#include <stdio.h>
#include "ippdc.h"
..................
FILE                          *inFile, *outFile;
Ipp8u                       *pSrc = NULL, *pDst = NULL, *startpSrc, *startpDst;
int                             srcLen, dstLen = 0;
IppLZSSState_8u       *pLZSSState; 
IppStatus                  status;  
...................
/**************************************************************/
/*  Memory allocation for input code and output restored data */
/*  buffers, and for the internal decoding state structure:   */
/**************************************************************/
startpSrc = ippsMalloc_8u( OUTBLOCKSIZE * sizeof(Ipp8u) );
startpDst = ippsMalloc_8u( INBLOCKSIZE * sizeof(Ipp8u) );
ippsDecodeLZSSInitAlloc_8u( &pLZSSState );
pSrc = startpSrc;
pDst = startpDst;
/**********************************************************************/
/* The main loop. In every iteration program calls the ippsDecodeLZSS_8u. */
/* ippsDecodeLZSS_8u changes the values of pSrc, srcLen, pDst and dstLen. */
/* ippsDecodeLZSS_8u* returns ippStsDstSizeLessExpected if there is no    */
/* room in the destination buffer pDst to continue decoding. In this case */
/* dstLen == 0. Such case is handled by flushing the pDst to the output   */
/* file. If ippsDecodeLZSS_8u returns ippStsNoErr, then program flushes   */
/* the current pDst of length of (INBLOCKSIZE - dstLen) bytes to the      */
/* output file and reads next srcLen bytes of input code to startSrc      */
/**********************************************************************/
for( ; ; ) 
{
    status = ippsDecodeLZSS_8u( &pSrc, &srcLen, &pDst, &dstLen, pLZSSState); 
    if( status == ippStsNoErr )
    {
      fwrite(startpDst, sizeof(Ipp8u), (INBLOCKSIZE - dstLen), outFile);
      pDst = startpDst;
      dstLen = INBLOCKSIZE;
      srcLen = fread( startpSrc, sizeof(Ipp8u), OUTBLOCKSIZE, inFile ); 
      pSrc = startpSrc;
      if(srcLen == 0)
        break;
    }
    else if( status == ippStsDstSizeLessExpected )
    {
       fwrite(startpDst, sizeof(Ipp8u), (INBLOCKSIZE - dstLen), outFile); 
       pDst = startpDst;
       dstLen = INBLOCKSIZE;
    }
} /* for */
/*************************************************************/
/* Free the memory allocated for input code and output       */
/* restored data buffers and for the internal decoding state */
/* structure:                                                */
/*************************************************************/
ippsLZSSFree_8u( pLZSSState );
ippsFree( startpSrc );
ippsFree( startpDst );
_fcloseall();
.............

Submit feedback on this help topic

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