minor code refactor in HUF module
This commit is contained in:
@@ -43,25 +43,15 @@
|
|||||||
#include "huf.h"
|
#include "huf.h"
|
||||||
|
|
||||||
|
|
||||||
/*-****************************************
|
/*=== Version ===*/
|
||||||
* Version
|
|
||||||
******************************************/
|
|
||||||
unsigned FSE_versionNumber(void) { return FSE_VERSION_NUMBER; }
|
unsigned FSE_versionNumber(void) { return FSE_VERSION_NUMBER; }
|
||||||
|
|
||||||
|
|
||||||
/*-****************************************
|
/*=== Error Management ===*/
|
||||||
* FSE Error Management
|
|
||||||
******************************************/
|
|
||||||
unsigned FSE_isError(size_t code) { return ERR_isError(code); }
|
unsigned FSE_isError(size_t code) { return ERR_isError(code); }
|
||||||
|
|
||||||
const char* FSE_getErrorName(size_t code) { return ERR_getErrorName(code); }
|
const char* FSE_getErrorName(size_t code) { return ERR_getErrorName(code); }
|
||||||
|
|
||||||
|
|
||||||
/* **************************************************************
|
|
||||||
* HUF Error Management
|
|
||||||
****************************************************************/
|
|
||||||
unsigned HUF_isError(size_t code) { return ERR_isError(code); }
|
unsigned HUF_isError(size_t code) { return ERR_isError(code); }
|
||||||
|
|
||||||
const char* HUF_getErrorName(size_t code) { return ERR_getErrorName(code); }
|
const char* HUF_getErrorName(size_t code) { return ERR_getErrorName(code); }
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -102,10 +102,11 @@ size_t HUF_compress4X_wksp (void* dst, size_t dstSize, const void* src, size_t s
|
|||||||
|
|
||||||
|
|
||||||
/* *** Constants *** */
|
/* *** Constants *** */
|
||||||
#define HUF_TABLELOG_ABSOLUTEMAX 15 /* absolute limit of HUF_MAX_TABLELOG. Beyond that value, code does not work */
|
#define HUF_TABLELOG_MAX 12 /* max configured tableLog (for static allocation); can be modified up to HUF_ABSOLUTEMAX_TABLELOG */
|
||||||
#define HUF_TABLELOG_MAX 12 /* max configured tableLog (for static allocation); can be modified up to HUF_ABSOLUTEMAX_TABLELOG */
|
|
||||||
#define HUF_TABLELOG_DEFAULT 11 /* tableLog by default, when not specified */
|
#define HUF_TABLELOG_DEFAULT 11 /* tableLog by default, when not specified */
|
||||||
#define HUF_SYMBOLVALUE_MAX 255
|
#define HUF_SYMBOLVALUE_MAX 255
|
||||||
|
|
||||||
|
#define HUF_TABLELOG_ABSOLUTEMAX 15 /* absolute limit of HUF_MAX_TABLELOG. Beyond that value, code does not work */
|
||||||
#if (HUF_TABLELOG_MAX > HUF_TABLELOG_ABSOLUTEMAX)
|
#if (HUF_TABLELOG_MAX > HUF_TABLELOG_ABSOLUTEMAX)
|
||||||
# error "HUF_TABLELOG_MAX is too large !"
|
# error "HUF_TABLELOG_MAX is too large !"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -108,10 +108,10 @@ size_t HUF_readDTableX2 (HUF_DTable* DTable, const void* src, size_t srcSize)
|
|||||||
memcpy(DTable, &dtd, sizeof(dtd));
|
memcpy(DTable, &dtd, sizeof(dtd));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prepare ranks */
|
/* Calculate starting value for each rank */
|
||||||
{ U32 n, nextRankStart = 0;
|
{ U32 n, nextRankStart = 0;
|
||||||
for (n=1; n<tableLog+1; n++) {
|
for (n=1; n<tableLog+1; n++) {
|
||||||
U32 current = nextRankStart;
|
U32 const current = nextRankStart;
|
||||||
nextRankStart += (rankVal[n] << (n-1));
|
nextRankStart += (rankVal[n] << (n-1));
|
||||||
rankVal[n] = current;
|
rankVal[n] = current;
|
||||||
} }
|
} }
|
||||||
@@ -121,11 +121,11 @@ size_t HUF_readDTableX2 (HUF_DTable* DTable, const void* src, size_t srcSize)
|
|||||||
for (n=0; n<nbSymbols; n++) {
|
for (n=0; n<nbSymbols; n++) {
|
||||||
U32 const w = huffWeight[n];
|
U32 const w = huffWeight[n];
|
||||||
U32 const length = (1 << w) >> 1;
|
U32 const length = (1 << w) >> 1;
|
||||||
U32 i;
|
U32 u;
|
||||||
HUF_DEltX2 D;
|
HUF_DEltX2 D;
|
||||||
D.byte = (BYTE)n; D.nbBits = (BYTE)(tableLog + 1 - w);
|
D.byte = (BYTE)n; D.nbBits = (BYTE)(tableLog + 1 - w);
|
||||||
for (i = rankVal[w]; i < rankVal[w] + length; i++)
|
for (u = rankVal[w]; u < rankVal[w] + length; u++)
|
||||||
dt[i] = D;
|
dt[u] = D;
|
||||||
rankVal[w] += length;
|
rankVal[w] += length;
|
||||||
} }
|
} }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user