Home | History | Annotate | Download | only in 7zip
      1 // ICoder.h
      2 
      3 #ifndef __ICODER_H
      4 #define __ICODER_H
      5 
      6 #include "IStream.h"
      7 
      8 #define CODER_INTERFACE(i, x) DECL_INTERFACE(i, 4, x)
      9 
     10 CODER_INTERFACE(ICompressProgressInfo, 0x04)
     11 {
     12   STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize) PURE;
     13 };
     14 
     15 CODER_INTERFACE(ICompressCoder, 0x05)
     16 {
     17   STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
     18       const UInt64 *inSize, const UInt64 *outSize,
     19       ICompressProgressInfo *progress) PURE;
     20 };
     21 
     22 CODER_INTERFACE(ICompressCoder2, 0x18)
     23 {
     24   STDMETHOD(Code)(ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 numInStreams,
     25       ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 numOutStreams,
     26       ICompressProgressInfo *progress) PURE;
     27 };
     28 
     29 namespace NCoderPropID
     30 {
     31   enum EEnum
     32   {
     33     kDefaultProp = 0,
     34     kDictionarySize,
     35     kUsedMemorySize,
     36     kOrder,
     37     kBlockSize,
     38     kPosStateBits,
     39     kLitContextBits,
     40     kLitPosBits,
     41     kNumFastBytes,
     42     kMatchFinder,
     43     kMatchFinderCycles,
     44     kNumPasses,
     45     kAlgorithm,
     46     kNumThreads,
     47     kEndMarker,
     48     kLevel,
     49     kReduceSize // estimated size of data that will be compressed. Encoder can use this value to reduce dictionary size.
     50   };
     51 }
     52 
     53 CODER_INTERFACE(ICompressSetCoderProperties, 0x20)
     54 {
     55   STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps) PURE;
     56 };
     57 
     58 /*
     59 CODER_INTERFACE(ICompressSetCoderProperties, 0x21)
     60 {
     61   STDMETHOD(SetDecoderProperties)(ISequentialInStream *inStream) PURE;
     62 };
     63 */
     64 
     65 CODER_INTERFACE(ICompressSetDecoderProperties2, 0x22)
     66 {
     67   STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size) PURE;
     68 };
     69 
     70 CODER_INTERFACE(ICompressWriteCoderProperties, 0x23)
     71 {
     72   STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream) PURE;
     73 };
     74 
     75 CODER_INTERFACE(ICompressGetInStreamProcessedSize, 0x24)
     76 {
     77   STDMETHOD(GetInStreamProcessedSize)(UInt64 *value) PURE;
     78 };
     79 
     80 CODER_INTERFACE(ICompressSetCoderMt, 0x25)
     81 {
     82   STDMETHOD(SetNumberOfThreads)(UInt32 numThreads) PURE;
     83 };
     84 
     85 CODER_INTERFACE(ICompressGetSubStreamSize, 0x30)
     86 {
     87   STDMETHOD(GetSubStreamSize)(UInt64 subStream, UInt64 *value) PURE;
     88 };
     89 
     90 CODER_INTERFACE(ICompressSetInStream, 0x31)
     91 {
     92   STDMETHOD(SetInStream)(ISequentialInStream *inStream) PURE;
     93   STDMETHOD(ReleaseInStream)() PURE;
     94 };
     95 
     96 CODER_INTERFACE(ICompressSetOutStream, 0x32)
     97 {
     98   STDMETHOD(SetOutStream)(ISequentialOutStream *outStream) PURE;
     99   STDMETHOD(ReleaseOutStream)() PURE;
    100 };
    101 
    102 CODER_INTERFACE(ICompressSetInStreamSize, 0x33)
    103 {
    104   STDMETHOD(SetInStreamSize)(const UInt64 *inSize) PURE;
    105 };
    106 
    107 CODER_INTERFACE(ICompressSetOutStreamSize, 0x34)
    108 {
    109   STDMETHOD(SetOutStreamSize)(const UInt64 *outSize) PURE;
    110 };
    111 
    112 CODER_INTERFACE(ICompressSetBufSize, 0x35)
    113 {
    114   STDMETHOD(SetInBufSize)(UInt32 streamIndex, UInt32 size) PURE;
    115   STDMETHOD(SetOutBufSize)(UInt32 streamIndex, UInt32 size) PURE;
    116 };
    117 
    118 CODER_INTERFACE(ICompressFilter, 0x40)
    119 {
    120   STDMETHOD(Init)() PURE;
    121   STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size) PURE;
    122   // Filter converts as most as possible bytes
    123   // Filter return outSize (UInt32)
    124   // if (outSize <= size): Filter have converted outSize bytes
    125   // if (outSize > size): Filter have not converted anything.
    126   //      and it needs at least outSize bytes to convert one block
    127   //      (it's for crypto block algorithms).
    128 };
    129 
    130 CODER_INTERFACE(ICompressCodecsInfo, 0x60)
    131 {
    132   STDMETHOD(GetNumberOfMethods)(UInt32 *numMethods) PURE;
    133   STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) PURE;
    134   STDMETHOD(CreateDecoder)(UInt32 index, const GUID *iid, void **coder) PURE;
    135   STDMETHOD(CreateEncoder)(UInt32 index, const GUID *iid, void **coder) PURE;
    136 };
    137 CODER_INTERFACE(ISetCompressCodecsInfo, 0x61)
    138 {
    139   STDMETHOD(SetCompressCodecsInfo)(ICompressCodecsInfo *compressCodecsInfo) PURE;
    140 };
    141 
    142 CODER_INTERFACE(ICryptoProperties, 0x80)
    143 {
    144   STDMETHOD(SetKey)(const Byte *data, UInt32 size) PURE;
    145   STDMETHOD(SetInitVector)(const Byte *data, UInt32 size) PURE;
    146 };
    147 
    148 /*
    149 CODER_INTERFACE(ICryptoResetSalt, 0x88)
    150 {
    151   STDMETHOD(ResetSalt)() PURE;
    152 };
    153 */
    154 
    155 CODER_INTERFACE(ICryptoResetInitVector, 0x8C)
    156 {
    157   STDMETHOD(ResetInitVector)() PURE;
    158 };
    159 
    160 CODER_INTERFACE(ICryptoSetPassword, 0x90)
    161 {
    162   STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size) PURE;
    163 };
    164 
    165 CODER_INTERFACE(ICryptoSetCRC, 0xA0)
    166 {
    167   STDMETHOD(CryptoSetCRC)(UInt32 crc) PURE;
    168 };
    169 
    170 //////////////////////
    171 // It's for DLL file
    172 namespace NMethodPropID
    173 {
    174   enum EEnum
    175   {
    176     kID,
    177     kName,
    178     kDecoder,
    179     kEncoder,
    180     kInStreams,
    181     kOutStreams,
    182     kDescription,
    183     kDecoderIsAssigned,
    184     kEncoderIsAssigned,
    185     kDigestSize
    186   };
    187 }
    188 
    189 CODER_INTERFACE(IHasher, 0xC0)
    190 {
    191   STDMETHOD_(void, Init)() PURE;
    192   STDMETHOD_(void, Update)(const void *data, UInt32 size) PURE;
    193   STDMETHOD_(void, Final)(Byte *digest) PURE;
    194   STDMETHOD_(UInt32, GetDigestSize)() PURE;
    195 };
    196 
    197 CODER_INTERFACE(IHashers, 0xC1)
    198 {
    199   STDMETHOD_(UInt32, GetNumHashers)() PURE;
    200   STDMETHOD(GetHasherProp)(UInt32 index, PROPID propID, PROPVARIANT *value) PURE;
    201   STDMETHOD(CreateHasher)(UInt32 index, IHasher **hasher) PURE;
    202 };
    203 
    204 extern "C"
    205 {
    206   typedef HRESULT (WINAPI *Func_GetNumberOfMethods)(UInt32 *numMethods);
    207   typedef HRESULT (WINAPI *Func_GetMethodProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
    208   typedef HRESULT (WINAPI *Func_GetHashers)(IHashers **hashers);
    209 }
    210 
    211 #endif
    212