3 #ifndef __CODER_MIXER2_H
4 #define __CODER_MIXER2_H
6 #include "../../../Common/MyVector.h"
7 #include "../../../Common/Types.h"
8 #include "../../../Common/MyCom.h"
9 #include "../../ICoder.h"
11 namespace NCoderMixer {
19 struct CCoderStreamsInfo
27 CRecordVector<CCoderStreamsInfo> Coders;
28 CRecordVector<CBindPair> BindPairs;
29 CRecordVector<UInt32> InStreams;
30 CRecordVector<UInt32> OutStreams;
41 UInt32 GetCoderStartOutStream(UInt32 coderIndex) const
43 UInt32 numOutStreams = 0;
44 for (UInt32 i = 0; i < coderIndex; i++)
45 numOutStreams += Coders[i].NumOutStreams;
51 void GetNumStreams(UInt32 &numInStreams, UInt32 &numOutStreams) const
55 for (int i = 0; i < Coders.Size(); i++)
57 const CCoderStreamsInfo &coderStreamsInfo = Coders[i];
58 numInStreams += coderStreamsInfo.NumInStreams;
59 numOutStreams += coderStreamsInfo.NumOutStreams;
63 int FindBinderForInStream(UInt32 inStream) const
65 for (int i = 0; i < BindPairs.Size(); i++)
66 if (BindPairs[i].InIndex == inStream)
70 int FindBinderForOutStream(UInt32 outStream) const
72 for (int i = 0; i < BindPairs.Size(); i++)
73 if (BindPairs[i].OutIndex == outStream)
78 UInt32 GetCoderInStreamIndex(UInt32 coderIndex) const
80 UInt32 streamIndex = 0;
81 for (UInt32 i = 0; i < coderIndex; i++)
82 streamIndex += Coders[i].NumInStreams;
86 UInt32 GetCoderOutStreamIndex(UInt32 coderIndex) const
88 UInt32 streamIndex = 0;
89 for (UInt32 i = 0; i < coderIndex; i++)
90 streamIndex += Coders[i].NumOutStreams;
95 void FindInStream(UInt32 streamIndex, UInt32 &coderIndex,
96 UInt32 &coderStreamIndex) const
98 for (coderIndex = 0; coderIndex < (UInt32)Coders.Size(); coderIndex++)
100 UInt32 curSize = Coders[coderIndex].NumInStreams;
101 if (streamIndex < curSize)
103 coderStreamIndex = streamIndex;
106 streamIndex -= curSize;
110 void FindOutStream(UInt32 streamIndex, UInt32 &coderIndex,
111 UInt32 &coderStreamIndex) const
113 for (coderIndex = 0; coderIndex < (UInt32)Coders.Size(); coderIndex++)
115 UInt32 curSize = Coders[coderIndex].NumOutStreams;
116 if (streamIndex < curSize)
118 coderStreamIndex = streamIndex;
121 streamIndex -= curSize;
127 class CBindReverseConverter
129 UInt32 _numSrcOutStreams;
130 NCoderMixer::CBindInfo _srcBindInfo;
131 CRecordVector<UInt32> _srcInToDestOutMap;
132 CRecordVector<UInt32> _srcOutToDestInMap;
133 CRecordVector<UInt32> _destInToSrcOutMap;
135 UInt32 NumSrcInStreams;
136 CRecordVector<UInt32> DestOutToSrcInMap;
138 CBindReverseConverter(const NCoderMixer::CBindInfo &srcBindInfo);
139 void CreateReverseBindInfo(NCoderMixer::CBindInfo &destBindInfo);
144 CMyComPtr<ICompressCoder> Coder;
145 CMyComPtr<ICompressCoder2> Coder2;
147 UInt32 NumOutStreams;
149 CRecordVector<UInt64> InSizes;
150 CRecordVector<UInt64> OutSizes;
151 CRecordVector<const UInt64 *> InSizePointers;
152 CRecordVector<const UInt64 *> OutSizePointers;
154 CCoderInfo2(UInt32 numInStreams, UInt32 numOutStreams);
155 void SetCoderInfo(const UInt64 **inSizes, const UInt64 **outSizes);
157 HRESULT QueryInterface(REFGUID iid, void** pp) const
159 IUnknown *p = Coder ? (IUnknown *)Coder : (IUnknown *)Coder2;
160 return p->QueryInterface(iid, pp);
167 virtual HRESULT SetBindInfo(const CBindInfo &bindInfo) = 0;
168 virtual void ReInit() = 0;
169 virtual void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes) = 0;