source: thirdparty/blosc/internal-complibs/zstd-0.7.4/legacy/zstd_v05.h @ 8ebc79b

Revision 8ebc79b, 7.7 KB checked in by Hal Finkel <hfinkel@…>, 8 years ago (diff)

Add the other internal compression libraries from blocs

  • Property mode set to 100644
Line 
1/*
2    zstd_v05 - decoder for 0.5 format
3    Header File
4    Copyright (C) 2014-2016, Yann Collet.
5
6    BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
7
8    Redistribution and use in source and binary forms, with or without
9    modification, are permitted provided that the following conditions are
10    met:
11    * Redistributions of source code must retain the above copyright
12    notice, this list of conditions and the following disclaimer.
13    * Redistributions in binary form must reproduce the above
14    copyright notice, this list of conditions and the following disclaimer
15    in the documentation and/or other materials provided with the
16    distribution.
17    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21    OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29    You can contact the author at :
30    - zstd source repository : https://github.com/Cyan4973/zstd
31*/
32#ifndef ZSTDv05_H
33#define ZSTDv05_H
34
35#if defined (__cplusplus)
36extern "C" {
37#endif
38
39/*-*************************************
40*  Dependencies
41***************************************/
42#include <stddef.h>   /* size_t */
43#include "mem.h"      /* U64, U32 */
44
45
46/* *************************************
47*  Simple functions
48***************************************/
49/*! ZSTDv05_decompress() :
50    `compressedSize` : is the _exact_ size of the compressed blob, otherwise decompression will fail.
51    `dstCapacity` must be large enough, equal or larger than originalSize.
52    @return : the number of bytes decompressed into `dst` (<= `dstCapacity`),
53              or an errorCode if it fails (which can be tested using ZSTDv05_isError()) */
54size_t ZSTDv05_decompress( void* dst, size_t dstCapacity,
55                     const void* src, size_t compressedSize);
56
57
58/* *************************************
59*  Helper functions
60***************************************/
61/* Error Management */
62unsigned    ZSTDv05_isError(size_t code);          /*!< tells if a `size_t` function result is an error code */
63const char* ZSTDv05_getErrorName(size_t code);     /*!< provides readable string for an error code */
64
65
66/* *************************************
67*  Explicit memory management
68***************************************/
69/** Decompression context */
70typedef struct ZSTDv05_DCtx_s ZSTDv05_DCtx;
71ZSTDv05_DCtx* ZSTDv05_createDCtx(void);
72size_t ZSTDv05_freeDCtx(ZSTDv05_DCtx* dctx);      /*!< @return : errorCode */
73
74/** ZSTDv05_decompressDCtx() :
75*   Same as ZSTDv05_decompress(), but requires an already allocated ZSTDv05_DCtx (see ZSTDv05_createDCtx()) */
76size_t ZSTDv05_decompressDCtx(ZSTDv05_DCtx* ctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
77
78
79/*-***********************
80*  Simple Dictionary API
81*************************/
82/*! ZSTDv05_decompress_usingDict() :
83*   Decompression using a pre-defined Dictionary content (see dictBuilder).
84*   Dictionary must be identical to the one used during compression, otherwise regenerated data will be corrupted.
85*   Note : dict can be NULL, in which case, it's equivalent to ZSTDv05_decompressDCtx() */
86size_t ZSTDv05_decompress_usingDict(ZSTDv05_DCtx* dctx,
87                                            void* dst, size_t dstCapacity,
88                                      const void* src, size_t srcSize,
89                                      const void* dict,size_t dictSize);
90
91/*-************************
92*  Advanced Streaming API
93***************************/
94typedef enum { ZSTDv05_fast, ZSTDv05_greedy, ZSTDv05_lazy, ZSTDv05_lazy2, ZSTDv05_btlazy2, ZSTDv05_opt, ZSTDv05_btopt } ZSTDv05_strategy;
95typedef struct {
96    U64 srcSize;
97    U32 windowLog;     /* the only useful information to retrieve */
98    U32 contentLog; U32 hashLog; U32 searchLog; U32 searchLength; U32 targetLength; ZSTDv05_strategy strategy;
99} ZSTDv05_parameters;
100size_t ZSTDv05_getFrameParams(ZSTDv05_parameters* params, const void* src, size_t srcSize);
101
102size_t ZSTDv05_decompressBegin_usingDict(ZSTDv05_DCtx* dctx, const void* dict, size_t dictSize);
103void   ZSTDv05_copyDCtx(ZSTDv05_DCtx* dstDCtx, const ZSTDv05_DCtx* srcDCtx);
104size_t ZSTDv05_nextSrcSizeToDecompress(ZSTDv05_DCtx* dctx);
105size_t ZSTDv05_decompressContinue(ZSTDv05_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
106
107
108/*-***********************
109*  ZBUFF API
110*************************/
111typedef struct ZBUFFv05_DCtx_s ZBUFFv05_DCtx;
112ZBUFFv05_DCtx* ZBUFFv05_createDCtx(void);
113size_t         ZBUFFv05_freeDCtx(ZBUFFv05_DCtx* dctx);
114
115size_t ZBUFFv05_decompressInit(ZBUFFv05_DCtx* dctx);
116size_t ZBUFFv05_decompressInitDictionary(ZBUFFv05_DCtx* dctx, const void* dict, size_t dictSize);
117
118size_t ZBUFFv05_decompressContinue(ZBUFFv05_DCtx* dctx,
119                                            void* dst, size_t* dstCapacityPtr,
120                                      const void* src, size_t* srcSizePtr);
121
122/*-***************************************************************************
123*  Streaming decompression
124*
125*  A ZBUFFv05_DCtx object is required to track streaming operations.
126*  Use ZBUFFv05_createDCtx() and ZBUFFv05_freeDCtx() to create/release resources.
127*  Use ZBUFFv05_decompressInit() to start a new decompression operation,
128*   or ZBUFFv05_decompressInitDictionary() if decompression requires a dictionary.
129*  Note that ZBUFFv05_DCtx objects can be reused multiple times.
130*
131*  Use ZBUFFv05_decompressContinue() repetitively to consume your input.
132*  *srcSizePtr and *dstCapacityPtr can be any size.
133*  The function will report how many bytes were read or written by modifying *srcSizePtr and *dstCapacityPtr.
134*  Note that it may not consume the entire input, in which case it's up to the caller to present remaining input again.
135*  The content of @dst will be overwritten (up to *dstCapacityPtr) at each function call, so save its content if it matters or change @dst.
136*  @return : a hint to preferred nb of bytes to use as input for next function call (it's only a hint, to help latency)
137*            or 0 when a frame is completely decoded
138*            or an error code, which can be tested using ZBUFFv05_isError().
139*
140*  Hint : recommended buffer sizes (not compulsory) : ZBUFFv05_recommendedDInSize() / ZBUFFv05_recommendedDOutSize()
141*  output : ZBUFFv05_recommendedDOutSize==128 KB block size is the internal unit, it ensures it's always possible to write a full block when decoded.
142*  input  : ZBUFFv05_recommendedDInSize==128Kb+3; just follow indications from ZBUFFv05_decompressContinue() to minimize latency. It should always be <= 128 KB + 3 .
143* *******************************************************************************/
144
145
146/* *************************************
147*  Tool functions
148***************************************/
149unsigned ZBUFFv05_isError(size_t errorCode);
150const char* ZBUFFv05_getErrorName(size_t errorCode);
151
152/** Functions below provide recommended buffer sizes for Compression or Decompression operations.
153*   These sizes are just hints, and tend to offer better latency */
154size_t ZBUFFv05_recommendedDInSize(void);
155size_t ZBUFFv05_recommendedDOutSize(void);
156
157
158
159/*-*************************************
160*  Constants
161***************************************/
162#define ZSTDv05_MAGICNUMBER 0xFD2FB525   /* v0.5 */
163
164
165
166
167#if defined (__cplusplus)
168}
169#endif
170
171#endif  /* ZSTDv0505_H */
Note: See TracBrowser for help on using the repository browser.