From: Yann Collet Date: Wed, 26 Aug 2015 18:22:01 +0000 (+0100) Subject: Updated FSE X-Git-Tag: v0.1.1^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b5198fe3abf77b25d978e2f1cc448086de1dd64;p=thirdparty%2Fzstd.git Updated FSE --- diff --git a/lib/fse.c b/lib/fse.c index 6871a19e3..9221151ac 100644 --- a/lib/fse.c +++ b/lib/fse.c @@ -135,7 +135,7 @@ typedef signed long long S64; * Method 1 : `__packed` statement. It depends on compiler extension (ie, not portable). * This method is safe if your compiler supports it, and *generally* as fast or faster than `memcpy`. * Method 2 : direct access. This method is portable but violate C standard. - * It can generate buggy code on targets which generate assembly depending on alignment. + * It can generate buggy code on targets generating assembly depending on alignment. * But in some circumstances, it's the only known way to get the most performance (ie GCC + ARMv6) * See http://fastcompression.blogspot.fr/2015/08/accessing-unaligned-memory.html for details. * Prefer these methods in priority order (0 > 1 > 2) @@ -1398,6 +1398,7 @@ size_t FSE_compress2 (void* dst, size_t dstSize, const void* src, size_t srcSize errorCode = FSE_count (count, &maxSymbolValue, ip, srcSize); if (FSE_isError(errorCode)) return errorCode; if (errorCode == srcSize) return 1; + if (errorCode == 1) return 0; /* each symbol only present once */ if (errorCode < (srcSize >> 7)) return 0; /* Heuristic : not compressible enough */ tableLog = FSE_optimalTableLog(tableLog, srcSize, maxSymbolValue); @@ -1534,7 +1535,7 @@ static size_t FSE_lookBits(FSE_DStream_t* bitD, U32 nbBits) static size_t FSE_lookBitsFast(FSE_DStream_t* bitD, U32 nbBits) /* only if nbBits >= 1 !! */ { - return (bitD->bitContainer << bitD->bitsConsumed) >> ((sizeof(bitD->bitContainer)*8)-nbBits); + return (bitD->bitContainer << (bitD->bitsConsumed & ((sizeof(bitD->bitContainer)*8)-1))) >> ((sizeof(bitD->bitContainer)*8)-nbBits); } static void FSE_skipBits(FSE_DStream_t* bitD, U32 nbBits)