Mercurial > vba-linux
diff src/win32/7zip/7z/CPP/7zip/Archive/Common/CoderMixer2.h @ 1:f9f4f1b99eed
importing src directory
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:31:27 -0600 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/win32/7zip/7z/CPP/7zip/Archive/Common/CoderMixer2.h Sat Mar 03 10:31:27 2012 -0600 1.3 @@ -0,0 +1,174 @@ 1.4 +// CoderMixer2.h 1.5 + 1.6 +#ifndef __CODER_MIXER2_H 1.7 +#define __CODER_MIXER2_H 1.8 + 1.9 +#include "../../../Common/MyVector.h" 1.10 +#include "../../../Common/Types.h" 1.11 +#include "../../../Common/MyCom.h" 1.12 +#include "../../ICoder.h" 1.13 + 1.14 +namespace NCoderMixer { 1.15 + 1.16 +struct CBindPair 1.17 +{ 1.18 + UInt32 InIndex; 1.19 + UInt32 OutIndex; 1.20 +}; 1.21 + 1.22 +struct CCoderStreamsInfo 1.23 +{ 1.24 + UInt32 NumInStreams; 1.25 + UInt32 NumOutStreams; 1.26 +}; 1.27 + 1.28 +struct CBindInfo 1.29 +{ 1.30 + CRecordVector<CCoderStreamsInfo> Coders; 1.31 + CRecordVector<CBindPair> BindPairs; 1.32 + CRecordVector<UInt32> InStreams; 1.33 + CRecordVector<UInt32> OutStreams; 1.34 + 1.35 + void Clear() 1.36 + { 1.37 + Coders.Clear(); 1.38 + BindPairs.Clear(); 1.39 + InStreams.Clear(); 1.40 + OutStreams.Clear(); 1.41 + } 1.42 + 1.43 + /* 1.44 + UInt32 GetCoderStartOutStream(UInt32 coderIndex) const 1.45 + { 1.46 + UInt32 numOutStreams = 0; 1.47 + for (UInt32 i = 0; i < coderIndex; i++) 1.48 + numOutStreams += Coders[i].NumOutStreams; 1.49 + return numOutStreams; 1.50 + } 1.51 + */ 1.52 + 1.53 + 1.54 + void GetNumStreams(UInt32 &numInStreams, UInt32 &numOutStreams) const 1.55 + { 1.56 + numInStreams = 0; 1.57 + numOutStreams = 0; 1.58 + for (int i = 0; i < Coders.Size(); i++) 1.59 + { 1.60 + const CCoderStreamsInfo &coderStreamsInfo = Coders[i]; 1.61 + numInStreams += coderStreamsInfo.NumInStreams; 1.62 + numOutStreams += coderStreamsInfo.NumOutStreams; 1.63 + } 1.64 + } 1.65 + 1.66 + int FindBinderForInStream(UInt32 inStream) const 1.67 + { 1.68 + for (int i = 0; i < BindPairs.Size(); i++) 1.69 + if (BindPairs[i].InIndex == inStream) 1.70 + return i; 1.71 + return -1; 1.72 + } 1.73 + int FindBinderForOutStream(UInt32 outStream) const 1.74 + { 1.75 + for (int i = 0; i < BindPairs.Size(); i++) 1.76 + if (BindPairs[i].OutIndex == outStream) 1.77 + return i; 1.78 + return -1; 1.79 + } 1.80 + 1.81 + UInt32 GetCoderInStreamIndex(UInt32 coderIndex) const 1.82 + { 1.83 + UInt32 streamIndex = 0; 1.84 + for (UInt32 i = 0; i < coderIndex; i++) 1.85 + streamIndex += Coders[i].NumInStreams; 1.86 + return streamIndex; 1.87 + } 1.88 + 1.89 + UInt32 GetCoderOutStreamIndex(UInt32 coderIndex) const 1.90 + { 1.91 + UInt32 streamIndex = 0; 1.92 + for (UInt32 i = 0; i < coderIndex; i++) 1.93 + streamIndex += Coders[i].NumOutStreams; 1.94 + return streamIndex; 1.95 + } 1.96 + 1.97 + 1.98 + void FindInStream(UInt32 streamIndex, UInt32 &coderIndex, 1.99 + UInt32 &coderStreamIndex) const 1.100 + { 1.101 + for (coderIndex = 0; coderIndex < (UInt32)Coders.Size(); coderIndex++) 1.102 + { 1.103 + UInt32 curSize = Coders[coderIndex].NumInStreams; 1.104 + if (streamIndex < curSize) 1.105 + { 1.106 + coderStreamIndex = streamIndex; 1.107 + return; 1.108 + } 1.109 + streamIndex -= curSize; 1.110 + } 1.111 + throw 1; 1.112 + } 1.113 + void FindOutStream(UInt32 streamIndex, UInt32 &coderIndex, 1.114 + UInt32 &coderStreamIndex) const 1.115 + { 1.116 + for (coderIndex = 0; coderIndex < (UInt32)Coders.Size(); coderIndex++) 1.117 + { 1.118 + UInt32 curSize = Coders[coderIndex].NumOutStreams; 1.119 + if (streamIndex < curSize) 1.120 + { 1.121 + coderStreamIndex = streamIndex; 1.122 + return; 1.123 + } 1.124 + streamIndex -= curSize; 1.125 + } 1.126 + throw 1; 1.127 + } 1.128 +}; 1.129 + 1.130 +class CBindReverseConverter 1.131 +{ 1.132 + UInt32 _numSrcOutStreams; 1.133 + NCoderMixer::CBindInfo _srcBindInfo; 1.134 + CRecordVector<UInt32> _srcInToDestOutMap; 1.135 + CRecordVector<UInt32> _srcOutToDestInMap; 1.136 + CRecordVector<UInt32> _destInToSrcOutMap; 1.137 +public: 1.138 + UInt32 NumSrcInStreams; 1.139 + CRecordVector<UInt32> DestOutToSrcInMap; 1.140 + 1.141 + CBindReverseConverter(const NCoderMixer::CBindInfo &srcBindInfo); 1.142 + void CreateReverseBindInfo(NCoderMixer::CBindInfo &destBindInfo); 1.143 +}; 1.144 + 1.145 +struct CCoderInfo2 1.146 +{ 1.147 + CMyComPtr<ICompressCoder> Coder; 1.148 + CMyComPtr<ICompressCoder2> Coder2; 1.149 + UInt32 NumInStreams; 1.150 + UInt32 NumOutStreams; 1.151 + 1.152 + CRecordVector<UInt64> InSizes; 1.153 + CRecordVector<UInt64> OutSizes; 1.154 + CRecordVector<const UInt64 *> InSizePointers; 1.155 + CRecordVector<const UInt64 *> OutSizePointers; 1.156 + 1.157 + CCoderInfo2(UInt32 numInStreams, UInt32 numOutStreams); 1.158 + void SetCoderInfo(const UInt64 **inSizes, const UInt64 **outSizes); 1.159 + 1.160 + HRESULT QueryInterface(REFGUID iid, void** pp) const 1.161 + { 1.162 + IUnknown *p = Coder ? (IUnknown *)Coder : (IUnknown *)Coder2; 1.163 + return p->QueryInterface(iid, pp); 1.164 + } 1.165 +}; 1.166 + 1.167 +class CCoderMixer2 1.168 +{ 1.169 +public: 1.170 + virtual HRESULT SetBindInfo(const CBindInfo &bindInfo) = 0; 1.171 + virtual void ReInit() = 0; 1.172 + virtual void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes) = 0; 1.173 +}; 1.174 + 1.175 +} 1.176 +#endif 1.177 +