⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ipp_zlib.h

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 H
字号:
/*
//
//               INTEL CORPORATION PROPRIETARY INFORMATION
//  th software is supplied under the terms of a license agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in accordance with the terms of that agreement.
//        Copyright (c) 2005 Intel Corporation. All Rights Reserved.
//
//
*/
    
/* zlib.h -- interface of the 'zlib' general purpose compression library
  version 1.2.1, November 17th, 2003

  Copyright (C) 1995-2003 Jean-loup Gailly and Mark Adler

  th software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of th software.

  Permission is granted to anyone to use th software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:

  1. The origin of th software must not be misrepresented; you must not
     claim that you wrote the original software. If you use th software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. th notice may not be removed or altered from any source distribution.

  Jean-loup Gailly        Mark Adler
  jloup@gzip.org          madler@alumni.caltech.edu


  The data format used by the zlib library is described by RFCs (Request for
  Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt
  (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
*/

#include "ipps.h"
#include "ippdc.h"
/**********************************************************************************/
/********************    zlib states for compatibility    *************************/
/**********************************************************************************/
    
#define FAR  

typedef unsigned char Byte;
typedef unsigned char Bytef;
typedef unsigned int uInt;
typedef unsigned long uLong;
typedef void* gzFile;
typedef void* voidpf;
typedef voidpf (*alloc_func)(voidpf opaque, uInt items, uInt size);
typedef void   (*free_func)(voidpf opaque, voidpf address);

typedef enum {
    infhead,      
    infflags,     
    inftime,      
    infos,        
    infexlen,     
    infextra,     
    infname,      
    infcomment,   
    infhcrc,      
    infmain
} inflate_header_mode;

typedef struct IppLZ77ZLIBState_ST {
    Bytef                    *next_in;  /* next input byte */
    uInt                     avail_in;  /* number of bytes available at next_in */
    uLong                    total_in;  /* total nb of input bytes read so far */

    Bytef                    *next_out; /* next output byte should be put there */
    uInt                     avail_out; /* remaining free space at next_out */
    uLong                    total_out; /* total nb of bytes output so far */

    char                     *msg;      /* last error message, NULL if no error */
    struct LZ77State_8u      *state; /* not visible by applications */

    alloc_func               zalloc;  /* used to allocate the internal state */
    free_func                zfree;   /* used to free the internal state */
    voidpf                   opaque;  /* private data object passed to zalloc and zfree */

    int                      data_type;  /* best guess about the data type: ascii or binary */
    uLong                    adler;      /* adler32 value of the uncompressed data */
    uLong                    reserved;   /* reserved for future use */
    
   /* fields specific only for Intel(R) IPP zlib-1.2.1 compatible version */
#ifndef INFLATE_NATIVE
    inflate_header_mode      headerMode;
    int                      headerFlags; 
    int                      headerBuf;
    int                      headerBits;
    int                      headerLength;
    int                      blockEnd; 
#endif

#ifdef INFLATE_OMP 
    /* This is the additional internal state, stateMT. It has the               */
    /* same type and size as the master internal state, state. Fields of        */
    /* stateMT should be initialized by inflateInit2. Check ippdeflate.c for    */
    /* details.                                                                 */
    struct LZ77State_8u      *stateMT;  

    /* These are two variables shared between LZ77 and Huff threads.            */
    /* They are necessary for handling 33 and 32 return statuses (in time       */
    /* returning from inflate when tere is not enough input or output)          */
    IppStatus                decodeHuffStatus; 
    IppStatus                decodeLZ77Status; 

    /* Thread shared variable: 0 - if there is no need to leave;                */
    /* 1 - if it is time to leave (switch to inflateStatus == final).           */
    int                      lastBlockHuff;
    int                      lastBlockLZ77;
    
    /* Variable for checking if the first swap done: 0 - not yet, 1 - done.     */
    int                      firstSwapDone;

#endif
} z_stream;

/**********************************************************************************/
/********************            zlib constants           *************************/
/**********************************************************************************/

#define ZLIB_VERSION "Intel IPP zlib-1.2.1 compatible version"
                       
#define Z_NO_FLUSH        0
#define Z_SYNC_FLUSH      2
#define Z_FULL_FLUSH      3
#define Z_FINISH          4
#define Z_BLOCK           5
#define Z_PARTIAL_FLUSH   Z_SYNC_FLUSH

 
#define Z_OK              0
#define Z_STREAM_END      1
#define Z_NEED_DICT       2
#define Z_ERRNO         (-1)
#define Z_STREAM_ERROR  (-2)
#define Z_DATA_ERROR    (-3)
#define Z_MEM_ERROR     (-4)
#define Z_BUF_ERROR     (-5)
#define Z_VERSION_ERROR (-6)

#define Z_NO_COMPRESSION         0
#define Z_BEST_SPEED             1
#define Z_BEST_COMPRESSION       9
#define Z_DEFAULT_COMPRESSION    6

#define Z_FILTERED            0
#define Z_HUFFMAN_ONLY        0
#define Z_RLE                 0
#define Z_DEFAULT_STRATEGY    0

#define Z_BINARY     0
#define Z_ASCII      1
#define Z_UNKNOWN    2

#define Z_DEFLATED   8
#define Z_NULL       0  

#define DEF_MEM_LEVEL 8
#define Z_BUFSIZE 65536 

#define MAX_WBITS 15

#define OS_CODE 0x00

/**********************************************************************************/
/********************            zlib prototypes          *************************/
/**********************************************************************************/

extern int deflateInit_ (z_stream* strm, int level, const char *version, int stream_size);
extern int deflateInit2_ (z_stream* strm, int  level, int  method,
                          int windowBits, int memLevel, int strategy, 
                          const char *version, int stream_size);

#define deflateInit(strm, level) \
        deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))

#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
        deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
                      (strategy), ZLIB_VERSION, sizeof(z_stream))

extern int deflate(z_stream* strm, int flush);
extern int deflateEnd(z_stream* strm);
extern int deflateReset (z_stream* strm);

extern int inflateInit_(z_stream* strm, const char *version, int stream_size);
extern int inflateInit2_(z_stream* strm, int  windowBits, const char *version, int stream_size);

#define inflateInit(strm) \
        inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))

#define inflateInit2(strm, windowBits) \
        inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))

extern int inflate(z_stream* strm, int flush);
extern int inflateSync(z_stream* strm);
extern int inflateEnd(z_stream* strm);
extern int inflateReset(z_stream* strm);

extern gzFile gzopen(const char *path, const char *mode);
extern int gzwrite(gzFile file, void* buf, unsigned len);
extern int gzread(gzFile file, void* buf, unsigned len);
extern int gzclose(gzFile file);

extern uLong adler32(uLong adler, const Bytef *buf, uInt len);
extern uLong crc32(uLong crc, const Bytef *buf, uInt len);

/**********************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -