minor simplifications
parent
a3d92aeafa
commit
39c596ca58
|
@ -516,7 +516,6 @@ size_t ZSTD_decodeSeqHeaders(int* nbSeq, const BYTE** dumpsPtr, size_t* dumpsLen
|
||||||
const BYTE* ip = istart;
|
const BYTE* ip = istart;
|
||||||
const BYTE* const iend = istart + srcSize;
|
const BYTE* const iend = istart + srcSize;
|
||||||
U32 LLtype, Offtype, MLtype;
|
U32 LLtype, Offtype, MLtype;
|
||||||
U32 LLlog, Offlog, MLlog;
|
|
||||||
size_t dumpsLength;
|
size_t dumpsLength;
|
||||||
|
|
||||||
/* check */
|
/* check */
|
||||||
|
@ -553,82 +552,75 @@ size_t ZSTD_decodeSeqHeaders(int* nbSeq, const BYTE** dumpsPtr, size_t* dumpsLen
|
||||||
/* check */
|
/* check */
|
||||||
if (ip > iend-3) return ERROR(srcSize_wrong); /* min : all 3 are "raw", hence no header, but at least xxLog bits per type */
|
if (ip > iend-3) return ERROR(srcSize_wrong); /* min : all 3 are "raw", hence no header, but at least xxLog bits per type */
|
||||||
|
|
||||||
/* sequences */
|
/* Build DTables */
|
||||||
{
|
{
|
||||||
S16 norm[MaxML+1]; /* assumption : MaxML >= MaxLL >= MaxOff */
|
S16 norm[MaxML+1]; /* assumption : MaxML >= MaxLL >= MaxOff */
|
||||||
size_t headerSize;
|
|
||||||
|
|
||||||
/* Build DTables */
|
|
||||||
switch(LLtype)
|
switch(LLtype)
|
||||||
{
|
{
|
||||||
U32 max;
|
|
||||||
case FSE_ENCODING_RLE :
|
case FSE_ENCODING_RLE :
|
||||||
LLlog = 0;
|
|
||||||
FSE_buildDTable_rle(DTableLL, *ip++);
|
FSE_buildDTable_rle(DTableLL, *ip++);
|
||||||
break;
|
break;
|
||||||
case FSE_ENCODING_RAW :
|
case FSE_ENCODING_RAW :
|
||||||
LLlog = LLbits;
|
|
||||||
FSE_buildDTable_raw(DTableLL, LLbits);
|
FSE_buildDTable_raw(DTableLL, LLbits);
|
||||||
break;
|
break;
|
||||||
case FSE_ENCODING_STATIC:
|
case FSE_ENCODING_STATIC:
|
||||||
break;
|
break;
|
||||||
case FSE_ENCODING_DYNAMIC :
|
|
||||||
default : /* impossible */
|
default : /* impossible */
|
||||||
max = MaxLL;
|
case FSE_ENCODING_DYNAMIC :
|
||||||
headerSize = FSE_readNCount(norm, &max, &LLlog, ip, iend-ip);
|
{ U32 LLlog, max = MaxLL;
|
||||||
if (FSE_isError(headerSize)) return ERROR(GENERIC);
|
size_t const headerSize = FSE_readNCount(norm, &max, &LLlog, ip, iend-ip);
|
||||||
if (LLlog > LLFSELog) return ERROR(corruption_detected);
|
if (FSE_isError(headerSize)) return ERROR(GENERIC);
|
||||||
ip += headerSize;
|
if (LLlog > LLFSELog) return ERROR(corruption_detected);
|
||||||
FSE_buildDTable(DTableLL, norm, max, LLlog);
|
ip += headerSize;
|
||||||
|
FSE_buildDTable(DTableLL, norm, max, LLlog);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(Offtype)
|
switch(Offtype)
|
||||||
{
|
{
|
||||||
U32 max;
|
|
||||||
case FSE_ENCODING_RLE :
|
case FSE_ENCODING_RLE :
|
||||||
Offlog = 0;
|
|
||||||
if (ip > iend-2) return ERROR(srcSize_wrong); /* min : "raw", hence no header, but at least xxLog bits */
|
if (ip > iend-2) return ERROR(srcSize_wrong); /* min : "raw", hence no header, but at least xxLog bits */
|
||||||
FSE_buildDTable_rle(DTableOffb, *ip++ & MaxOff); /* if *ip > MaxOff, data is corrupted */
|
FSE_buildDTable_rle(DTableOffb, *ip++ & MaxOff); /* if *ip > MaxOff, data is corrupted */
|
||||||
break;
|
break;
|
||||||
case FSE_ENCODING_RAW :
|
case FSE_ENCODING_RAW :
|
||||||
Offlog = Offbits;
|
|
||||||
FSE_buildDTable_raw(DTableOffb, Offbits);
|
FSE_buildDTable_raw(DTableOffb, Offbits);
|
||||||
break;
|
break;
|
||||||
case FSE_ENCODING_STATIC:
|
case FSE_ENCODING_STATIC:
|
||||||
break;
|
break;
|
||||||
case FSE_ENCODING_DYNAMIC :
|
|
||||||
default : /* impossible */
|
default : /* impossible */
|
||||||
max = MaxOff;
|
case FSE_ENCODING_DYNAMIC :
|
||||||
headerSize = FSE_readNCount(norm, &max, &Offlog, ip, iend-ip);
|
{
|
||||||
if (FSE_isError(headerSize)) return ERROR(GENERIC);
|
U32 Offlog, max = MaxOff;
|
||||||
if (Offlog > OffFSELog) return ERROR(corruption_detected);
|
size_t const headerSize = FSE_readNCount(norm, &max, &Offlog, ip, iend-ip);
|
||||||
ip += headerSize;
|
if (FSE_isError(headerSize)) return ERROR(GENERIC);
|
||||||
FSE_buildDTable(DTableOffb, norm, max, Offlog);
|
if (Offlog > OffFSELog) return ERROR(corruption_detected);
|
||||||
|
ip += headerSize;
|
||||||
|
FSE_buildDTable(DTableOffb, norm, max, Offlog);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(MLtype)
|
switch(MLtype)
|
||||||
{
|
{
|
||||||
U32 max;
|
|
||||||
case FSE_ENCODING_RLE :
|
case FSE_ENCODING_RLE :
|
||||||
MLlog = 0;
|
|
||||||
if (ip > iend-2) return ERROR(srcSize_wrong); /* min : "raw", hence no header, but at least xxLog bits */
|
if (ip > iend-2) return ERROR(srcSize_wrong); /* min : "raw", hence no header, but at least xxLog bits */
|
||||||
FSE_buildDTable_rle(DTableML, *ip++);
|
FSE_buildDTable_rle(DTableML, *ip++);
|
||||||
break;
|
break;
|
||||||
case FSE_ENCODING_RAW :
|
case FSE_ENCODING_RAW :
|
||||||
MLlog = MLbits;
|
|
||||||
FSE_buildDTable_raw(DTableML, MLbits);
|
FSE_buildDTable_raw(DTableML, MLbits);
|
||||||
break;
|
break;
|
||||||
case FSE_ENCODING_STATIC:
|
case FSE_ENCODING_STATIC:
|
||||||
break;
|
break;
|
||||||
case FSE_ENCODING_DYNAMIC :
|
|
||||||
default : /* impossible */
|
default : /* impossible */
|
||||||
max = MaxML;
|
case FSE_ENCODING_DYNAMIC :
|
||||||
headerSize = FSE_readNCount(norm, &max, &MLlog, ip, iend-ip);
|
{ U32 MLlog, max = MaxML;
|
||||||
if (FSE_isError(headerSize)) return ERROR(GENERIC);
|
size_t const headerSize = FSE_readNCount(norm, &max, &MLlog, ip, iend-ip);
|
||||||
if (MLlog > MLFSELog) return ERROR(corruption_detected);
|
if (FSE_isError(headerSize)) return ERROR(GENERIC);
|
||||||
ip += headerSize;
|
if (MLlog > MLFSELog) return ERROR(corruption_detected);
|
||||||
FSE_buildDTable(DTableML, norm, max, MLlog);
|
ip += headerSize;
|
||||||
} }
|
FSE_buildDTable(DTableML, norm, max, MLlog);
|
||||||
|
}
|
||||||
|
} } /* Build DTables */
|
||||||
|
|
||||||
return ip-istart;
|
return ip-istart;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue