Fixed issue #34 and #31

This commit is contained in:
Yann Collet 2015-07-06 23:45:35 -08:00
parent effbd9811b
commit ee28a0def4

View File

@ -737,7 +737,7 @@ static size_t ZSTD_compressSequences(BYTE* dst, size_t maxDstSize,
/* Encoding table of Literal Lengths */ /* Encoding table of Literal Lengths */
max = MaxLL; max = MaxLL;
mostFrequent = FSE_countFast(count, &max, seqStorePtr->litLengthStart, nbSeq); mostFrequent = FSE_countFast(count, &max, seqStorePtr->litLengthStart, nbSeq);
if (mostFrequent == nbSeq) if ((mostFrequent == nbSeq) && (nbSeq > 2))
{ {
*op++ = *(seqStorePtr->litLengthStart); *op++ = *(seqStorePtr->litLengthStart);
FSE_buildCTable_rle(CTable_LitLength, (BYTE)max); FSE_buildCTable_rle(CTable_LitLength, (BYTE)max);
@ -771,7 +771,7 @@ static size_t ZSTD_compressSequences(BYTE* dst, size_t maxDstSize,
offsetBitsPtr += nbSeq; offsetBitsPtr += nbSeq;
mostFrequent = FSE_countFast(count, &max, offsetBits_start, nbSeq); mostFrequent = FSE_countFast(count, &max, offsetBits_start, nbSeq);
} }
if (mostFrequent == nbSeq) if ((mostFrequent == nbSeq) && (nbSeq > 2))
{ {
*op++ = *offsetBits_start; *op++ = *offsetBits_start;
FSE_buildCTable_rle(CTable_OffsetBits, (BYTE)max); FSE_buildCTable_rle(CTable_OffsetBits, (BYTE)max);
@ -794,7 +794,7 @@ static size_t ZSTD_compressSequences(BYTE* dst, size_t maxDstSize,
/* Encoding Table of MatchLengths */ /* Encoding Table of MatchLengths */
max = MaxML; max = MaxML;
mostFrequent = FSE_countFast(count, &max, seqStorePtr->matchLengthStart, nbSeq); mostFrequent = FSE_countFast(count, &max, seqStorePtr->matchLengthStart, nbSeq);
if (mostFrequent == nbSeq) if ((mostFrequent == nbSeq) && (nbSeq > 2))
{ {
*op++ = *seqStorePtr->matchLengthStart; *op++ = *seqStorePtr->matchLengthStart;
FSE_buildCTable_rle(CTable_MatchLength, (BYTE)max); FSE_buildCTable_rle(CTable_MatchLength, (BYTE)max);