public static size_t FSE_decompress_usingDTable_generic()

in csharp/src/FseDecompress.cs [233:295]


		public static size_t FSE_decompress_usingDTable_generic(void* dst, size_t maxDstSize, void* cSrc, size_t cSrcSize, FSE_DTable* dt, uint fast)
		{
			BYTE* ostart = (BYTE*)dst;
			BYTE* op = ostart;
			BYTE* omax = op + maxDstSize;
			BYTE* olimit = omax - 3;

			BIT_DStream_t bitD = new BIT_DStream_t();
			FSE_DState_t state1 = new FSE_DState_t();
			FSE_DState_t state2 = new FSE_DState_t();

			/* Init */
			{ size_t errcod = InitDStream(bitD, cSrc, cSrcSize); if (IsError(errcod)) return errcod; }

			Fse.InitDState(state1, bitD, dt);
			Fse.InitDState(state2, bitD, dt);

			//#define FSE_GETSYMBOL(statePtr) fast ? DecodeSymbolFast(statePtr, &bitD) : DecodeSymbol(statePtr, &bitD)

			/* 4 symbols per loop */
			for (; (ReloadDStream(bitD) == BIT_DStream_status.BIT_DStream_unfinished) & (op < olimit); op += 4)
			{
				op[0] = fast != 0 ? DecodeSymbolFast(state1, bitD) : DecodeSymbol(state1, bitD);

				//if (FSE_MAX_TABLELOG * 2 + 7 > sizeOfBitContainer * 8)    /* This test must be static */
				//	ReloadDStream(bitD);

				op[1] = fast != 0 ? DecodeSymbolFast(state2, bitD) : DecodeSymbol(state2, bitD);

				if (FSE_MAX_TABLELOG * 4 + 7 > sizeOfBitContainer * 8)    /* This test must be static */
				{ if (ReloadDStream(bitD) > BIT_DStream_status.BIT_DStream_unfinished) { op += 2; break; } }

				op[2] = fast != 0 ? DecodeSymbolFast(state1, bitD) : DecodeSymbol(state1, bitD);

				//if (FSE_MAX_TABLELOG * 2 + 7 > sizeOfBitContainer * 8)    /* This test must be static */
				//	ReloadDStream(bitD);

				op[3] = fast != 0 ? DecodeSymbolFast(state2, bitD) : DecodeSymbol(state2, bitD);
			}

			/* tail */
			/* note : ReloadDStream(&bitD) >= FSE_DStream_partiallyFilled; Ends at exactly BIT_DStream_completed */
			while (true)
			{
				if (op > (omax - 2)) return ERROR(Error.dstSize_tooSmall);
				*op++ = fast != 0 ? DecodeSymbolFast(state1, bitD) : DecodeSymbol(state1, bitD);
				if (ReloadDStream(bitD) == BIT_DStream_status.BIT_DStream_overflow)
				{
					*op++ = fast != 0 ? DecodeSymbolFast(state2, bitD) : DecodeSymbol(state2, bitD);
					break;
				}

				if (op > (omax - 2)) return ERROR(Error.dstSize_tooSmall);
				*op++ = fast != 0 ? DecodeSymbolFast(state2, bitD) : DecodeSymbol(state2, bitD);
				if (ReloadDStream(bitD) == BIT_DStream_status.BIT_DStream_overflow)
				{
					*op++ = fast != 0 ? DecodeSymbolFast(state1, bitD) : DecodeSymbol(state1, bitD);
					break;
				}
			}

			return (size_t)(op - ostart);
		}