Add README and clean up code

This commit is contained in:
Stella Lau
2017-07-26 13:24:03 -07:00
parent e9161637b2
commit 40759bade9
7 changed files with 134 additions and 942 deletions
+50 -37
View File
@@ -2,7 +2,52 @@
#define LDM_H
#include "mem.h" // from /lib/common/mem.h
#include "ldm_params.h"
// #include "ldm_params.h"
// =============================================================================
// Modify the parameters in ldm_params.h if "ldm_params.h" is included.
// Otherwise, modify the parameters here.
// =============================================================================
#ifndef LDM_PARAMS_H
// Defines the size of the hash table.
// Note that this is not the number of buckets.
// Currently this should be less than WINDOW_SIZE_LOG + 4.
#define LDM_MEMORY_USAGE 23
// The number of entries in a hash bucket.
#define HASH_BUCKET_SIZE_LOG 3 // The maximum is 4 for now.
// Defines the lag in inserting elements into the hash table.
#define LDM_LAG 0
// The maximum window size when searching for matches.
// The maximum value is 30.
#define LDM_WINDOW_SIZE_LOG 28
// The minimum match length.
// This should be a multiple of four.
#define LDM_MIN_MATCH_LENGTH 64
// If INSERT_BY_TAG, insert entries into the hash table as a function of the
// hash. Certain hashes will not be inserted.
//
// Otherwise, insert as a function of the position.
#define INSERT_BY_TAG 1
// Store a checksum with the hash table entries for faster comparison.
// This halves the number of entries the hash table can contain.
#define USE_CHECKSUM 1
#endif
// Output compression statistics.
#define COMPUTE_STATS
// Output the configuration.
#define OUTPUT_CONFIGURATION
// =============================================================================
// The number of bytes storing the compressed and decompressed size
// in the header.
@@ -15,40 +60,9 @@
#define RUN_BITS (8-ML_BITS)
#define RUN_MASK ((1U<<RUN_BITS)-1)
// THe number of bytes storing the offset.
// The number of bytes storing the offset.
#define LDM_OFFSET_SIZE 4
// =============================================================================
// Modify parameters in ldm_params.h if "ldm_params.h" is included.
// =============================================================================
#ifndef LDM_PARAMS_H
// Defines the size of the hash table.
// Note that this is not the number of buckets.
// Currently this should be less than WINDOW_SIZE_LOG + 4?
#define LDM_MEMORY_USAGE 25
// The number of entries in a hash bucket.
#define HASH_BUCKET_SIZE_LOG 3 // The maximum is 4 for now.
// Defines the lag in inserting elements into the hash table.
#define LDM_LAG 0
// The maximum window size.
#define LDM_WINDOW_SIZE_LOG 28 // Max value is 30
//These should be multiples of four (and perhaps set to the same value?).
#define LDM_MIN_MATCH_LENGTH 64
#define INSERT_BY_TAG 1 // Insertion policy based on hash.
#define USE_CHECKSUM 1
#endif
// =============================================================================
#define COMPUTE_STATS
#define OUTPUT_CONFIGURATION
#define LDM_WINDOW_SIZE (1 << (LDM_WINDOW_SIZE_LOG))
#define LDM_HASH_LENGTH LDM_MIN_MATCH_LENGTH
@@ -81,7 +95,6 @@ typedef struct LDM_DCtx LDM_DCtx;
* bytes added similarly to the additional literal length bytes after the offset.
*
* The last sequence is incomplete and stops right after the literals.
*
*/
size_t LDM_compress(const void *src, size_t srcSize,
void *dst, size_t maxDstSize);
@@ -96,7 +109,7 @@ void LDM_initializeCCtx(LDM_CCtx *cctx,
void *dst, size_t maxDstSize);
/**
* Frees up memory allocating in initializeCCtx
* Frees up memory allocated in LDM_initializeCCtx().
*/
void LDM_destroyCCtx(LDM_CCtx *cctx);
@@ -121,8 +134,8 @@ void LDM_printCompressStats(const LDM_compressStats *stats);
*
* This is followed by literalLength bytes corresponding to the literals.
*/
void LDM_encodeLiteralLengthAndLiterals(
LDM_CCtx *cctx, BYTE *pToken, const U64 literalLength);
void LDM_encodeLiteralLengthAndLiterals(LDM_CCtx *cctx, BYTE *pToken,
const U64 literalLength);
/**
* Write current block (literals, literal length, match offset,