EncodeGIT

Performs GIT encoding.

Syntax

IppStatus ippsEncodeGIT_8u (const Ipp8u* pSrc, int srcLen, Ipp8u* pDst, int* pDstLen, IppGITStrategyHint strategyHint, IppGITState_8u* pGITState);

Parameters

pSrc

Pointer to the source buffer.

srcLen

Length of the source buffer.

pDst

Pointer to the destination buffer.

pDstLen

Pointer to the length of the destination buffer.

strategyHint

Suggests using of the code implemented specific strategy for lexicorgaphical reordering (see table "strategyHint Parameter"); default value is ippGITNoStrategyHint.

pGITState

Pointer to the GIT encoding state structure.

Description

The function ippsEncodeGIT is declared in the ippdc.h file. This function performs GIT encoding. It processes the srcLen bytes of the input data pSrc and writes the results to the pDst buffer. The function uses the GIT encoding state structure pGITState that contains pointers to different data structures required for operation. The structure must be initialized by the functions ippsEncodeGITInitAlloc or ippsEncodeGITInit beforehand.

It is not recommended to use source data buffer less than 8Kb.

Note iconNote

Value of srcLen must not exceed that of maxSrcLen specified in the function ippsEncodeGITInitAlloc or ippsEncodeGITInit.

Nevertheless, the larger files can be encoded by subsequently calling the ippsEncodeGIT function several times (see the code example below).

Encoding quality depends on the input data and in some cases can be improved by specifying the parameter strategyHint.

The default value for the strategyHint parameter is ippGITNoStrategyHint.

The code example below shows how to use the ippsEncodeGIT_8u and supporting functions.

Return Values

ippStsNoErr

Indicates no error.

ippStsNullPtrErr

Indicates an error if one of the pointers is NULL.

ippStsSizeErr

Indicates an error if srcLen is greater than the value of the maxSrcLen parameter passed to ippsEncodeGITGetSize or ippsEncodeGITInitAlloc.

Using the Function EncodeGIT and Supporting Functions

#define BLOCKSIZE 65536 
................
FILE*               in, out;
Ipp8u*              data, code;
IppGITState_8u*     pGITState;
int                 GITStateSize, size, codeLen;
IppGITStrategyHint  strategyHint;
.................

		
/*************************************************************/
/* Opening the file containing input data and the file       */
/* for the compressed data:                                  */
/*************************************************************/
in = fopen("datafile.txt", "rb"); 
out = fopen("codefile", "wb");

		
/*************************************************************/
/* Memory allocation for input data and output code buffers, */
/* and for the internal encoding state structure:            */
/*************************************************************/ 
data = (Ipp8u*) malloc(BLOCKSIZE * sizeof(Ipp8u));
code = (Ipp8u*) malloc((BLOCKSIZE << 1) * sizeof(Ipp8u));
ippsEncodeGITGetSize_8u(BLOCKSIZE, (BLOCKSIZE << 1), &GITStateSize);
pGITState = (IppGITState_8u*) malloc(GITStateSize * sizeof(Ipp8u));

		
/*************************************************************/
/* Initializing the memory, allocated for internal encoding  */
/* state structure and setting the encoding strategy:        */
/*************************************************************/
ippsEncodeGITInit_8u(BLOCKSIZE, (BLOCKSIZE << 1), pGITState);
strategyHint = ippGITLeftReorder;
/*************************************************************/
/* The main loop. In every iteration program reads the size       */  
/* bytes from the input data file to data array and          */ 
/* compresses by calling the ippsEncodeGIT_8u function.      */  
/* ippsEncodeGIT_8u places the compressed data to the code   */
/* array and returns the length of compressed data in bytes  */ 
/* trough the &codeLen argument. After that program writes   */
/* the value of codeLen and codeLen bytes of compressed data */  
/* to the output data file.                                  */
/*************************************************************/
for( ; ; )
{
    size = fread(&data[0], sizeof(Ipp8u), BLOCKSIZE, in);
    if(size <= 0)
      break;
    if(ippsEncodeGIT_8u(data, size, code, &codeLen, strategyHint, pGITState) != ippStsNoErr)
      return (-1);
    fwrite(&codeLen, sizeof(int), 1, out);
    fwrite(code, sizeof(Ipp8u), codeLen, out);
} /* for */

		
/*************************************************************/
/* Free the memory allocated for input data and output       */
/* code buffers and for the internal encoding state          */
/* structure:                                                */
/*************************************************************/
free(pGITState); 
free(data);
free(code);
fclose(in);
fclose(out);
....................

Submit feedback on this help topic

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