📄 inflate.c
字号:
else {
for( ; ; ) {
retStatus = ippsDecodeLZ77GetBlockType_8u( &strm->next_in, &strm->avail_in, &huffMode, pLZ77State );
if( retStatus != ippStsNoErr ) {
if( retStatus == ippStsSrcSizeLessExpected ) ret = Z_OK;
else ret = Z_DATA_ERROR;
break;
} /* if */
switch( huffMode ) {
case IppLZ77UseDynamic:
retStatus = ippsDecodeLZ77DynamicHuffFull_8u( &strm->next_in, &strm->avail_in,
&strm->next_out, &strm->avail_out, ippflush, pLZ77State );
break;
case IppLZ77UseStored:
retStatus = ippsDecodeLZ77StoredBlock_8u( &strm->next_in, &strm->avail_in,
&strm->next_out, &strm->avail_out, pLZ77State );
break;
case IppLZ77UseFixed:
retStatus = ippsDecodeLZ77FixedHuffFull_8u( &strm->next_in, &strm->avail_in,
&strm->next_out, &strm->avail_out, ippflush, pLZ77State );
break;
default:
ret = Z_DATA_ERROR;
goto inf_leave;
} /* switch */
if( retStatus == ippStsNoErr ) {
if( strm->avail_out ) continue;
break;
} /* if */
if( (retStatus == ippStsSrcSizeLessExpected) || (retStatus == ippStsDstSizeLessExpected) ) break;
if( retStatus == ippStsStreamEnd ) {
state->headerMode = infhead;
ret = Z_STREAM_END;
inflateStatus = IppLZ77InflateStatusFinal;
ippsDecodeLZ77SetStatus_8u( inflateStatus, pLZ77State );
goto inf_leave;
} /* if */
ret = Z_DATA_ERROR;
break;
} /* for */
} /* else */
in -= strm->avail_in;
out -= strm->avail_out;
strm->total_in += in;
strm->total_out += out;
if( state->wrap && out )strm->adler = state->check = UPDATE(state->check, strm->next_out - out, out);
return ret;
} /* if */
ippsDecodeLZ77GetStatus_8u(&inflateStatus, pLZ77State);
if(inflateStatus == IppLZ77InflateStatusInit)
{
unsigned int copy;
unsigned int len;
/* 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 */
ippsDecodeLZ77GetStatus_8u(&inflateStatus, pLZ77State);
if(inflateStatus == IppLZ77InflateStatusFinal)
{
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(state->wrap && 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;
} /* sequential inflate() */
#endif /* if not defined INFLATE_OMP or _OPENMP */
int ZEXPORT inflateEnd(strm)
z_streamp strm;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -