Developer Reference

  • 2020
  • 07/15/2020
  • Public Content


Encodes the last few bits in the bitstream and aligns the output data on the byte boundary.


IppStatus ippsEncodeLZSSFlush_8u (Ipp8u**
, int*
, IppLZSSState_8u*
Include Files
Domain Dependencies
Double pointer to the destination buffer.
Pointer to the length of destination buffer.
Pointer to the LZSS encoder state structure.
This function encodes the last few bits (remainder) in the bitstream, writes them to
, and aligns the output data on a byte boundary.
Return Values
Indicates no error.
Indicates an error if one of the pointers is
Indicates an error if
is less than or equal to 0.
Indicates a warning that the size of the destination buffer is insufficient for completing the operation.


/******************************************************************************* * Copyright 2015-2020 Intel Corporation. * * This software and the related documents are Intel copyrighted materials, and * your use of them is governed by the express license under which they were * provided to you (License). Unless the License provides otherwise, you may not * use, modify, copy, publish, distribute, disclose or transmit this software or * the related documents without Intel's prior written permission. * * This software and the related documents are provided as is, with no express * or implied warranties, other than those that are expressly stated in the * License. *******************************************************************************/ // The example below shows how to use the function ippsEncodeLZSS_8u and supporting functions: // ippsLZSSGetSize_8u, ippsEncodeLZSSInit_8u // ippsEncodeLZSS_8u // ippsEncodeLZSSFlush_8u #include <stdio.h> #include "ipp.h" #define INBLOCKSIZE 65536 #define OUTBLOCKSIZE 16384 /* Next two defines are created to simplify code reading and understanding */ #define EXIT_MAIN exitLine: /* Label for Exit */ #define check_sts(st) if((st) != ippStsNoErr) goto exitLine; /* Go to Exit if Intel(R) Integrated Primitives (Intel(R) IPP) function returned status different from ippStsNoErr */ /* Results of ippMalloc() are not validated because Intel(R) IPP functions perform bad arguments check and will return an appropriate status */ int main(void) { FILE *inFile = NULL, *outFile = NULL; Ipp8u *pSrc = NULL, *pDst = NULL, *startpSrc = NULL, *startpDst = NULL; int srcLen, dstLen = 0; int commonDstLen = 0; IppLZSSState_8u *pLZSSState = NULL; int szState = 0; IppStatus status = ippStsNoErr; inFile = fopen("EncodeLZSSFlush.c", "rb"); if ( !inFile ) { printf("\nCan't open input data file ""EncodeLZSSFlush.c"". program terminated.\n"); goto exitLine; } outFile = fopen("EncodeLZSSFlush.bin", "wb"); if ( !outFile ) { printf("\nCan't open output data file ""EncodeLZSSFlush.bin"". program terminated.\n"); goto exitLine; } /*************************************************************/ /* Memory allocation for input data and output code buffers, */ /* and for the internal encoding state structure: */ /*************************************************************/ startpSrc = ippsMalloc_8u( (INBLOCKSIZE) * sizeof(char) ); startpDst = ippsMalloc_8u( (OUTBLOCKSIZE) * sizeof(char) ); check_sts( status = ippsLZSSGetSize_8u( &szState ) ) pLZSSState = (IppLZSSState_8u*)ippsMalloc_8u( szState ); check_sts( status = ippsEncodeLZSSInit_8u( pLZSSState ) ) /*************************************************************/ /* Initializing the arguments, reading srcLen bytes of */ /* input data from input data file to startpSrc: */ /*************************************************************/ commonDstLen = (OUTBLOCKSIZE); pDst = startpDst; dstLen = commonDstLen; srcLen = fread( startpSrc, sizeof(Ipp8u), INBLOCKSIZE, inFile ); if (srcLen <= 0) { printf("\nInput data file ""EncodeLZSSFlush.c"" is corrupted. program terminated.\n"); goto exitLine; } pSrc = startpSrc; /**************************************************************/ /* The main loop. In every iteration program calls the */ /* ippsEncodeLZSS_8u. ippsEncodeLZSS_8u changes the values */ /* of pSrc, srcLen, pDst and dstLen. ippsEncodeLZSS_8u */ /* returns ippStsDstSizeLessExpected if there is no */ /* room in the destination buffer pDst to continue encoding. */ /* In this case dstLen == 0. Such case is handled by */ /* flushing the pDst to the output file. If ippsEncodeLZSS_8u */ /* returns ippStsNoErr, then the program flushes the current */ /* pDst of length of (commonDstLen - dstLen) bytes to */ /* the output file and reads next srcLen bytes of input data */ /* to startpSrc. */ /**************************************************************/ for( ; ; ) { status = ippsEncodeLZSS_8u(&pSrc, &srcLen, &pDst, &dstLen, pLZSSState); if( status == ippStsDstSizeLessExpected ) { fwrite( startpDst, sizeof(Ipp8u), (commonDstLen - dstLen), outFile ); dstLen = commonDstLen; pDst = startpDst; } else if( status == ippStsNoErr ) { fwrite( startpDst, sizeof(Ipp8u), (commonDstLen - dstLen), outFile ); pDst = startpDst; dstLen = commonDstLen; srcLen = fread( startpSrc, sizeof(Ipp8u), INBLOCKSIZE, inFile ); if( srcLen <= 0 ) break; pSrc = startpSrc; } else { check_sts( status ) } } /**************************************************************/ /* The call of ippsEncodeLZSSFlush_8u flushes the last few */ /* bits of code to the destination buffer: */ /**************************************************************/ check_sts( ippsEncodeLZSSFlush_8u(&pDst, &dstLen, pLZSSState) ) fwrite( startpDst, sizeof(Ipp8u), (commonDstLen - dstLen), outFile ); printf( "\n EncodeLZSSFlush.c successfully encoded to EncodeLZSSFlush.bin \n"); EXIT_MAIN ippsFree( pLZSSState ); ippsFree( startpSrc ); ippsFree( startpDst ); if ( inFile ) fclose( inFile ); if ( outFile ) fclose( outFile ); printf("Exit status %d (%s)\n", (int)status, ippGetStatusString(status)); return (int)status; }

Product and Performance Information


Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804