📄 inflate.c
字号:
srcLenMT = 0;
} /* if */
retStatusMT = ippsDecodeLZ77_8u(&pPairMT, &srcLenMT, &pDst, &dstLenMT, ippflush, pLZ77StateMT);
if((retStatusMT == ippStsNoErr) && (state->lastBlockLZ77 == 1))
retStatusMT = ippStsStreamEnd;
state->decodeLZ77Status = retStatusMT;
strm->next_out = pDst;
strm->avail_out = dstLenMT;
pairsIndMT = pPairMT - pPairConstMT;
if(retStatusMT == ippStsNoErr)
{
ippsDecodeLZ77SetPairs_8u(pPairConstMT, 0, pairsLenConstMT, pLZ77StateMT);
}
else if(retStatusMT == ippStsDstSizeLessExpected)
{
ippsDecodeLZ77SetPairs_8u(pPairConstMT, pairsIndMT, pairsLenConstMT, pLZ77StateMT);
}
else if(retStatusMT == ippStsStreamEnd)
{
ippsDecodeLZ77SetPairs_8u(pPairConstMT, 0, pairsIndMT, pLZ77StateMT);
} /* if else */
/* END OF SECTION 2. */
} /* pragma omp section */
} /* pragma omp parallel sections */
/* Sequential block: */
/* here must be the check of returned statuses by Huffman and LZ77. */
/* after check - take a descision to swap (and call SWAP_PAIRS) or not */
/* and, if not, - goto inf_leave. Third variant is ippStsStreamEnd and */
/* we must break and set inflateStatus to Final. */
decodeHuffStatus = state->decodeHuffStatus;
decodeLZ77Status = state->decodeLZ77Status;
if(decodeHuffStatus == ippStsStreamEnd)
{
state->lastBlockHuff = 1;
if(decodeLZ77Status == ippStsNoErr)
{
SWAP_PAIRS(pPairConstSW, pPairConstSWMT, pairsIndSW, pairsIndSWMT, pairsLenConstSW, pairsLenConstSWMT, state);
state->lastBlockLZ77 = 1;
}
else if(decodeLZ77Status == ippStsDstSizeLessExpected)
{
inflateStatus = IppLZ77InflateStatusHuffProcess;
ippsDecodeLZ77SetStatus_8u(inflateStatus, pLZ77State);
ret = Z_OK;
goto inf_leave;
}
else if(decodeLZ77Status == ippStsStreamEnd)
{
inflateStatus = IppLZ77InflateStatusFinal;
ippsDecodeLZ77SetStatus_8u(inflateStatus, pLZ77State);
break;
}
else
{
ret = Z_DATA_ERROR;
goto inf_leave;
} /* if else */
} /* if */
else if(decodeHuffStatus == ippStsDstSizeLessExpected)
{
if(decodeLZ77Status == ippStsNoErr) /* !!!! we gamble on it !!!! */
{
SWAP_PAIRS(pPairConstSW, pPairConstSWMT, pairsIndSW, pairsIndSWMT, pairsLenConstSW, pairsLenConstSWMT, state);
}
else if(decodeLZ77Status == ippStsDstSizeLessExpected)
{
ippsDecodeLZ77SetPairs_8u(pPairConst, pairsInd, pairsLenConst, pLZ77State);
inflateStatus = IppLZ77InflateStatusHuffProcess;
ippsDecodeLZ77SetStatus_8u(inflateStatus, pLZ77State);
ret = Z_OK;
goto inf_leave;
}
else
{
ret = Z_DATA_ERROR;
goto inf_leave;
} /* if else */
}
else if(decodeHuffStatus == ippStsNoErr)
{
if(decodeLZ77Status == ippStsDstSizeLessExpected)
{
inflateStatus = IppLZ77InflateStatusHuffProcess;
ippsDecodeLZ77SetStatus_8u(inflateStatus, pLZ77State);
ret = Z_OK;
goto inf_leave;
}
else if(decodeLZ77Status == ippStsStreamEnd || decodeLZ77Status < 0)
{
ret = Z_DATA_ERROR;
goto inf_leave;
}
else if(decodeLZ77Status == ippStsNoErr)
{
ippsDecodeLZ77SetPairs_8u(pPairConstMT, pairsIndMT, pairsLenConstMT, pLZ77StateMT);
} /* if else */
}
else if(decodeHuffStatus == ippStsSrcSizeLessExpected)
{
if(decodeLZ77Status == ippStsNoErr)
{
ippsDecodeLZ77SetPairs_8u(pPairConstMT, pairsIndMT, pairsLenConstMT, pLZ77StateMT);
inflateStatus = IppLZ77InflateStatusHuffProcess;
ippsDecodeLZ77SetStatus_8u(inflateStatus, pLZ77State);
ret = Z_OK;
goto inf_leave;
}
else if(decodeLZ77Status == ippStsDstSizeLessExpected)
{
inflateStatus = IppLZ77InflateStatusHuffProcess;
ippsDecodeLZ77SetStatus_8u(inflateStatus, pLZ77State);
ret = Z_OK;
goto inf_leave;
}
else
{
ret = Z_DATA_ERROR;
goto inf_leave;
} /* if else */
}
else
{
ret = Z_DATA_ERROR;
goto inf_leave;
} /* if else */
} /* SPOTTY FOR flush != Z_BLOCK */
} /* IF inflateStatus == IppLZ77InflateStatusHuffProcess */
} /* if flush != Z_BLOCK: 2-thread paralellized spot */
else
{
for( ; ; ) /* SPOTTY FOR flush == Z_BLOCK */
{
ippsDecodeLZ77GetStatus_8u(&inflateStatus, pLZ77State);
ippsDecodeLZ77GetPairs_8u(&pPairConst, &pairsInd, &pairsLenConst, pLZ77State);
if(inflateStatus == IppLZ77InflateStatusHuffProcess)
{
pSrc = strm->next_in;
srcLen = strm->avail_in;
retStatus = ippsDecodeLZ77GetBlockType_8u(&pSrc, &srcLen, &huffMode, pLZ77State);
strm->avail_in = srcLen;
strm->next_in = pSrc;
if(retStatus == ippStsNoErr)
{
if(huffMode == IppLZ77UseFixed)
{
pPair = pPairConst + pairsInd;
dstLen = pairsLenConst - pairsInd;
pSrc = strm->next_in;
srcLen = strm->avail_in;
retStatus = ippsDecodeLZ77FixedHuff_8u(&pSrc, &srcLen, &pPair, &dstLen, ippflush, pLZ77State);
strm->next_in = pSrc;
strm->avail_in = srcLen;
pairsInd = pPair - pPairConst;
if(retStatus == ippStsNoErr)
{
ippsDecodeLZ77SetPairs_8u(pPairConst, pairsInd, pairsLenConst, pLZ77State);
state->blockEnd = 1;
inflateStatus = IppLZ77InflateStatusLZ77Process;
ippsDecodeLZ77SetPairs_8u(pPairConst, 0, pairsInd, pLZ77State);
}
else if(retStatus == ippStsDstSizeLessExpected || retStatus == ippStsStreamEnd)
{
inflateStatus = IppLZ77InflateStatusLZ77Process;
ippsDecodeLZ77SetPairs_8u(pPairConst, 0, pairsInd, pLZ77State);
if(retStatus == ippStsStreamEnd)
state->headerMode = infhead;
}
else if(retStatus == ippStsSrcSizeLessExpected)
{
ippsDecodeLZ77SetPairs_8u(pPairConst, pairsInd, pairsLenConst, pLZ77State);
ret = Z_OK;
goto inf_leave;
} /* if else */
ippsDecodeLZ77SetStatus_8u(inflateStatus, pLZ77State);
}
else if(huffMode == IppLZ77UseDynamic)
{
pPair = pPairConst + pairsInd;
dstLen = pairsLenConst - pairsInd;
pSrc = strm->next_in;
srcLen = strm->avail_in;
retStatus = ippsDecodeLZ77DynamicHuff_8u(&pSrc, &srcLen, &pPair, &dstLen, ippflush, pLZ77State);
strm->next_in = pSrc;
strm->avail_in = srcLen;
pairsInd = pPair - pPairConst;
if(retStatus == ippStsNoErr)
{
ippsDecodeLZ77SetPairs_8u(pPairConst, pairsInd, pairsLenConst, pLZ77State);
state->blockEnd = 1;
inflateStatus = IppLZ77InflateStatusLZ77Process;
ippsDecodeLZ77SetPairs_8u(pPairConst, 0, pairsInd, pLZ77State);
}
else if(retStatus == ippStsDstSizeLessExpected || retStatus == ippStsStreamEnd)
{
inflateStatus = IppLZ77InflateStatusLZ77Process;
ippsDecodeLZ77SetPairs_8u(pPairConst, 0, pairsInd, pLZ77State);
if(retStatus == ippStsStreamEnd)
state->headerMode = infhead;
}
else if(retStatus == ippStsSrcSizeLessExpected)
{
ippsDecodeLZ77SetPairs_8u(pPairConst, pairsInd, pairsLenConst, pLZ77State);
ret = Z_OK;
goto inf_leave;
} /* if else */
ippsDecodeLZ77SetStatus_8u(inflateStatus, pLZ77State);
}
else if(huffMode == IppLZ77UseStored)
{
pSrc = strm->next_in;
srcLen = strm->avail_in;
pDst = strm->next_out;
dstLen = strm->avail_out;
retStatus = ippsDecodeLZ77StoredBlock_8u(&pSrc, &srcLen, &pDst, &dstLen, pLZ77State);
strm->next_in = pSrc;
strm->avail_in = srcLen;
strm->next_out = pDst;
strm->avail_out = dstLen;
if(retStatus == ippStsNoErr)
{
inflateStatus = IppLZ77InflateStatusHuffProcess;
}
else if(retStatus == ippStsStreamEnd)
{
inflateStatus = IppLZ77InflateStatusFinal;
state->headerMode = infhead;
break;
}
else if(retStatus == ippStsDstSizeLessExpected || retStatus == ippStsSrcSizeLessExpected)
{
ret = Z_OK;
goto inf_leave;
}
else
{
ret = Z_DATA_ERROR;
goto inf_leave;
} /* if else */
ippsDecodeLZ77SetStatus_8u(inflateStatus, pLZ77State);
} /* if else */
}
else if(retStatus == ippStsSrcSizeLessExpected)
{
ret = Z_OK;
goto inf_leave;
}
else
{
ret = Z_DATA_ERROR;
goto inf_leave;
} /* if else */
} /* IppLZ77InflateStatusHuffProcess */
ippsDecodeLZ77GetStatus_8u(&inflateStatus, pLZ77State);
ippsDecodeLZ77GetPairs_8u(&pPairConst, &pairsInd, &pairsLenConst, pLZ77State);
if(inflateStatus == IppLZ77InflateStatusLZ77Process)
{
pPair = pPairConst + pairsInd;
srcLen = pairsLenConst - pairsInd;
pDst = strm->next_out;
dstLen = strm->avail_out;
retStatus = ippsDecodeLZ77_8u(&pPair, &srcLen, &pDst, &dstLen, ippflush, pLZ77State);
strm->next_out = pDst;
strm->avail_out = dstLen;
pairsInd = pPair - pPairConst;
if(retStatus == ippStsNoErr)
{
ippsDecodeLZ77SetPairs_8u(pPairConst, 0, pairsInd, pLZ77State);
inflateStatus = IppLZ77InflateStatusHuffProcess;
if((flush == Z_BLOCK) && (state->blockEnd == 1))
{
ippsDecodeLZ77SetStatus_8u(inflateStatus, pLZ77State);
ret = Z_OK;
state->blockEnd = 0;
goto inf_leave;
} /* if */
}
else if(retStatus == ippStsDstSizeLessExpected)
{
ippsDecodeLZ77SetPairs_8u(pPairConst, pairsInd, pairsLenConst, pLZ77State);
ret = Z_OK;
goto inf_leave;
}
else if(retStatus == ippStsStreamEnd)
{
ippsDecodeLZ77SetPairs_8u(pPairConst, 0, pairsInd, pLZ77State);
inflateStatus = IppLZ77InflateStatusFinal;
ippsDecodeLZ77SetStatus_8u(inflateStatus, pLZ77State);
break;
}
else
{
ret = Z_DATA_ERROR;
goto inf_leave;
} /* if else */
ippsDecodeLZ77SetStatus_8u(inflateStatus, pLZ77State);
} /* IppLZ77InflateStatusLZ77Process */
} /* SPOTTY FOR flush == Z_BLOCK */
} /* if flush == Z_BLOCK: single thread execution without OMP */
ippsDecodeLZ77GetStatus_8u(&inflateStatus, pLZ77State);
ippsDecodeLZ77GetPairs_8u(&pPairConst, &pairsInd, &pairsLenConst, pLZ77State);
if(inflateStatus == IppLZ77InflateStatusFinal)
{
state->decodeHuffStatus = ippStsNoErr;
state->decodeLZ77Status = ippStsNoErr;
state->lastBlockHuff = 0;
state->lastBlockLZ77 = 0;
state->firstSwapDone = 0;
ret = Z_STREAM_END;
goto inf_leave;
} /* IppLZ77InflateStatusFinal */
goto next_iteration;
inf_leave:
in -= strm->avail_in;
out -= strm->avail_out;
strm->total_in += in;
strm->total_out += out;
if(out) strm->adler = state->check = UPDATE(state->check, strm->next_out - out, out);
if(ret == Z_STREAM_END && state->wrap)
{
while(state->headerBits < 32)
{
if(strm->avail_in == 0) return Z_OK;
(strm->avail_in)--;
state->headerBuf += ((*(strm->next_in)) << state->headerBits);
(strm->next_in)++;
(strm->total_in)++;
state->headerBits += 8;
} /* while */
if((
#ifdef GUNZIP
state->headerFlags ? state->headerBuf:
#endif
REVERSE(state->headerBuf)) != (int)(state->check) )
{
ret = Z_DATA_ERROR;
} /* if */
} /* if */
return ret;
} /* parallel inflate() */
#else /* else - means if either INFLATE_OMP or _OPENMP undefined: */
int ZEXPORT inflate(strm, flush)
z_streamp strm;
int flush;
{
struct inflate_state FAR *state = (struct inflate_state FAR *)strm->state;
IppLZ77State_8u* pLZ77State = (IppLZ77State_8u*) state->ipp_state;
IppLZ77InflateStatus inflateStatus;
IppStatus retStatus;
IppLZ77Flush ippflush = IppLZ77NoFlush;
IppLZ77HuffMode huffMode;
unsigned int in = strm->avail_in;
unsigned int out = strm->avail_out;
int ret;
next_iteration:
ippsDecodeLZ77GetStatus_8u( &inflateStatus, pLZ77State );
if( inflateStatus == IppLZ77InflateStatusHuffProcess ) {
ret = Z_OK;
if( flush == Z_BLOCK ) state->blockEnd = 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -