CoderMixer2MT.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // CoderMixer2MT.h
  2. #ifndef __CODER_MIXER2_MT_H
  3. #define __CODER_MIXER2_MT_H
  4. #include "CoderMixer2.h"
  5. #include "../../../Common/MyCom.h"
  6. #include "../../Common/StreamBinder.h"
  7. #include "../../Common/VirtThread.h"
  8. namespace NCoderMixer {
  9. struct CCoder2: public CCoderInfo2, public CVirtThread
  10. {
  11. HRESULT Result;
  12. CObjectVector< CMyComPtr<ISequentialInStream> > InStreams;
  13. CObjectVector< CMyComPtr<ISequentialOutStream> > OutStreams;
  14. CRecordVector<ISequentialInStream*> InStreamPointers;
  15. CRecordVector<ISequentialOutStream*> OutStreamPointers;
  16. CCoder2(UInt32 numInStreams, UInt32 numOutStreams);
  17. void SetCoderInfo(const UInt64 **inSizes, const UInt64 **outSizes);
  18. virtual void Execute();
  19. void Code(ICompressProgressInfo *progress);
  20. };
  21. /*
  22. SetBindInfo()
  23. for each coder
  24. AddCoder[2]()
  25. SetProgressIndex(UInt32 coderIndex);
  26. for each file
  27. {
  28. ReInit()
  29. for each coder
  30. SetCoderInfo
  31. Code
  32. }
  33. */
  34. class CCoderMixer2MT:
  35. public ICompressCoder2,
  36. public CCoderMixer2,
  37. public CMyUnknownImp
  38. {
  39. CBindInfo _bindInfo;
  40. CObjectVector<CStreamBinder> _streamBinders;
  41. int _progressCoderIndex;
  42. void AddCoderCommon();
  43. HRESULT Init(ISequentialInStream **inStreams, ISequentialOutStream **outStreams);
  44. HRESULT ReturnIfError(HRESULT code);
  45. public:
  46. CObjectVector<CCoder2> _coders;
  47. MY_UNKNOWN_IMP
  48. STDMETHOD(Code)(ISequentialInStream **inStreams,
  49. const UInt64 **inSizes,
  50. UInt32 numInStreams,
  51. ISequentialOutStream **outStreams,
  52. const UInt64 **outSizes,
  53. UInt32 numOutStreams,
  54. ICompressProgressInfo *progress);
  55. HRESULT SetBindInfo(const CBindInfo &bindInfo);
  56. void AddCoder(ICompressCoder *coder);
  57. void AddCoder2(ICompressCoder2 *coder);
  58. void SetProgressCoderIndex(int coderIndex) { _progressCoderIndex = coderIndex; }
  59. void ReInit();
  60. void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes)
  61. { _coders[coderIndex].SetCoderInfo(inSizes, outSizes); }
  62. UInt64 GetWriteProcessedSize(UInt32 binderIndex) const
  63. { return _streamBinders[binderIndex].ProcessedSize; }
  64. };
  65. }
  66. #endif