DeltaFilter.cpp (p7zip_15.14.1_src_all) | : | DeltaFilter.cpp (p7zip_16.02_src_all) | ||
---|---|---|---|---|
skipping to change at line 13 | skipping to change at line 13 | |||
#include "StdAfx.h" | #include "StdAfx.h" | |||
#include "../../../C/Delta.h" | #include "../../../C/Delta.h" | |||
#include "../../Common/MyCom.h" | #include "../../Common/MyCom.h" | |||
#include "../ICoder.h" | #include "../ICoder.h" | |||
#include "../Common/RegisterCodec.h" | #include "../Common/RegisterCodec.h" | |||
namespace NCompress { | ||||
namespace NDelta { | ||||
struct CDelta | struct CDelta | |||
{ | { | |||
unsigned _delta; | unsigned _delta; | |||
Byte _state[DELTA_STATE_SIZE]; | Byte _state[DELTA_STATE_SIZE]; | |||
CDelta(): _delta(1) {} | CDelta(): _delta(1) {} | |||
void DeltaInit() { Delta_Init(_state); } | void DeltaInit() { Delta_Init(_state); } | |||
}; | }; | |||
#ifndef EXTRACT_ONLY | #ifndef EXTRACT_ONLY | |||
class CDeltaEncoder: | class CEncoder: | |||
public ICompressFilter, | public ICompressFilter, | |||
public ICompressSetCoderProperties, | public ICompressSetCoderProperties, | |||
public ICompressWriteCoderProperties, | public ICompressWriteCoderProperties, | |||
CDelta, | CDelta, | |||
public CMyUnknownImp | public CMyUnknownImp | |||
{ | { | |||
public: | public: | |||
MY_UNKNOWN_IMP2(ICompressSetCoderProperties, ICompressWriteCoderProperties) | MY_UNKNOWN_IMP3(ICompressFilter, ICompressSetCoderProperties, ICompressWriteCo derProperties) | |||
INTERFACE_ICompressFilter(;) | INTERFACE_ICompressFilter(;) | |||
STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps); | STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps); | |||
STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream); | STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream); | |||
}; | }; | |||
STDMETHODIMP CDeltaEncoder::Init() | STDMETHODIMP CEncoder::Init() | |||
{ | { | |||
DeltaInit(); | DeltaInit(); | |||
return S_OK; | return S_OK; | |||
} | } | |||
STDMETHODIMP_(UInt32) CDeltaEncoder::Filter(Byte *data, UInt32 size) | STDMETHODIMP_(UInt32) CEncoder::Filter(Byte *data, UInt32 size) | |||
{ | { | |||
Delta_Encode(_state, _delta, data, size); | Delta_Encode(_state, _delta, data, size); | |||
return size; | return size; | |||
} | } | |||
STDMETHODIMP CDeltaEncoder::SetCoderProperties(const PROPID *propIDs, const PROP VARIANT *props, UInt32 numProps) | STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs, const PROPVARIA NT *props, UInt32 numProps) | |||
{ | { | |||
UInt32 delta = _delta; | UInt32 delta = _delta; | |||
for (UInt32 i = 0; i < numProps; i++) | for (UInt32 i = 0; i < numProps; i++) | |||
{ | { | |||
const PROPVARIANT &prop = props[i]; | const PROPVARIANT &prop = props[i]; | |||
PROPID propID = propIDs[i]; | PROPID propID = propIDs[i]; | |||
if (propID >= NCoderPropID::kReduceSize) | if (propID >= NCoderPropID::kReduceSize) | |||
continue; | continue; | |||
if (prop.vt != VT_UI4) | if (prop.vt != VT_UI4) | |||
return E_INVALIDARG; | return E_INVALIDARG; | |||
skipping to change at line 77 | skipping to change at line 80 | |||
break; | break; | |||
case NCoderPropID::kNumThreads: break; | case NCoderPropID::kNumThreads: break; | |||
case NCoderPropID::kLevel: break; | case NCoderPropID::kLevel: break; | |||
default: return E_INVALIDARG; | default: return E_INVALIDARG; | |||
} | } | |||
} | } | |||
_delta = delta; | _delta = delta; | |||
return S_OK; | return S_OK; | |||
} | } | |||
STDMETHODIMP CDeltaEncoder::WriteCoderProperties(ISequentialOutStream *outStream ) | STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream) | |||
{ | { | |||
Byte prop = (Byte)(_delta - 1); | Byte prop = (Byte)(_delta - 1); | |||
return outStream->Write(&prop, 1, NULL); | return outStream->Write(&prop, 1, NULL); | |||
} | } | |||
#endif | #endif | |||
class CDeltaDecoder: | class CDecoder: | |||
public ICompressFilter, | public ICompressFilter, | |||
public ICompressSetDecoderProperties2, | public ICompressSetDecoderProperties2, | |||
CDelta, | CDelta, | |||
public CMyUnknownImp | public CMyUnknownImp | |||
{ | { | |||
public: | public: | |||
MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2) | MY_UNKNOWN_IMP2(ICompressFilter, ICompressSetDecoderProperties2) | |||
INTERFACE_ICompressFilter(;) | INTERFACE_ICompressFilter(;) | |||
STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size); | STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size); | |||
}; | }; | |||
STDMETHODIMP CDeltaDecoder::Init() | STDMETHODIMP CDecoder::Init() | |||
{ | { | |||
DeltaInit(); | DeltaInit(); | |||
return S_OK; | return S_OK; | |||
} | } | |||
STDMETHODIMP_(UInt32) CDeltaDecoder::Filter(Byte *data, UInt32 size) | STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size) | |||
{ | { | |||
Delta_Decode(_state, _delta, data, size); | Delta_Decode(_state, _delta, data, size); | |||
return size; | return size; | |||
} | } | |||
STDMETHODIMP CDeltaDecoder::SetDecoderProperties2(const Byte *props, UInt32 size ) | STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *props, UInt32 size) | |||
{ | { | |||
if (size != 1) | if (size != 1) | |||
return E_INVALIDARG; | return E_INVALIDARG; | |||
_delta = (unsigned)props[0] + 1; | _delta = (unsigned)props[0] + 1; | |||
return S_OK; | return S_OK; | |||
} | } | |||
REGISTER_FILTER_E(Delta, | REGISTER_FILTER_E(Delta, | |||
CDeltaDecoder(), | CDecoder(), | |||
CDeltaEncoder(), | CEncoder(), | |||
3, "Delta") | 3, "Delta") | |||
}} | ||||
End of changes. 14 change blocks. | ||||
13 lines changed or deleted | 16 lines changed or added |