📄 inflate.c
字号:
out = strm->avail_out;
state = (struct inflate_state FAR *) strm->state;
pLZ77State = (IppLZ77State_8u*) state->ipp_state;
ippflush = IppLZ77NoFlush;
next_iteration:
ippsDecodeLZ77GetStatus_8u(&inflateStatus, pLZ77State);
if(inflateStatus == IppLZ77InflateStatusInit)
{
/* processing GZIP or ZLIB header */
for( ; ; )
{
if(state->headerMode == infhead)
{
if (state->wrap == 0)
{
state->headerBits = 0;
state->headerBuf = 0;
state->headerMode = infmain;
break;
} /* if */
while(state->headerBits < 16)
{
if(strm->avail_in == 0)
{
ret = Z_OK;
goto inf_leave;
} /* if */
(strm->avail_in)--;
state->headerBuf += ((*(strm->next_in)) << state->headerBits);
(strm->next_in)++;
state->headerBits += 8;
} /* while */
#ifdef GUNZIP
if( state->wrap & 2 )
{ /* gzip header */
if (state->headerBuf == 0x8b1f)
{
state->check = crc32(0, Z_NULL, 0);
state->headerBuf = 0;
state->headerBits = 0;
state->headerMode = infflags;
}
else
{
ret = Z_DATA_ERROR;
goto inf_leave;
} /* if else */
}
if (!(state->wrap & 1) || /* check if zlib header allowed */
#else
if(
#endif
(((state->headerBuf & 0xff) << 8) + ((state->headerBuf)>>8))%31 )
{
ret = Z_DATA_ERROR;
goto inf_leave;
}
else
{
strm->adler = state->check = adler32(0, Z_NULL, 0);
state->headerMode = infmain;
if( (state->headerBuf >> 4) & 0x200) state->headerMode = infdictid;
state->headerBuf = 0;
state->headerBits = 0;
} /* if else */
} /* infhead */
else if(state->headerMode == infflags)
{
while(state->headerBits < 16)
{
if(strm->avail_in == 0)
{
ret = Z_OK;
goto inf_leave;
} /* if */
(strm->avail_in)--;
state->headerBuf += ((*(strm->next_in)) << state->headerBits);
(strm->next_in)++;
state->headerBits += 8;
} /* while */
state->headerFlags = state->headerBuf;
if((state->headerFlags & 0xff) != Z_DEFLATED)
{
ret = Z_DATA_ERROR;
goto inf_leave;
} /* if */
if(state->headerFlags & 0xe000)
{
ret = Z_DATA_ERROR;
goto inf_leave;
} /* if */
state->headerBuf = 0;
state->headerBits = 0;
state->headerMode = inftime;
} /* infflags */
else if(state->headerMode == inftime)
{
while(state->headerBits < 32)
{
if(strm->avail_in == 0)
{
ret = Z_OK;
goto inf_leave;
} /* if */
(strm->avail_in)--;
state->headerBuf += ((*(strm->next_in)) << state->headerBits);
(strm->next_in)++;
state->headerBits += 8;
} /* while */
state->headerBuf = 0;
state->headerBits = 0;
state->headerMode = infos;
} /* inftime */
else if(state->headerMode == infos)
{
while(state->headerBits < 16)
{
if(strm->avail_in == 0)
{
ret = Z_OK;
goto inf_leave;
} /* if */
(strm->avail_in)--;
state->headerBuf += ((*(strm->next_in)) << state->headerBits);
(strm->next_in)++;
state->headerBits += 8;
} /* while */
state->headerBuf = 0;
state->headerBits = 0;
state->headerMode = infexlen;
} /* infos */
else if(state->headerMode == infexlen)
{
if(state->headerFlags & 0x0400)
{
while(state->headerBits < 16)
{
if(strm->avail_in == 0)
{
ret = Z_OK;
goto inf_leave;
} /* if */
(strm->avail_in)--;
state->headerBuf += ((*(strm->next_in)) << state->headerBits);
(strm->next_in)++;
state->headerBits += 8;
} /* while */
state->headerLength = state->headerBuf;
state->headerBuf = 0;
state->headerBits = 0;
} /* if */
state->headerMode = infextra;
} /* infexlen */
else if(state->headerMode == infextra)
{
if(state->headerFlags & 0x0400)
{
copy = state->headerLength;
if(copy > (int)strm->avail_in) copy = strm->avail_in;
if(copy) {
strm->avail_in -= copy;
strm->next_in += copy;
state->headerLength -= copy;
} /* if */
if(state->headerLength)
{
ret = Z_OK;
goto inf_leave;
} /* if */
}
state->headerMode = infname;
} /* infextra */
else if(state->headerMode == infname)
{
if(state->headerFlags & 0x0800)
{
if(strm->avail_in == 0)
{
ret = Z_OK;
goto inf_leave;
} /* if */
copy = 0;
do {
len = (unsigned int)(strm->next_in[copy++]);
} while (len && copy < strm->avail_in);
strm->avail_in -= copy;
strm->next_in += copy;
if(len)
{
ret = Z_OK;
goto inf_leave;
} /* if */
} /* if */
state->headerMode = infcomment;
} /* infname */
else if(state->headerMode == infcomment)
{
if(state->headerFlags & 0x1000)
{
if(strm->avail_in == 0)
{
ret = Z_OK;
goto inf_leave;
} /* if */
copy = 0;
do{
len = (unsigned int)(strm->next_in[copy++]);
}while(len && copy < strm->avail_in);
strm->avail_in -= copy;
strm->next_in += copy;
if(len)
{
ret = Z_OK;
goto inf_leave;
} /* if */
} /* if */
state->headerMode = infhcrc;
} /* infcomment */
else if(state->headerMode == infhcrc)
{
if(state->headerFlags & 0x0200)
{
while(state->headerBits < 16)
{
if(strm->avail_in == 0)
{
ret = Z_OK;
goto inf_leave;
} /* if */
(strm->avail_in)--;
state->headerBuf += ((*(strm->next_in)) << state->headerBits);
(strm->next_in)++;
state->headerBits += 8;
} /* while */
state->headerBuf = 0;
state->headerBits = 0;
} /* if */
state->headerMode = infmain;
} /* infhcrc */
if(state->headerMode == infmain)
{
state->headerBits = 0;
state->headerBuf = 0;
break;
} /* if infmain */
if(state->headerMode == infdictid)
{
while(state->headerBits < 32)
{
if(strm->avail_in == 0)
{
ret = Z_OK;
goto inf_leave;
} /* if */
(strm->avail_in)--;
state->headerBuf += ((*(strm->next_in)) << state->headerBits);
(strm->next_in)++;
state->headerBits += 8;
} /* while */
strm->adler = state->check = REVERSE(state->headerBuf);
state->headerBits = 0;
state->headerBuf = 0;
state->headerMode = infdict;
} /* if infdictid */
if(state->headerMode == infdict)
{
if(state->havedict == 0)
{
ret = Z_NEED_DICT;
goto inf_leave;
} /* if */
strm->adler = state->check = adler32(0, Z_NULL, 0);
state->headerMode = infmain;
} /* if infdict */
} /* for */
inflateStatus = IppLZ77InflateStatusHuffProcess;
ippsDecodeLZ77SetStatus_8u(inflateStatus, pLZ77State);
} /* IppLZ77InflateStatusInit */
for( ; ; )
{
ippsDecodeLZ77GetStatus_8u(&inflateStatus, 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)
{
pDst = strm->next_out;
dstLen = strm->avail_out;
pSrc = strm->next_in;
srcLen = strm->avail_in;
retStatus = ippsDecodeLZ77FixedHuffFull_8u(&pSrc, &srcLen, &pDst, &dstLen, ippflush, pLZ77State);
strm->next_in = pSrc;
strm->avail_in = srcLen;
strm->next_out = pDst;
strm->avail_out = dstLen;
if(retStatus == ippStsNoErr)
{
if(flush == Z_BLOCK)
{
state->blockEnd = 1;
inflateStatus = IppLZ77InflateStatusHuffProcess;
ret = Z_OK;
goto inf_leave;
} /* if */
}
else if(retStatus == ippStsStreamEnd)
{
inflateStatus = IppLZ77InflateStatusFinal;
state->headerMode = infhead;
ippsDecodeLZ77SetStatus_8u(inflateStatus, pLZ77State);
break;
}
else if(retStatus == ippStsSrcSizeLessExpected || retStatus == ippStsDstSizeLessExpected)
{
ret = Z_OK;
goto inf_leave;
} /* if else */
}
else if(huffMode == IppLZ77UseDynamic)
{
pDst = strm->next_out;
dstLen = strm->avail_out;
pSrc = strm->next_in;
srcLen = strm->avail_in;
retStatus = ippsDecodeLZ77DynamicHuffFull_8u(&pSrc, &srcLen, &pDst, &dstLen, ippflush, pLZ77State);
strm->next_in = pSrc;
strm->avail_in = srcLen;
strm->next_out = pDst;
strm->avail_out = dstLen;
if(retStatus == ippStsNoErr)
{
if(flush == Z_BLOCK)
{
state->blockEnd = 1;
inflateStatus = IppLZ77InflateStatusHuffProcess;
ret = Z_OK;
goto inf_leave;
} /* if */
}
else if(retStatus == ippStsStreamEnd)
{
state->headerMode = infhead;
inflateStatus = IppLZ77InflateStatusFinal;
ippsDecodeLZ77SetStatus_8u(inflateStatus, pLZ77State);
break;
}
else if( retStatus == ippStsSrcSizeLessExpected || retStatus == ippStsDstSizeLessExpected )
{
ret = Z_OK;
goto inf_leave;
} /* if else */
}
else if(huffMode == IppLZ77UseStored)
{
pSrc = strm->next_in;
srcLen = strm->avail_in;
pDst = strm->next_out;
dstLen = strm->avail_ou
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -