Lines Matching refs:bitC

763 static size_t HUF_initCStream(HUF_CStream_t* bitC,  in HUF_initCStream()  argument
766 ZSTD_memset(bitC, 0, sizeof(*bitC)); in HUF_initCStream()
767 bitC->startPtr = (BYTE*)startPtr; in HUF_initCStream()
768 bitC->ptr = bitC->startPtr; in HUF_initCStream()
769 bitC->endPtr = bitC->startPtr + dstCapacity - sizeof(bitC->bitContainer[0]); in HUF_initCStream()
770 if (dstCapacity <= sizeof(bitC->bitContainer[0])) return ERROR(dstSize_tooSmall); in HUF_initCStream()
784 FORCE_INLINE_TEMPLATE void HUF_addBits(HUF_CStream_t* bitC, HUF_CElt elt, int idx, int kFast) in HUF_addBits() argument
793 bitC->bitContainer[idx] >>= HUF_getNbBits(elt); in HUF_addBits()
794 bitC->bitContainer[idx] |= kFast ? HUF_getValueFast(elt) : HUF_getValue(elt); in HUF_addBits()
798 bitC->bitPos[idx] += HUF_getNbBitsFast(elt); in HUF_addBits()
799 assert((bitC->bitPos[idx] & 0xFF) <= HUF_BITS_IN_CONTAINER); in HUF_addBits()
812 assert(!kFast || (bitC->bitPos[idx] & 0xFF) <= HUF_BITS_IN_CONTAINER); in HUF_addBits()
818 FORCE_INLINE_TEMPLATE void HUF_zeroIndex1(HUF_CStream_t* bitC) in HUF_zeroIndex1() argument
820 bitC->bitContainer[1] = 0; in HUF_zeroIndex1()
821 bitC->bitPos[1] = 0; in HUF_zeroIndex1()
828 FORCE_INLINE_TEMPLATE void HUF_mergeIndex1(HUF_CStream_t* bitC) in HUF_mergeIndex1() argument
830 assert((bitC->bitPos[1] & 0xFF) < HUF_BITS_IN_CONTAINER); in HUF_mergeIndex1()
831 bitC->bitContainer[0] >>= (bitC->bitPos[1] & 0xFF); in HUF_mergeIndex1()
832 bitC->bitContainer[0] |= bitC->bitContainer[1]; in HUF_mergeIndex1()
833 bitC->bitPos[0] += bitC->bitPos[1]; in HUF_mergeIndex1()
834 assert((bitC->bitPos[0] & 0xFF) <= HUF_BITS_IN_CONTAINER); in HUF_mergeIndex1()
844 FORCE_INLINE_TEMPLATE void HUF_flushBits(HUF_CStream_t* bitC, int kFast) in HUF_flushBits() argument
847 size_t const nbBits = bitC->bitPos[0] & 0xFF; in HUF_flushBits()
850 size_t const bitContainer = bitC->bitContainer[0] >> (HUF_BITS_IN_CONTAINER - nbBits); in HUF_flushBits()
852 bitC->bitPos[0] &= 7; in HUF_flushBits()
854 assert(nbBits <= sizeof(bitC->bitContainer[0]) * 8); in HUF_flushBits()
855 assert(bitC->ptr <= bitC->endPtr); in HUF_flushBits()
856 MEM_writeLEST(bitC->ptr, bitContainer); in HUF_flushBits()
857 bitC->ptr += nbBytes; in HUF_flushBits()
858 assert(!kFast || bitC->ptr <= bitC->endPtr); in HUF_flushBits()
859 if (!kFast && bitC->ptr > bitC->endPtr) bitC->ptr = bitC->endPtr; in HUF_flushBits()
880 static size_t HUF_closeCStream(HUF_CStream_t* bitC) in HUF_closeCStream() argument
882 HUF_addBits(bitC, HUF_endMark(), /* idx */ 0, /* kFast */ 0); in HUF_closeCStream()
883 HUF_flushBits(bitC, /* kFast */ 0); in HUF_closeCStream()
885 size_t const nbBits = bitC->bitPos[0] & 0xFF; in HUF_closeCStream()
886 if (bitC->ptr >= bitC->endPtr) return 0; /* overflow detected */ in HUF_closeCStream()
887 return (bitC->ptr - bitC->startPtr) + (nbBits > 0); in HUF_closeCStream()
898 HUF_compress1X_usingCTable_internal_body_loop(HUF_CStream_t* bitC, in HUF_compress1X_usingCTable_internal_body_loop() argument
908 HUF_encodeSymbol(bitC, ip[--n], ct, 0, /* fast */ 0); in HUF_compress1X_usingCTable_internal_body_loop()
910 HUF_flushBits(bitC, kFastFlush); in HUF_compress1X_usingCTable_internal_body_loop()
918 HUF_encodeSymbol(bitC, ip[n - u], ct, 0, 1); in HUF_compress1X_usingCTable_internal_body_loop()
920 HUF_encodeSymbol(bitC, ip[n - kUnroll], ct, 0, kLastFast); in HUF_compress1X_usingCTable_internal_body_loop()
921 HUF_flushBits(bitC, kFastFlush); in HUF_compress1X_usingCTable_internal_body_loop()
930 HUF_encodeSymbol(bitC, ip[n - u], ct, /* idx */ 0, /* fast */ 1); in HUF_compress1X_usingCTable_internal_body_loop()
932 HUF_encodeSymbol(bitC, ip[n - kUnroll], ct, /* idx */ 0, /* fast */ kLastFast); in HUF_compress1X_usingCTable_internal_body_loop()
933 HUF_flushBits(bitC, kFastFlush); in HUF_compress1X_usingCTable_internal_body_loop()
938 HUF_zeroIndex1(bitC); in HUF_compress1X_usingCTable_internal_body_loop()
940 HUF_encodeSymbol(bitC, ip[n - kUnroll - u], ct, /* idx */ 1, /* fast */ 1); in HUF_compress1X_usingCTable_internal_body_loop()
942 HUF_encodeSymbol(bitC, ip[n - kUnroll - kUnroll], ct, /* idx */ 1, /* fast */ kLastFast); in HUF_compress1X_usingCTable_internal_body_loop()
944 HUF_mergeIndex1(bitC); in HUF_compress1X_usingCTable_internal_body_loop()
945 HUF_flushBits(bitC, kFastFlush); in HUF_compress1X_usingCTable_internal_body_loop()
973 HUF_CStream_t bitC; in HUF_compress1X_usingCTable_internal_body() local
977 { size_t const initErr = HUF_initCStream(&bitC, op, (size_t)(oend-op)); in HUF_compress1X_usingCTable_internal_body()
981 …HUF_compress1X_usingCTable_internal_body_loop(&bitC, ip, srcSize, ct, /* kUnroll */ MEM_32bits() ?… in HUF_compress1X_usingCTable_internal_body()
986 …HUF_compress1X_usingCTable_internal_body_loop(&bitC, ip, srcSize, ct, /* kUnroll */ 2, /* kFastFlu… in HUF_compress1X_usingCTable_internal_body()
991 …HUF_compress1X_usingCTable_internal_body_loop(&bitC, ip, srcSize, ct, /* kUnroll */ 2, /* kFastFlu… in HUF_compress1X_usingCTable_internal_body()
995 …HUF_compress1X_usingCTable_internal_body_loop(&bitC, ip, srcSize, ct, /* kUnroll */ 3, /* kFastFlu… in HUF_compress1X_usingCTable_internal_body()
1001 …HUF_compress1X_usingCTable_internal_body_loop(&bitC, ip, srcSize, ct, /* kUnroll */ 5, /* kFastFlu… in HUF_compress1X_usingCTable_internal_body()
1004 …HUF_compress1X_usingCTable_internal_body_loop(&bitC, ip, srcSize, ct, /* kUnroll */ 5, /* kFastFlu… in HUF_compress1X_usingCTable_internal_body()
1007 …HUF_compress1X_usingCTable_internal_body_loop(&bitC, ip, srcSize, ct, /* kUnroll */ 6, /* kFastFlu… in HUF_compress1X_usingCTable_internal_body()
1010 …HUF_compress1X_usingCTable_internal_body_loop(&bitC, ip, srcSize, ct, /* kUnroll */ 7, /* kFastFlu… in HUF_compress1X_usingCTable_internal_body()
1013 …HUF_compress1X_usingCTable_internal_body_loop(&bitC, ip, srcSize, ct, /* kUnroll */ 8, /* kFastFlu… in HUF_compress1X_usingCTable_internal_body()
1017 …HUF_compress1X_usingCTable_internal_body_loop(&bitC, ip, srcSize, ct, /* kUnroll */ 9, /* kFastFlu… in HUF_compress1X_usingCTable_internal_body()
1022 assert(bitC.ptr <= bitC.endPtr); in HUF_compress1X_usingCTable_internal_body()
1024 return HUF_closeCStream(&bitC); in HUF_compress1X_usingCTable_internal_body()