kusano 7d535a
/*
kusano 7d535a
   LZ4 HC - High Compression Mode of LZ4
kusano 7d535a
   Header File
kusano 7d535a
   Copyright (C) 2011-2015, Yann Collet.
kusano 7d535a
   BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
kusano 7d535a
kusano 7d535a
   Redistribution and use in source and binary forms, with or without
kusano 7d535a
   modification, are permitted provided that the following conditions are
kusano 7d535a
   met:
kusano 7d535a
kusano 7d535a
       * Redistributions of source code must retain the above copyright
kusano 7d535a
   notice, this list of conditions and the following disclaimer.
kusano 7d535a
       * Redistributions in binary form must reproduce the above
kusano 7d535a
   copyright notice, this list of conditions and the following disclaimer
kusano 7d535a
   in the documentation and/or other materials provided with the
kusano 7d535a
   distribution.
kusano 7d535a
kusano 7d535a
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
kusano 7d535a
   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
kusano 7d535a
   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
kusano 7d535a
   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
kusano 7d535a
   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
kusano 7d535a
   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
kusano 7d535a
   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
kusano 7d535a
   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
kusano 7d535a
   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
kusano 7d535a
   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
kusano 7d535a
   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
kusano 7d535a
kusano 7d535a
   You can contact the author at :
kusano 7d535a
   - LZ4 source repository : https://github.com/Cyan4973/lz4
kusano 7d535a
   - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
kusano 7d535a
*/
kusano 7d535a
#pragma once
kusano 7d535a
kusano 7d535a
kusano 7d535a
#if defined (__cplusplus)
kusano 7d535a
extern "C" {
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
/*****************************
kusano 7d535a
*  Includes
kusano 7d535a
*****************************/
kusano 7d535a
#include <stddef.h>   /* size_t */</stddef.h>
kusano 7d535a
kusano 7d535a
kusano 7d535a
/**************************************
kusano 7d535a
*  Block Compression
kusano 7d535a
**************************************/
kusano 7d535a
int LZ4_compress_HC (const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel);
kusano 7d535a
/*
kusano 7d535a
LZ4_compress_HC :
kusano 7d535a
    Destination buffer 'dst' must be already allocated.
kusano 7d535a
    Compression completion is guaranteed if 'dst' buffer is sized to handle worst circumstances (data not compressible)
kusano 7d535a
    Worst size evaluation is provided by function LZ4_compressBound() (see "lz4.h")
kusano 7d535a
      srcSize  : Max supported value is LZ4_MAX_INPUT_SIZE (see "lz4.h")
kusano 7d535a
      compressionLevel : Recommended values are between 4 and 9, although any value between 0 and 16 will work.
kusano 7d535a
                         0 means "use default value" (see lz4hc.c).
kusano 7d535a
                         Values >16 behave the same as 16.
kusano 7d535a
      return : the number of bytes written into buffer 'dst'
kusano 7d535a
            or 0 if compression fails.
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
kusano 7d535a
/* Note :
kusano 7d535a
   Decompression functions are provided within LZ4 source code (see "lz4.h") (BSD license)
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
kusano 7d535a
int LZ4_sizeofStateHC(void);
kusano 7d535a
int LZ4_compress_HC_extStateHC(void* state, const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel);
kusano 7d535a
/*
kusano 7d535a
LZ4_compress_HC_extStateHC() :
kusano 7d535a
   Use this function if you prefer to manually allocate memory for compression tables.
kusano 7d535a
   To know how much memory must be allocated for the compression tables, use :
kusano 7d535a
      int LZ4_sizeofStateHC();
kusano 7d535a
kusano 7d535a
   Allocated memory must be aligned on 8-bytes boundaries (which a normal malloc() will do properly).
kusano 7d535a
kusano 7d535a
   The allocated memory can then be provided to the compression functions using 'void* state' parameter.
kusano 7d535a
   LZ4_compress_HC_extStateHC() is equivalent to previously described function.
kusano 7d535a
   It just uses externally allocated memory for stateHC.
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
kusano 7d535a
/**************************************
kusano 7d535a
*  Streaming Compression
kusano 7d535a
**************************************/
kusano 7d535a
#define LZ4_STREAMHCSIZE        262192
kusano 7d535a
#define LZ4_STREAMHCSIZE_SIZET (LZ4_STREAMHCSIZE / sizeof(size_t))
kusano 7d535a
typedef struct { size_t table[LZ4_STREAMHCSIZE_SIZET]; } LZ4_streamHC_t;
kusano 7d535a
/*
kusano 7d535a
  LZ4_streamHC_t
kusano 7d535a
  This structure allows static allocation of LZ4 HC streaming state.
kusano 7d535a
  State must then be initialized using LZ4_resetStreamHC() before first use.
kusano 7d535a
kusano 7d535a
  Static allocation should only be used in combination with static linking.
kusano 7d535a
  If you want to use LZ4 as a DLL, please use construction functions below, which are future-proof.
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
kusano 7d535a
LZ4_streamHC_t* LZ4_createStreamHC(void);
kusano 7d535a
int             LZ4_freeStreamHC (LZ4_streamHC_t* streamHCPtr);
kusano 7d535a
/*
kusano 7d535a
  These functions create and release memory for LZ4 HC streaming state.
kusano 7d535a
  Newly created states are already initialized.
kusano 7d535a
  Existing state space can be re-used anytime using LZ4_resetStreamHC().
kusano 7d535a
  If you use LZ4 as a DLL, use these functions instead of static structure allocation,
kusano 7d535a
  to avoid size mismatch between different versions.
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
void LZ4_resetStreamHC (LZ4_streamHC_t* streamHCPtr, int compressionLevel);
kusano 7d535a
int  LZ4_loadDictHC (LZ4_streamHC_t* streamHCPtr, const char* dictionary, int dictSize);
kusano 7d535a
kusano 7d535a
int LZ4_compress_HC_continue (LZ4_streamHC_t* streamHCPtr, const char* src, char* dst, int srcSize, int maxDstSize);
kusano 7d535a
kusano 7d535a
int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, int maxDictSize);
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
  These functions compress data in successive blocks of any size, using previous blocks as dictionary.
kusano 7d535a
  One key assumption is that previous blocks (up to 64 KB) remain read-accessible while compressing next blocks.
kusano 7d535a
  There is an exception for ring buffers, which can be smaller 64 KB.
kusano 7d535a
  Such case is automatically detected and correctly handled by LZ4_compress_HC_continue().
kusano 7d535a
kusano 7d535a
  Before starting compression, state must be properly initialized, using LZ4_resetStreamHC().
kusano 7d535a
  A first "fictional block" can then be designated as initial dictionary, using LZ4_loadDictHC() (Optional).
kusano 7d535a
kusano 7d535a
  Then, use LZ4_compress_HC_continue() to compress each successive block.
kusano 7d535a
  It works like LZ4_compress_HC(), but use previous memory blocks as dictionary to improve compression.
kusano 7d535a
  Previous memory blocks (including initial dictionary when present) must remain accessible and unmodified during compression.
kusano 7d535a
  As a reminder, size 'dst' buffer to handle worst cases, using LZ4_compressBound(), to ensure success of compression operation.
kusano 7d535a
kusano 7d535a
  If, for any reason, previous data blocks can't be preserved unmodified in memory during next compression block,
kusano 7d535a
  you must save it to a safer memory space, using LZ4_saveDictHC().
kusano 7d535a
  Return value of LZ4_saveDictHC() is the size of dictionary effectively saved into 'safeBuffer'.
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
/**************************************
kusano 7d535a
*  Deprecated Functions
kusano 7d535a
**************************************/
kusano 7d535a
/* Deprecate Warnings */
kusano 7d535a
/* Should these warnings messages be a problem,
kusano 7d535a
   it is generally possible to disable them,
kusano 7d535a
   with -Wno-deprecated-declarations for gcc
kusano 7d535a
   or _CRT_SECURE_NO_WARNINGS in Visual for example.
kusano 7d535a
   You can also define LZ4_DEPRECATE_WARNING_DEFBLOCK. */
kusano 7d535a
#ifndef LZ4_DEPRECATE_WARNING_DEFBLOCK
kusano 7d535a
#  define LZ4_DEPRECATE_WARNING_DEFBLOCK
kusano 7d535a
#  define LZ4_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
kusano 7d535a
#  if (LZ4_GCC_VERSION >= 405) || defined(__clang__)
kusano 7d535a
#    define LZ4_DEPRECATED(message) __attribute__((deprecated(message)))
kusano 7d535a
#  elif (LZ4_GCC_VERSION >= 301)
kusano 7d535a
#    define LZ4_DEPRECATED(message) __attribute__((deprecated))
kusano 7d535a
#  elif defined(_MSC_VER)
kusano 7d535a
#    define LZ4_DEPRECATED(message) __declspec(deprecated(message))
kusano 7d535a
#  else
kusano 7d535a
#    pragma message("WARNING: You need to implement LZ4_DEPRECATED for this compiler")
kusano 7d535a
#    define LZ4_DEPRECATED(message)
kusano 7d535a
#  endif
kusano 7d535a
#endif // LZ4_DEPRECATE_WARNING_DEFBLOCK
kusano 7d535a
kusano 7d535a
/* compression functions */
kusano 7d535a
/* these functions are planned to trigger warning messages by r131 approximately */
kusano 7d535a
int LZ4_compressHC                (const char* source, char* dest, int inputSize);
kusano 7d535a
int LZ4_compressHC_limitedOutput  (const char* source, char* dest, int inputSize, int maxOutputSize);
kusano 7d535a
int LZ4_compressHC2               (const char* source, char* dest, int inputSize, int compressionLevel);
kusano 7d535a
int LZ4_compressHC2_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
kusano 7d535a
int LZ4_compressHC_withStateHC               (void* state, const char* source, char* dest, int inputSize);
kusano 7d535a
int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
kusano 7d535a
int LZ4_compressHC2_withStateHC              (void* state, const char* source, char* dest, int inputSize, int compressionLevel);
kusano 7d535a
int LZ4_compressHC2_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
kusano 7d535a
int LZ4_compressHC_continue               (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize);
kusano 7d535a
int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
kusano 7d535a
kusano 7d535a
/* Streaming functions following the older model; should no longer be used */
kusano 7d535a
LZ4_DEPRECATED("use LZ4_createStreamHC() instead") void* LZ4_createHC (char* inputBuffer);
kusano 7d535a
LZ4_DEPRECATED("use LZ4_saveDictHC() instead")     char* LZ4_slideInputBufferHC (void* LZ4HC_Data);
kusano 7d535a
LZ4_DEPRECATED("use LZ4_freeStreamHC() instead")   int   LZ4_freeHC (void* LZ4HC_Data);
kusano 7d535a
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int   LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel);
kusano 7d535a
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int   LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
kusano 7d535a
LZ4_DEPRECATED("use LZ4_createStreamHC() instead") int   LZ4_sizeofStreamStateHC(void);
kusano 7d535a
LZ4_DEPRECATED("use LZ4_resetStreamHC() instead")  int   LZ4_resetStreamStateHC(void* state, char* inputBuffer);
kusano 7d535a
kusano 7d535a
kusano 7d535a
#if defined (__cplusplus)
kusano 7d535a
}
kusano 7d535a
#endif