rlm@1
|
1 // CoderMixer2.h
|
rlm@1
|
2
|
rlm@1
|
3 #ifndef __CODER_MIXER2_H
|
rlm@1
|
4 #define __CODER_MIXER2_H
|
rlm@1
|
5
|
rlm@1
|
6 #include "../../../Common/MyVector.h"
|
rlm@1
|
7 #include "../../../Common/Types.h"
|
rlm@1
|
8 #include "../../../Common/MyCom.h"
|
rlm@1
|
9 #include "../../ICoder.h"
|
rlm@1
|
10
|
rlm@1
|
11 namespace NCoderMixer {
|
rlm@1
|
12
|
rlm@1
|
13 struct CBindPair
|
rlm@1
|
14 {
|
rlm@1
|
15 UInt32 InIndex;
|
rlm@1
|
16 UInt32 OutIndex;
|
rlm@1
|
17 };
|
rlm@1
|
18
|
rlm@1
|
19 struct CCoderStreamsInfo
|
rlm@1
|
20 {
|
rlm@1
|
21 UInt32 NumInStreams;
|
rlm@1
|
22 UInt32 NumOutStreams;
|
rlm@1
|
23 };
|
rlm@1
|
24
|
rlm@1
|
25 struct CBindInfo
|
rlm@1
|
26 {
|
rlm@1
|
27 CRecordVector<CCoderStreamsInfo> Coders;
|
rlm@1
|
28 CRecordVector<CBindPair> BindPairs;
|
rlm@1
|
29 CRecordVector<UInt32> InStreams;
|
rlm@1
|
30 CRecordVector<UInt32> OutStreams;
|
rlm@1
|
31
|
rlm@1
|
32 void Clear()
|
rlm@1
|
33 {
|
rlm@1
|
34 Coders.Clear();
|
rlm@1
|
35 BindPairs.Clear();
|
rlm@1
|
36 InStreams.Clear();
|
rlm@1
|
37 OutStreams.Clear();
|
rlm@1
|
38 }
|
rlm@1
|
39
|
rlm@1
|
40 /*
|
rlm@1
|
41 UInt32 GetCoderStartOutStream(UInt32 coderIndex) const
|
rlm@1
|
42 {
|
rlm@1
|
43 UInt32 numOutStreams = 0;
|
rlm@1
|
44 for (UInt32 i = 0; i < coderIndex; i++)
|
rlm@1
|
45 numOutStreams += Coders[i].NumOutStreams;
|
rlm@1
|
46 return numOutStreams;
|
rlm@1
|
47 }
|
rlm@1
|
48 */
|
rlm@1
|
49
|
rlm@1
|
50
|
rlm@1
|
51 void GetNumStreams(UInt32 &numInStreams, UInt32 &numOutStreams) const
|
rlm@1
|
52 {
|
rlm@1
|
53 numInStreams = 0;
|
rlm@1
|
54 numOutStreams = 0;
|
rlm@1
|
55 for (int i = 0; i < Coders.Size(); i++)
|
rlm@1
|
56 {
|
rlm@1
|
57 const CCoderStreamsInfo &coderStreamsInfo = Coders[i];
|
rlm@1
|
58 numInStreams += coderStreamsInfo.NumInStreams;
|
rlm@1
|
59 numOutStreams += coderStreamsInfo.NumOutStreams;
|
rlm@1
|
60 }
|
rlm@1
|
61 }
|
rlm@1
|
62
|
rlm@1
|
63 int FindBinderForInStream(UInt32 inStream) const
|
rlm@1
|
64 {
|
rlm@1
|
65 for (int i = 0; i < BindPairs.Size(); i++)
|
rlm@1
|
66 if (BindPairs[i].InIndex == inStream)
|
rlm@1
|
67 return i;
|
rlm@1
|
68 return -1;
|
rlm@1
|
69 }
|
rlm@1
|
70 int FindBinderForOutStream(UInt32 outStream) const
|
rlm@1
|
71 {
|
rlm@1
|
72 for (int i = 0; i < BindPairs.Size(); i++)
|
rlm@1
|
73 if (BindPairs[i].OutIndex == outStream)
|
rlm@1
|
74 return i;
|
rlm@1
|
75 return -1;
|
rlm@1
|
76 }
|
rlm@1
|
77
|
rlm@1
|
78 UInt32 GetCoderInStreamIndex(UInt32 coderIndex) const
|
rlm@1
|
79 {
|
rlm@1
|
80 UInt32 streamIndex = 0;
|
rlm@1
|
81 for (UInt32 i = 0; i < coderIndex; i++)
|
rlm@1
|
82 streamIndex += Coders[i].NumInStreams;
|
rlm@1
|
83 return streamIndex;
|
rlm@1
|
84 }
|
rlm@1
|
85
|
rlm@1
|
86 UInt32 GetCoderOutStreamIndex(UInt32 coderIndex) const
|
rlm@1
|
87 {
|
rlm@1
|
88 UInt32 streamIndex = 0;
|
rlm@1
|
89 for (UInt32 i = 0; i < coderIndex; i++)
|
rlm@1
|
90 streamIndex += Coders[i].NumOutStreams;
|
rlm@1
|
91 return streamIndex;
|
rlm@1
|
92 }
|
rlm@1
|
93
|
rlm@1
|
94
|
rlm@1
|
95 void FindInStream(UInt32 streamIndex, UInt32 &coderIndex,
|
rlm@1
|
96 UInt32 &coderStreamIndex) const
|
rlm@1
|
97 {
|
rlm@1
|
98 for (coderIndex = 0; coderIndex < (UInt32)Coders.Size(); coderIndex++)
|
rlm@1
|
99 {
|
rlm@1
|
100 UInt32 curSize = Coders[coderIndex].NumInStreams;
|
rlm@1
|
101 if (streamIndex < curSize)
|
rlm@1
|
102 {
|
rlm@1
|
103 coderStreamIndex = streamIndex;
|
rlm@1
|
104 return;
|
rlm@1
|
105 }
|
rlm@1
|
106 streamIndex -= curSize;
|
rlm@1
|
107 }
|
rlm@1
|
108 throw 1;
|
rlm@1
|
109 }
|
rlm@1
|
110 void FindOutStream(UInt32 streamIndex, UInt32 &coderIndex,
|
rlm@1
|
111 UInt32 &coderStreamIndex) const
|
rlm@1
|
112 {
|
rlm@1
|
113 for (coderIndex = 0; coderIndex < (UInt32)Coders.Size(); coderIndex++)
|
rlm@1
|
114 {
|
rlm@1
|
115 UInt32 curSize = Coders[coderIndex].NumOutStreams;
|
rlm@1
|
116 if (streamIndex < curSize)
|
rlm@1
|
117 {
|
rlm@1
|
118 coderStreamIndex = streamIndex;
|
rlm@1
|
119 return;
|
rlm@1
|
120 }
|
rlm@1
|
121 streamIndex -= curSize;
|
rlm@1
|
122 }
|
rlm@1
|
123 throw 1;
|
rlm@1
|
124 }
|
rlm@1
|
125 };
|
rlm@1
|
126
|
rlm@1
|
127 class CBindReverseConverter
|
rlm@1
|
128 {
|
rlm@1
|
129 UInt32 _numSrcOutStreams;
|
rlm@1
|
130 NCoderMixer::CBindInfo _srcBindInfo;
|
rlm@1
|
131 CRecordVector<UInt32> _srcInToDestOutMap;
|
rlm@1
|
132 CRecordVector<UInt32> _srcOutToDestInMap;
|
rlm@1
|
133 CRecordVector<UInt32> _destInToSrcOutMap;
|
rlm@1
|
134 public:
|
rlm@1
|
135 UInt32 NumSrcInStreams;
|
rlm@1
|
136 CRecordVector<UInt32> DestOutToSrcInMap;
|
rlm@1
|
137
|
rlm@1
|
138 CBindReverseConverter(const NCoderMixer::CBindInfo &srcBindInfo);
|
rlm@1
|
139 void CreateReverseBindInfo(NCoderMixer::CBindInfo &destBindInfo);
|
rlm@1
|
140 };
|
rlm@1
|
141
|
rlm@1
|
142 struct CCoderInfo2
|
rlm@1
|
143 {
|
rlm@1
|
144 CMyComPtr<ICompressCoder> Coder;
|
rlm@1
|
145 CMyComPtr<ICompressCoder2> Coder2;
|
rlm@1
|
146 UInt32 NumInStreams;
|
rlm@1
|
147 UInt32 NumOutStreams;
|
rlm@1
|
148
|
rlm@1
|
149 CRecordVector<UInt64> InSizes;
|
rlm@1
|
150 CRecordVector<UInt64> OutSizes;
|
rlm@1
|
151 CRecordVector<const UInt64 *> InSizePointers;
|
rlm@1
|
152 CRecordVector<const UInt64 *> OutSizePointers;
|
rlm@1
|
153
|
rlm@1
|
154 CCoderInfo2(UInt32 numInStreams, UInt32 numOutStreams);
|
rlm@1
|
155 void SetCoderInfo(const UInt64 **inSizes, const UInt64 **outSizes);
|
rlm@1
|
156
|
rlm@1
|
157 HRESULT QueryInterface(REFGUID iid, void** pp) const
|
rlm@1
|
158 {
|
rlm@1
|
159 IUnknown *p = Coder ? (IUnknown *)Coder : (IUnknown *)Coder2;
|
rlm@1
|
160 return p->QueryInterface(iid, pp);
|
rlm@1
|
161 }
|
rlm@1
|
162 };
|
rlm@1
|
163
|
rlm@1
|
164 class CCoderMixer2
|
rlm@1
|
165 {
|
rlm@1
|
166 public:
|
rlm@1
|
167 virtual HRESULT SetBindInfo(const CBindInfo &bindInfo) = 0;
|
rlm@1
|
168 virtual void ReInit() = 0;
|
rlm@1
|
169 virtual void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes) = 0;
|
rlm@1
|
170 };
|
rlm@1
|
171
|
rlm@1
|
172 }
|
rlm@1
|
173 #endif
|
rlm@1
|
174
|