1370b324cSopenharmony_ci// CoderMixer2.h
2370b324cSopenharmony_ci
3370b324cSopenharmony_ci#ifndef ZIP7_INC_CODER_MIXER2_H
4370b324cSopenharmony_ci#define ZIP7_INC_CODER_MIXER2_H
5370b324cSopenharmony_ci
6370b324cSopenharmony_ci#include "../../../Common/MyCom.h"
7370b324cSopenharmony_ci#include "../../../Common/MyVector.h"
8370b324cSopenharmony_ci
9370b324cSopenharmony_ci#include "../../ICoder.h"
10370b324cSopenharmony_ci
11370b324cSopenharmony_ci#include "../../Common/CreateCoder.h"
12370b324cSopenharmony_ci
13370b324cSopenharmony_ci#ifdef Z7_ST
14370b324cSopenharmony_ci  #define USE_MIXER_ST
15370b324cSopenharmony_ci#else
16370b324cSopenharmony_ci  #define USE_MIXER_MT
17370b324cSopenharmony_ci  #ifndef Z7_SFX
18370b324cSopenharmony_ci    #define USE_MIXER_ST
19370b324cSopenharmony_ci  #endif
20370b324cSopenharmony_ci#endif
21370b324cSopenharmony_ci
22370b324cSopenharmony_ci#ifdef USE_MIXER_MT
23370b324cSopenharmony_ci#include "../../Common/StreamBinder.h"
24370b324cSopenharmony_ci#include "../../Common/VirtThread.h"
25370b324cSopenharmony_ci#endif
26370b324cSopenharmony_ci
27370b324cSopenharmony_ci
28370b324cSopenharmony_ci
29370b324cSopenharmony_ci#ifdef USE_MIXER_ST
30370b324cSopenharmony_ci
31370b324cSopenharmony_ciZ7_CLASS_IMP_COM_1(
32370b324cSopenharmony_ci  CSequentialInStreamCalcSize
33370b324cSopenharmony_ci  , ISequentialInStream
34370b324cSopenharmony_ci)
35370b324cSopenharmony_ci  bool _wasFinished;
36370b324cSopenharmony_ci  CMyComPtr<ISequentialInStream> _stream;
37370b324cSopenharmony_ci  UInt64 _size;
38370b324cSopenharmony_cipublic:
39370b324cSopenharmony_ci  void SetStream(ISequentialInStream *stream) { _stream = stream;  }
40370b324cSopenharmony_ci  void Init()
41370b324cSopenharmony_ci  {
42370b324cSopenharmony_ci    _size = 0;
43370b324cSopenharmony_ci    _wasFinished = false;
44370b324cSopenharmony_ci  }
45370b324cSopenharmony_ci  void ReleaseStream() { _stream.Release(); }
46370b324cSopenharmony_ci  UInt64 GetSize() const { return _size; }
47370b324cSopenharmony_ci  bool WasFinished() const { return _wasFinished; }
48370b324cSopenharmony_ci};
49370b324cSopenharmony_ci
50370b324cSopenharmony_ci
51370b324cSopenharmony_ciZ7_CLASS_IMP_COM_2(
52370b324cSopenharmony_ci  COutStreamCalcSize
53370b324cSopenharmony_ci  , ISequentialOutStream
54370b324cSopenharmony_ci  , IOutStreamFinish
55370b324cSopenharmony_ci)
56370b324cSopenharmony_ci  CMyComPtr<ISequentialOutStream> _stream;
57370b324cSopenharmony_ci  UInt64 _size;
58370b324cSopenharmony_cipublic:
59370b324cSopenharmony_ci  void SetStream(ISequentialOutStream *stream) { _stream = stream; }
60370b324cSopenharmony_ci  void ReleaseStream() { _stream.Release(); }
61370b324cSopenharmony_ci  void Init() { _size = 0; }
62370b324cSopenharmony_ci  UInt64 GetSize() const { return _size; }
63370b324cSopenharmony_ci};
64370b324cSopenharmony_ci
65370b324cSopenharmony_ci#endif
66370b324cSopenharmony_ci
67370b324cSopenharmony_ci
68370b324cSopenharmony_ci
69370b324cSopenharmony_cinamespace NCoderMixer2 {
70370b324cSopenharmony_ci
71370b324cSopenharmony_cistruct CBond
72370b324cSopenharmony_ci{
73370b324cSopenharmony_ci  UInt32 PackIndex;
74370b324cSopenharmony_ci  UInt32 UnpackIndex;
75370b324cSopenharmony_ci
76370b324cSopenharmony_ci  UInt32 Get_InIndex(bool encodeMode) const { return encodeMode ? UnpackIndex : PackIndex; }
77370b324cSopenharmony_ci  UInt32 Get_OutIndex(bool encodeMode) const { return encodeMode ? PackIndex : UnpackIndex; }
78370b324cSopenharmony_ci};
79370b324cSopenharmony_ci
80370b324cSopenharmony_ci
81370b324cSopenharmony_cistruct CCoderStreamsInfo
82370b324cSopenharmony_ci{
83370b324cSopenharmony_ci  UInt32 NumStreams;
84370b324cSopenharmony_ci};
85370b324cSopenharmony_ci
86370b324cSopenharmony_ci
87370b324cSopenharmony_cistruct CBindInfo
88370b324cSopenharmony_ci{
89370b324cSopenharmony_ci  CRecordVector<CCoderStreamsInfo> Coders;
90370b324cSopenharmony_ci  CRecordVector<CBond> Bonds;
91370b324cSopenharmony_ci  CRecordVector<UInt32> PackStreams;
92370b324cSopenharmony_ci  unsigned UnpackCoder;
93370b324cSopenharmony_ci
94370b324cSopenharmony_ci  unsigned GetNum_Bonds_and_PackStreams() const { return Bonds.Size() + PackStreams.Size(); }
95370b324cSopenharmony_ci
96370b324cSopenharmony_ci  int FindBond_for_PackStream(UInt32 packStream) const
97370b324cSopenharmony_ci  {
98370b324cSopenharmony_ci    FOR_VECTOR (i, Bonds)
99370b324cSopenharmony_ci      if (Bonds[i].PackIndex == packStream)
100370b324cSopenharmony_ci        return (int)i;
101370b324cSopenharmony_ci    return -1;
102370b324cSopenharmony_ci  }
103370b324cSopenharmony_ci
104370b324cSopenharmony_ci  int FindBond_for_UnpackStream(UInt32 unpackStream) const
105370b324cSopenharmony_ci  {
106370b324cSopenharmony_ci    FOR_VECTOR (i, Bonds)
107370b324cSopenharmony_ci      if (Bonds[i].UnpackIndex == unpackStream)
108370b324cSopenharmony_ci        return (int)i;
109370b324cSopenharmony_ci    return -1;
110370b324cSopenharmony_ci  }
111370b324cSopenharmony_ci
112370b324cSopenharmony_ci  bool SetUnpackCoder()
113370b324cSopenharmony_ci  {
114370b324cSopenharmony_ci    bool isOk = false;
115370b324cSopenharmony_ci    FOR_VECTOR (i, Coders)
116370b324cSopenharmony_ci    {
117370b324cSopenharmony_ci      if (FindBond_for_UnpackStream(i) < 0)
118370b324cSopenharmony_ci      {
119370b324cSopenharmony_ci        if (isOk)
120370b324cSopenharmony_ci          return false;
121370b324cSopenharmony_ci        UnpackCoder = i;
122370b324cSopenharmony_ci        isOk = true;
123370b324cSopenharmony_ci      }
124370b324cSopenharmony_ci    }
125370b324cSopenharmony_ci    return isOk;
126370b324cSopenharmony_ci  }
127370b324cSopenharmony_ci
128370b324cSopenharmony_ci  bool IsStream_in_PackStreams(UInt32 streamIndex) const
129370b324cSopenharmony_ci  {
130370b324cSopenharmony_ci    return FindStream_in_PackStreams(streamIndex) >= 0;
131370b324cSopenharmony_ci  }
132370b324cSopenharmony_ci
133370b324cSopenharmony_ci  int FindStream_in_PackStreams(UInt32 streamIndex) const
134370b324cSopenharmony_ci  {
135370b324cSopenharmony_ci    FOR_VECTOR (i, PackStreams)
136370b324cSopenharmony_ci      if (PackStreams[i] == streamIndex)
137370b324cSopenharmony_ci        return (int)i;
138370b324cSopenharmony_ci    return -1;
139370b324cSopenharmony_ci  }
140370b324cSopenharmony_ci
141370b324cSopenharmony_ci
142370b324cSopenharmony_ci  // that function is used before Maps is calculated
143370b324cSopenharmony_ci
144370b324cSopenharmony_ci  UInt32 GetStream_for_Coder(UInt32 coderIndex) const
145370b324cSopenharmony_ci  {
146370b324cSopenharmony_ci    UInt32 streamIndex = 0;
147370b324cSopenharmony_ci    for (UInt32 i = 0; i < coderIndex; i++)
148370b324cSopenharmony_ci      streamIndex += Coders[i].NumStreams;
149370b324cSopenharmony_ci    return streamIndex;
150370b324cSopenharmony_ci  }
151370b324cSopenharmony_ci
152370b324cSopenharmony_ci  // ---------- Maps Section ----------
153370b324cSopenharmony_ci
154370b324cSopenharmony_ci  CRecordVector<UInt32> Coder_to_Stream;
155370b324cSopenharmony_ci  CRecordVector<UInt32> Stream_to_Coder;
156370b324cSopenharmony_ci
157370b324cSopenharmony_ci  void ClearMaps();
158370b324cSopenharmony_ci  bool CalcMapsAndCheck();
159370b324cSopenharmony_ci
160370b324cSopenharmony_ci  // ---------- End of Maps Section ----------
161370b324cSopenharmony_ci
162370b324cSopenharmony_ci  void Clear()
163370b324cSopenharmony_ci  {
164370b324cSopenharmony_ci    Coders.Clear();
165370b324cSopenharmony_ci    Bonds.Clear();
166370b324cSopenharmony_ci    PackStreams.Clear();
167370b324cSopenharmony_ci
168370b324cSopenharmony_ci    ClearMaps();
169370b324cSopenharmony_ci  }
170370b324cSopenharmony_ci
171370b324cSopenharmony_ci  void GetCoder_for_Stream(UInt32 streamIndex, UInt32 &coderIndex, UInt32 &coderStreamIndex) const
172370b324cSopenharmony_ci  {
173370b324cSopenharmony_ci    coderIndex = Stream_to_Coder[streamIndex];
174370b324cSopenharmony_ci    coderStreamIndex = streamIndex - Coder_to_Stream[coderIndex];
175370b324cSopenharmony_ci  }
176370b324cSopenharmony_ci};
177370b324cSopenharmony_ci
178370b324cSopenharmony_ci
179370b324cSopenharmony_ci
180370b324cSopenharmony_ciclass CCoder
181370b324cSopenharmony_ci{
182370b324cSopenharmony_ci  Z7_CLASS_NO_COPY(CCoder)
183370b324cSopenharmony_cipublic:
184370b324cSopenharmony_ci  CMyComPtr<ICompressCoder> Coder;
185370b324cSopenharmony_ci  CMyComPtr<ICompressCoder2> Coder2;
186370b324cSopenharmony_ci  UInt32 NumStreams;
187370b324cSopenharmony_ci  bool Finish;
188370b324cSopenharmony_ci
189370b324cSopenharmony_ci  UInt64 UnpackSize;
190370b324cSopenharmony_ci  const UInt64 *UnpackSizePointer;
191370b324cSopenharmony_ci
192370b324cSopenharmony_ci  CRecordVector<UInt64> PackSizes;
193370b324cSopenharmony_ci  CRecordVector<const UInt64 *> PackSizePointers;
194370b324cSopenharmony_ci
195370b324cSopenharmony_ci  CCoder(): Finish(false) {}
196370b324cSopenharmony_ci
197370b324cSopenharmony_ci  void SetCoderInfo(const UInt64 *unpackSize, const UInt64 * const *packSizes, bool finish);
198370b324cSopenharmony_ci
199370b324cSopenharmony_ci  HRESULT CheckDataAfterEnd(bool &dataAfterEnd_Error /* , bool &InternalPackSizeError */) const;
200370b324cSopenharmony_ci
201370b324cSopenharmony_ci  IUnknown *GetUnknown() const
202370b324cSopenharmony_ci  {
203370b324cSopenharmony_ci    return Coder ? (IUnknown *)Coder : (IUnknown *)Coder2;
204370b324cSopenharmony_ci  }
205370b324cSopenharmony_ci
206370b324cSopenharmony_ci  HRESULT QueryInterface(REFGUID iid, void** pp) const
207370b324cSopenharmony_ci  {
208370b324cSopenharmony_ci    return GetUnknown()->QueryInterface(iid, pp);
209370b324cSopenharmony_ci  }
210370b324cSopenharmony_ci};
211370b324cSopenharmony_ci
212370b324cSopenharmony_ci
213370b324cSopenharmony_ci
214370b324cSopenharmony_ciclass CMixer
215370b324cSopenharmony_ci{
216370b324cSopenharmony_ci  bool Is_PackSize_Correct_for_Stream(UInt32 streamIndex);
217370b324cSopenharmony_ci
218370b324cSopenharmony_ciprotected:
219370b324cSopenharmony_ci  CBindInfo _bi;
220370b324cSopenharmony_ci
221370b324cSopenharmony_ci  int FindBond_for_Stream(bool forInputStream, UInt32 streamIndex) const
222370b324cSopenharmony_ci  {
223370b324cSopenharmony_ci    if (EncodeMode == forInputStream)
224370b324cSopenharmony_ci      return _bi.FindBond_for_UnpackStream(streamIndex);
225370b324cSopenharmony_ci    else
226370b324cSopenharmony_ci      return _bi.FindBond_for_PackStream(streamIndex);
227370b324cSopenharmony_ci  }
228370b324cSopenharmony_ci
229370b324cSopenharmony_ci  CBoolVector IsFilter_Vector;
230370b324cSopenharmony_ci  CBoolVector IsExternal_Vector;
231370b324cSopenharmony_ci  bool EncodeMode;
232370b324cSopenharmony_cipublic:
233370b324cSopenharmony_ci  unsigned MainCoderIndex;
234370b324cSopenharmony_ci
235370b324cSopenharmony_ci  // bool InternalPackSizeError;
236370b324cSopenharmony_ci
237370b324cSopenharmony_ci  CMixer(bool encodeMode):
238370b324cSopenharmony_ci      EncodeMode(encodeMode),
239370b324cSopenharmony_ci      MainCoderIndex(0)
240370b324cSopenharmony_ci      // , InternalPackSizeError(false)
241370b324cSopenharmony_ci      {}
242370b324cSopenharmony_ci
243370b324cSopenharmony_ci  virtual ~CMixer() {}
244370b324cSopenharmony_ci  /*
245370b324cSopenharmony_ci  Sequence of calling:
246370b324cSopenharmony_ci
247370b324cSopenharmony_ci      SetBindInfo();
248370b324cSopenharmony_ci      for each coder
249370b324cSopenharmony_ci        AddCoder();
250370b324cSopenharmony_ci      SelectMainCoder();
251370b324cSopenharmony_ci
252370b324cSopenharmony_ci      for each file
253370b324cSopenharmony_ci      {
254370b324cSopenharmony_ci        ReInit()
255370b324cSopenharmony_ci        for each coder
256370b324cSopenharmony_ci          SetCoderInfo();
257370b324cSopenharmony_ci        Code();
258370b324cSopenharmony_ci      }
259370b324cSopenharmony_ci  */
260370b324cSopenharmony_ci
261370b324cSopenharmony_ci  virtual HRESULT SetBindInfo(const CBindInfo &bindInfo)
262370b324cSopenharmony_ci  {
263370b324cSopenharmony_ci    _bi = bindInfo;
264370b324cSopenharmony_ci    IsFilter_Vector.Clear();
265370b324cSopenharmony_ci    MainCoderIndex = 0;
266370b324cSopenharmony_ci    return S_OK;
267370b324cSopenharmony_ci  }
268370b324cSopenharmony_ci
269370b324cSopenharmony_ci  virtual void AddCoder(const CCreatedCoder &cod) = 0;
270370b324cSopenharmony_ci  virtual CCoder &GetCoder(unsigned index) = 0;
271370b324cSopenharmony_ci  virtual void SelectMainCoder(bool useFirst) = 0;
272370b324cSopenharmony_ci  virtual HRESULT ReInit2() = 0;
273370b324cSopenharmony_ci  virtual void SetCoderInfo(unsigned coderIndex, const UInt64 *unpackSize, const UInt64 * const *packSizes, bool finish) = 0;
274370b324cSopenharmony_ci  virtual HRESULT Code(
275370b324cSopenharmony_ci      ISequentialInStream * const *inStreams,
276370b324cSopenharmony_ci      ISequentialOutStream * const *outStreams,
277370b324cSopenharmony_ci      ICompressProgressInfo *progress,
278370b324cSopenharmony_ci      bool &dataAfterEnd_Error) = 0;
279370b324cSopenharmony_ci  virtual UInt64 GetBondStreamSize(unsigned bondIndex) const = 0;
280370b324cSopenharmony_ci
281370b324cSopenharmony_ci  bool Is_UnpackSize_Correct_for_Coder(UInt32 coderIndex);
282370b324cSopenharmony_ci  bool Is_PackSize_Correct_for_Coder(UInt32 coderIndex);
283370b324cSopenharmony_ci  bool IsThere_ExternalCoder_in_PackTree(UInt32 coderIndex);
284370b324cSopenharmony_ci};
285370b324cSopenharmony_ci
286370b324cSopenharmony_ci
287370b324cSopenharmony_ci
288370b324cSopenharmony_ci
289370b324cSopenharmony_ci#ifdef USE_MIXER_ST
290370b324cSopenharmony_ci
291370b324cSopenharmony_cistruct CCoderST: public CCoder
292370b324cSopenharmony_ci{
293370b324cSopenharmony_ci  bool CanRead;
294370b324cSopenharmony_ci  bool CanWrite;
295370b324cSopenharmony_ci
296370b324cSopenharmony_ci  CCoderST(): CanRead(false), CanWrite(false) {}
297370b324cSopenharmony_ci};
298370b324cSopenharmony_ci
299370b324cSopenharmony_ci
300370b324cSopenharmony_cistruct CStBinderStream
301370b324cSopenharmony_ci{
302370b324cSopenharmony_ci  CSequentialInStreamCalcSize *InStreamSpec;
303370b324cSopenharmony_ci  COutStreamCalcSize *OutStreamSpec;
304370b324cSopenharmony_ci  CMyComPtr<IUnknown> StreamRef;
305370b324cSopenharmony_ci
306370b324cSopenharmony_ci  CStBinderStream(): InStreamSpec(NULL), OutStreamSpec(NULL) {}
307370b324cSopenharmony_ci};
308370b324cSopenharmony_ci
309370b324cSopenharmony_ci
310370b324cSopenharmony_ciclass CMixerST:
311370b324cSopenharmony_ci  public IUnknown,
312370b324cSopenharmony_ci  public CMixer,
313370b324cSopenharmony_ci  public CMyUnknownImp
314370b324cSopenharmony_ci{
315370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_0
316370b324cSopenharmony_ci  Z7_CLASS_NO_COPY(CMixerST)
317370b324cSopenharmony_ci
318370b324cSopenharmony_ci  HRESULT GetInStream2(ISequentialInStream * const *inStreams, /* const UInt64 * const *inSizes, */
319370b324cSopenharmony_ci      UInt32 outStreamIndex, ISequentialInStream **inStreamRes);
320370b324cSopenharmony_ci  HRESULT GetInStream(ISequentialInStream * const *inStreams, /* const UInt64 * const *inSizes, */
321370b324cSopenharmony_ci      UInt32 inStreamIndex, ISequentialInStream **inStreamRes);
322370b324cSopenharmony_ci  HRESULT GetOutStream(ISequentialOutStream * const *outStreams, /* const UInt64 * const *outSizes, */
323370b324cSopenharmony_ci      UInt32 outStreamIndex, ISequentialOutStream **outStreamRes);
324370b324cSopenharmony_ci
325370b324cSopenharmony_ci  HRESULT FinishStream(UInt32 streamIndex);
326370b324cSopenharmony_ci  HRESULT FinishCoder(UInt32 coderIndex);
327370b324cSopenharmony_ci
328370b324cSopenharmony_cipublic:
329370b324cSopenharmony_ci  CObjectVector<CCoderST> _coders;
330370b324cSopenharmony_ci
331370b324cSopenharmony_ci  CObjectVector<CStBinderStream> _binderStreams;
332370b324cSopenharmony_ci
333370b324cSopenharmony_ci  CMixerST(bool encodeMode);
334370b324cSopenharmony_ci  ~CMixerST() Z7_DESTRUCTOR_override;
335370b324cSopenharmony_ci
336370b324cSopenharmony_ci  virtual void AddCoder(const CCreatedCoder &cod) Z7_override;
337370b324cSopenharmony_ci  virtual CCoder &GetCoder(unsigned index) Z7_override;
338370b324cSopenharmony_ci  virtual void SelectMainCoder(bool useFirst) Z7_override;
339370b324cSopenharmony_ci  virtual HRESULT ReInit2() Z7_override;
340370b324cSopenharmony_ci  virtual void SetCoderInfo(unsigned coderIndex, const UInt64 *unpackSize, const UInt64 * const *packSizes, bool finish) Z7_override
341370b324cSopenharmony_ci    { _coders[coderIndex].SetCoderInfo(unpackSize, packSizes, finish); }
342370b324cSopenharmony_ci  virtual HRESULT Code(
343370b324cSopenharmony_ci      ISequentialInStream * const *inStreams,
344370b324cSopenharmony_ci      ISequentialOutStream * const *outStreams,
345370b324cSopenharmony_ci      ICompressProgressInfo *progress,
346370b324cSopenharmony_ci      bool &dataAfterEnd_Error) Z7_override;
347370b324cSopenharmony_ci  virtual UInt64 GetBondStreamSize(unsigned bondIndex) const Z7_override;
348370b324cSopenharmony_ci
349370b324cSopenharmony_ci  HRESULT GetMainUnpackStream(
350370b324cSopenharmony_ci      ISequentialInStream * const *inStreams,
351370b324cSopenharmony_ci      ISequentialInStream **inStreamRes);
352370b324cSopenharmony_ci};
353370b324cSopenharmony_ci
354370b324cSopenharmony_ci#endif
355370b324cSopenharmony_ci
356370b324cSopenharmony_ci
357370b324cSopenharmony_ci
358370b324cSopenharmony_ci
359370b324cSopenharmony_ci#ifdef USE_MIXER_MT
360370b324cSopenharmony_ci
361370b324cSopenharmony_ciclass CCoderMT: public CCoder, public CVirtThread
362370b324cSopenharmony_ci{
363370b324cSopenharmony_ci  Z7_CLASS_NO_COPY(CCoderMT)
364370b324cSopenharmony_ci  CRecordVector<ISequentialInStream*> InStreamPointers;
365370b324cSopenharmony_ci  CRecordVector<ISequentialOutStream*> OutStreamPointers;
366370b324cSopenharmony_ci
367370b324cSopenharmony_ciprivate:
368370b324cSopenharmony_ci  virtual void Execute() Z7_override;
369370b324cSopenharmony_cipublic:
370370b324cSopenharmony_ci  bool EncodeMode;
371370b324cSopenharmony_ci  HRESULT Result;
372370b324cSopenharmony_ci  CObjectVector< CMyComPtr<ISequentialInStream> > InStreams;
373370b324cSopenharmony_ci  CObjectVector< CMyComPtr<ISequentialOutStream> > OutStreams;
374370b324cSopenharmony_ci
375370b324cSopenharmony_ci  void Release()
376370b324cSopenharmony_ci  {
377370b324cSopenharmony_ci    InStreamPointers.Clear();
378370b324cSopenharmony_ci    OutStreamPointers.Clear();
379370b324cSopenharmony_ci    unsigned i;
380370b324cSopenharmony_ci    for (i = 0; i < InStreams.Size(); i++)
381370b324cSopenharmony_ci      InStreams[i].Release();
382370b324cSopenharmony_ci    for (i = 0; i < OutStreams.Size(); i++)
383370b324cSopenharmony_ci      OutStreams[i].Release();
384370b324cSopenharmony_ci  }
385370b324cSopenharmony_ci
386370b324cSopenharmony_ci  class CReleaser
387370b324cSopenharmony_ci  {
388370b324cSopenharmony_ci    Z7_CLASS_NO_COPY(CReleaser)
389370b324cSopenharmony_ci    CCoderMT &_c;
390370b324cSopenharmony_ci  public:
391370b324cSopenharmony_ci    CReleaser(CCoderMT &c): _c(c) {}
392370b324cSopenharmony_ci    ~CReleaser() { _c.Release(); }
393370b324cSopenharmony_ci  };
394370b324cSopenharmony_ci
395370b324cSopenharmony_ci  CCoderMT(): EncodeMode(false) {}
396370b324cSopenharmony_ci  ~CCoderMT() Z7_DESTRUCTOR_override
397370b324cSopenharmony_ci  {
398370b324cSopenharmony_ci    /* WaitThreadFinish() will be called in ~CVirtThread().
399370b324cSopenharmony_ci       But we need WaitThreadFinish() call before CCoder destructor,
400370b324cSopenharmony_ci       and before destructors of this class members.
401370b324cSopenharmony_ci    */
402370b324cSopenharmony_ci    CVirtThread::WaitThreadFinish();
403370b324cSopenharmony_ci  }
404370b324cSopenharmony_ci
405370b324cSopenharmony_ci  void Code(ICompressProgressInfo *progress);
406370b324cSopenharmony_ci};
407370b324cSopenharmony_ci
408370b324cSopenharmony_ci
409370b324cSopenharmony_ciclass CMixerMT:
410370b324cSopenharmony_ci  public IUnknown,
411370b324cSopenharmony_ci  public CMixer,
412370b324cSopenharmony_ci  public CMyUnknownImp
413370b324cSopenharmony_ci{
414370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_0
415370b324cSopenharmony_ci  Z7_CLASS_NO_COPY(CMixerMT)
416370b324cSopenharmony_ci
417370b324cSopenharmony_ci  CObjectVector<CStreamBinder> _streamBinders;
418370b324cSopenharmony_ci
419370b324cSopenharmony_ci  HRESULT Init(ISequentialInStream * const *inStreams, ISequentialOutStream * const *outStreams);
420370b324cSopenharmony_ci  HRESULT ReturnIfError(HRESULT code);
421370b324cSopenharmony_ci
422370b324cSopenharmony_ci  // virtual ~CMixerMT() {}
423370b324cSopenharmony_cipublic:
424370b324cSopenharmony_ci  CObjectVector<CCoderMT> _coders;
425370b324cSopenharmony_ci
426370b324cSopenharmony_ci  virtual HRESULT SetBindInfo(const CBindInfo &bindInfo) Z7_override;
427370b324cSopenharmony_ci  virtual void AddCoder(const CCreatedCoder &cod) Z7_override;
428370b324cSopenharmony_ci  virtual CCoder &GetCoder(unsigned index) Z7_override;
429370b324cSopenharmony_ci  virtual void SelectMainCoder(bool useFirst) Z7_override;
430370b324cSopenharmony_ci  virtual HRESULT ReInit2() Z7_override;
431370b324cSopenharmony_ci  virtual void SetCoderInfo(unsigned coderIndex, const UInt64 *unpackSize, const UInt64 * const *packSizes, bool finish) Z7_override
432370b324cSopenharmony_ci    { _coders[coderIndex].SetCoderInfo(unpackSize, packSizes, finish); }
433370b324cSopenharmony_ci  virtual HRESULT Code(
434370b324cSopenharmony_ci      ISequentialInStream * const *inStreams,
435370b324cSopenharmony_ci      ISequentialOutStream * const *outStreams,
436370b324cSopenharmony_ci      ICompressProgressInfo *progress,
437370b324cSopenharmony_ci      bool &dataAfterEnd_Error) Z7_override;
438370b324cSopenharmony_ci  virtual UInt64 GetBondStreamSize(unsigned bondIndex) const Z7_override;
439370b324cSopenharmony_ci
440370b324cSopenharmony_ci  CMixerMT(bool encodeMode): CMixer(encodeMode) {}
441370b324cSopenharmony_ci};
442370b324cSopenharmony_ci
443370b324cSopenharmony_ci#endif
444370b324cSopenharmony_ci
445370b324cSopenharmony_ci}
446370b324cSopenharmony_ci
447370b324cSopenharmony_ci#endif
448