This commit is contained in:
Igor Pavlov
2023-12-22 17:17:05 +00:00
committed by Kornel
parent ec44a8a070
commit a36c48cece
954 changed files with 42199 additions and 25482 deletions

View File

@@ -1,7 +1,7 @@
// ZlibDecoder.h
#ifndef __ZLIB_DECODER_H
#define __ZLIB_DECODER_H
#ifndef ZIP7_INC_ZLIB_DECODER_H
#define ZIP7_INC_ZLIB_DECODER_H
#include "DeflateDecoder.h"
@@ -10,16 +10,14 @@ namespace NZlib {
const UInt32 ADLER_INIT_VAL = 1;
class COutStreamWithAdler:
public ISequentialOutStream,
public CMyUnknownImp
{
Z7_CLASS_IMP_NOQIB_1(
COutStreamWithAdler
, ISequentialOutStream
)
CMyComPtr<ISequentialOutStream> _stream;
UInt32 _adler;
UInt64 _size;
public:
MY_UNKNOWN_IMP
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
void SetStream(ISequentialOutStream *stream) { _stream = stream; }
void ReleaseStream() { _stream.Release(); }
void Init() { _adler = ADLER_INIT_VAL; _size = 0; }
@@ -27,23 +25,17 @@ public:
UInt64 GetSize() const { return _size; }
};
class CDecoder:
public ICompressCoder,
public CMyUnknownImp
{
Z7_CLASS_IMP_NOQIB_1(
CDecoder
, ICompressCoder
)
COutStreamWithAdler *AdlerSpec;
CMyComPtr<ISequentialOutStream> AdlerStream;
NCompress::NDeflate::NDecoder::CCOMCoder *DeflateDecoderSpec;
CMyComPtr<ICompressCoder> DeflateDecoder;
public:
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
UInt64 GetInputProcessedSize() const { return DeflateDecoderSpec->GetInputProcessedSize() + 2; }
UInt64 GetOutputProcessedSize() const { return AdlerSpec->GetSize(); }
MY_UNKNOWN_IMP
};
static bool inline IsZlib(const Byte *p)
@@ -65,8 +57,8 @@ static bool inline IsZlib_3bytes(const Byte *p)
{
if (!IsZlib(p))
return false;
unsigned val = p[2];
unsigned blockType = (val >> 1) & 0x3;
const unsigned val = p[2];
const unsigned blockType = (val >> 1) & 0x3;
if (blockType == 3) // unsupported block type for deflate
return false;
if (blockType == NCompress::NDeflate::NBlockType::kStored && (val >> 3) != 0)