[superblock] Reduce stack usage by correctly sizing header buffers

This commit is contained in:
Nick Terrell 2020-09-24 18:04:44 -07:00
parent 6a1e526ea7
commit f1cbeec039
2 changed files with 6 additions and 2 deletions

View File

@ -186,6 +186,10 @@ typedef enum { set_basic, set_rle, set_compressed, set_repeat } symbolEncodingTy
#define OffFSELog 8 #define OffFSELog 8
#define MaxFSELog MAX(MAX(MLFSELog, LLFSELog), OffFSELog) #define MaxFSELog MAX(MAX(MLFSELog, LLFSELog), OffFSELog)
#define ZSTD_MAX_HUF_HEADER_SIZE 128 /* header + <= 127 byte tree description */
/* Each table cannot take more than #symbols * FSELog bits */
#define ZSTD_MAX_FSE_HEADERS_SIZE (((MaxML + 1) * MLFSELog + (MaxLL + 1) * LLFSELog + (MaxOff + 1) * OffFSELog + 7) / 8)
static UNUSED_ATTR const U32 LL_bits[MaxLL+1] = { static UNUSED_ATTR const U32 LL_bits[MaxLL+1] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

View File

@ -29,7 +29,7 @@
* This metadata is populated in ZSTD_buildSuperBlockEntropy_literal() */ * This metadata is populated in ZSTD_buildSuperBlockEntropy_literal() */
typedef struct { typedef struct {
symbolEncodingType_e hType; symbolEncodingType_e hType;
BYTE hufDesBuffer[500]; /* TODO give name to this value */ BYTE hufDesBuffer[ZSTD_MAX_HUF_HEADER_SIZE];
size_t hufDesSize; size_t hufDesSize;
} ZSTD_hufCTablesMetadata_t; } ZSTD_hufCTablesMetadata_t;
@ -42,7 +42,7 @@ typedef struct {
symbolEncodingType_e llType; symbolEncodingType_e llType;
symbolEncodingType_e ofType; symbolEncodingType_e ofType;
symbolEncodingType_e mlType; symbolEncodingType_e mlType;
BYTE fseTablesBuffer[500]; /* TODO give name to this value */ BYTE fseTablesBuffer[ZSTD_MAX_FSE_HEADERS_SIZE];
size_t fseTablesSize; size_t fseTablesSize;
size_t lastCountSize; /* This is to account for bug in 1.3.4. More detail in ZSTD_compressSubBlock_sequences() */ size_t lastCountSize; /* This is to account for bug in 1.3.4. More detail in ZSTD_compressSubBlock_sequences() */
} ZSTD_fseCTablesMetadata_t; } ZSTD_fseCTablesMetadata_t;