ReactOS  0.4.15-dev-1201-gb2cf5a4
huf.h File Reference
#include <stddef.h>
#include "mem.h"
Include dependency graph for huf.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define HUF_H_298734234
 
#define HUF_PUBLIC_API
 
#define HUF_BLOCKSIZE_MAX   (128 * 1024)
 
#define HUF_WORKSPACE_SIZE   (6 << 10)
 
#define HUF_WORKSPACE_SIZE_U32   (HUF_WORKSPACE_SIZE / sizeof(U32))
 

Functions

HUF_PUBLIC_API size_t HUF_compress (void *dst, size_t dstCapacity, const void *src, size_t srcSize)
 
HUF_PUBLIC_API size_t HUF_decompress (void *dst, size_t originalSize, const void *cSrc, size_t cSrcSize)
 
HUF_PUBLIC_API size_t HUF_compressBound (size_t size)
 
HUF_PUBLIC_API unsigned HUF_isError (size_t code)
 
HUF_PUBLIC_API const charHUF_getErrorName (size_t code)
 
HUF_PUBLIC_API size_t HUF_compress2 (void *dst, size_t dstCapacity, const void *src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog)
 
HUF_PUBLIC_API size_t HUF_compress4X_wksp (void *dst, size_t dstCapacity, const void *src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog, void *workSpace, size_t wkspSize)
 

Macro Definition Documentation

◆ HUF_BLOCKSIZE_MAX

#define HUF_BLOCKSIZE_MAX   (128 * 1024)

maximum input size for a single block compressed with HUF_compress

Definition at line 92 of file huf.h.

◆ HUF_H_298734234

#define HUF_H_298734234

Definition at line 40 of file huf.h.

◆ HUF_PUBLIC_API

#define HUF_PUBLIC_API

Definition at line 57 of file huf.h.

◆ HUF_WORKSPACE_SIZE

#define HUF_WORKSPACE_SIZE   (6 << 10)

HUF_compress4X_wksp() : Same as HUF_compress2(), but uses externally allocated workSpace. workspace must have minimum alignment of 4, and be at least as large as HUF_WORKSPACE_SIZE

Definition at line 113 of file huf.h.

◆ HUF_WORKSPACE_SIZE_U32

#define HUF_WORKSPACE_SIZE_U32   (HUF_WORKSPACE_SIZE / sizeof(U32))

Definition at line 114 of file huf.h.

Function Documentation

◆ HUF_compress()

HUF_PUBLIC_API size_t HUF_compress ( void dst,
size_t  dstCapacity,
const void src,
size_t  srcSize 
)

HUF_compress() : Compress content from buffer 'src', of size 'srcSize', into buffer 'dst'. 'dst' buffer must be already allocated. Compression runs faster if dstCapacity >= HUF_compressBound(srcSize). srcSize must be <= HUF_BLOCKSIZE_MAX == 128 KB.

Returns
: size of compressed data (<= dstCapacity). Special values : if return == 0, srcData is not compressible => Nothing is stored within dst !!! if HUF_isError(return), compression failed (more details using HUF_getErrorName())

Definition at line 824 of file huf_compress.c.

825 {
826  return HUF_compress2(dst, maxDstSize, src, srcSize, 255, HUF_TABLELOG_DEFAULT);
827 }
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
size_t HUF_compress2(void *dst, size_t dstSize, const void *src, size_t srcSize, unsigned maxSymbolValue, unsigned huffLog)
Definition: huf_compress.c:807

◆ HUF_compress2()

HUF_PUBLIC_API size_t HUF_compress2 ( void dst,
size_t  dstCapacity,
const void src,
size_t  srcSize,
unsigned  maxSymbolValue,
unsigned  tableLog 
)

HUF_compress2() : Same as HUF_compress(), but offers control over maxSymbolValue and tableLog. maxSymbolValue must be <= HUF_SYMBOLVALUE_MAX . tableLog must be <= HUF_TABLELOG_MAX .

Definition at line 807 of file huf_compress.c.

810 {
811  unsigned* workSpace = ExAllocatePoolWithTag(NonPagedPool, sizeof(unsigned) * HUF_WORKSPACE_SIZE_U32, HUFC_ALLOC_TAG);
812  size_t ret;
813 
814  if (!workSpace)
815  return 0;
816 
817  ret = HUF_compress4X_wksp(dst, dstSize, src, srcSize, maxSymbolValue, huffLog, workSpace, sizeof(unsigned) * HUF_WORKSPACE_SIZE_U32);
818 
819  ExFreePool(workSpace);
820 
821  return ret;
822 }
#define HUF_WORKSPACE_SIZE_U32
Definition: huf.h:114
size_t HUF_compress4X_wksp(void *dst, size_t dstSize, const void *src, size_t srcSize, unsigned maxSymbolValue, unsigned huffLog, void *workSpace, size_t wkspSize)
Definition: huf_compress.c:781
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define HUFC_ALLOC_TAG
Definition: huf_compress.c:59
int ret
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by HUF_compress().

◆ HUF_compress4X_wksp()

HUF_PUBLIC_API size_t HUF_compress4X_wksp ( void dst,
size_t  dstCapacity,
const void src,
size_t  srcSize,
unsigned  maxSymbolValue,
unsigned  tableLog,
void workSpace,
size_t  wkspSize 
)

Definition at line 781 of file huf_compress.c.

785 {
786  return HUF_compress_internal(dst, dstSize, src, srcSize,
787  maxSymbolValue, huffLog, 0 /*4 streams*/,
788  workSpace, wkspSize,
789  NULL, NULL, 0, 0 /*bmi2*/);
790 }
static size_t HUF_compress_internal(void *dst, size_t dstSize, const void *src, size_t srcSize, unsigned maxSymbolValue, unsigned huffLog, unsigned singleStream, void *workSpace, size_t wkspSize, HUF_CElt *oldHufTable, HUF_repeat *repeat, int preferRepeat, const int bmi2)
Definition: huf_compress.c:651
smooth NULL
Definition: ftsmooth.c:416
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

Referenced by HUF_compress2().

◆ HUF_compressBound()

HUF_PUBLIC_API size_t HUF_compressBound ( size_t  size)

maximum compressed size (worst case)

Definition at line 462 of file huf_compress.c.

462 { return HUF_COMPRESSBOUND(size); }
GLsizeiptr size
Definition: glext.h:5919

◆ HUF_decompress()

HUF_PUBLIC_API size_t HUF_decompress ( void dst,
size_t  originalSize,
const void cSrc,
size_t  cSrcSize 
)

HUF_decompress() : Decompress HUF data from buffer 'cSrc', of size 'cSrcSize', into already allocated buffer 'dst', of minimum size 'dstSize'. originalSize : must be the exact size of original (uncompressed) data. Note : in contrast with FSE, HUF_decompress can regenerate RLE (cSrcSize==1) and uncompressed (cSrcSize==dstSize) data, because it knows size to regenerate (originalSize).

Returns
: size of regenerated data (== originalSize), or an error code, which can be tested using HUF_isError()

Definition at line 1037 of file huf_decompress.c.

1038 {
1039  static const decompressionAlgo decompress[2] = { HUF_decompress4X1, HUF_decompress4X2 };
1040 
1041  /* validation checks */
1042  if (dstSize == 0) return ERROR(dstSize_tooSmall);
1043  if (cSrcSize > dstSize) return ERROR(corruption_detected); /* invalid */
1044  if (cSrcSize == dstSize) { memcpy(dst, cSrc, dstSize); return dstSize; } /* not compressed */
1045  if (cSrcSize == 1) { memset(dst, *(const BYTE*)cSrc, dstSize); return dstSize; } /* RLE */
1046 
1047  { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize);
1048  return decompress[algoNb](dst, dstSize, cSrc, cSrcSize);
1049  }
1050 }
size_t HUF_decompress4X2(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize)
#define ERROR(name)
Definition: error_private.h:53
size_t(* decompressionAlgo)(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: xxhash.c:193
U32 HUF_selectDecoder(size_t dstSize, size_t cSrcSize)
size_t HUF_decompress4X1(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize)
GLenum GLenum dst
Definition: glext.h:6340
#define memset(x, y, z)
Definition: compat.h:39
unsigned int U32
Definition: xxhash.c:195

◆ HUF_getErrorName()

HUF_PUBLIC_API const char* HUF_getErrorName ( size_t  code)

provides error code string (useful for debugging)

Definition at line 55 of file entropy_common.c.

55 { return ERR_getErrorName(code); }
ERR_STATIC const char * ERR_getErrorName(size_t code)
Definition: error_private.h:67
Definition: inflate.c:139

◆ HUF_isError()

HUF_PUBLIC_API unsigned HUF_isError ( size_t  code)

tells if a return value is an error code

Definition at line 54 of file entropy_common.c.

54 { return ERR_isError(code); }
ERR_STATIC unsigned ERR_isError(size_t code)
Definition: error_private.h:56
Definition: inflate.c:139