• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // 7zEncode.h
2 
3 #ifndef __7Z_ENCODE_H
4 #define __7Z_ENCODE_H
5 
6 #include "7zCompressionMode.h"
7 
8 #include "../Common/CoderMixer2.h"
9 
10 #include "7zItem.h"
11 
12 namespace NArchive {
13 namespace N7z {
14 
15 class CMtEncMultiProgress:
16   public ICompressProgressInfo,
17   public CMyUnknownImp
18 {
19   CMyComPtr<ICompressProgressInfo> _progress;
20   #ifndef _7ZIP_ST
21   NWindows::NSynchronization::CCriticalSection CriticalSection;
22   #endif
23 
24 public:
25   UInt64 OutSize;
26 
CMtEncMultiProgress()27   CMtEncMultiProgress(): OutSize(0) {}
28 
29   void Init(ICompressProgressInfo *progress);
30 
AddOutSize(UInt64 addOutSize)31   void AddOutSize(UInt64 addOutSize)
32   {
33     #ifndef _7ZIP_ST
34     NWindows::NSynchronization::CCriticalSectionLock lock(CriticalSection);
35     #endif
36     OutSize += addOutSize;
37   }
38 
39   MY_UNKNOWN_IMP1(ICompressProgressInfo)
40 
41   STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
42 };
43 
44 class CEncoder
45 {
46   #ifdef USE_MIXER_ST
47     NCoderMixer2::CMixerST *_mixerST;
48   #endif
49   #ifdef USE_MIXER_MT
50     NCoderMixer2::CMixerMT *_mixerMT;
51   #endif
52 
53   NCoderMixer2::CMixer *_mixer;
54   CMyComPtr<IUnknown> _mixerRef;
55 
56   CCompressionMethodMode _options;
57   NCoderMixer2::CBindInfo _bindInfo;
58   CRecordVector<CMethodId> _decompressionMethods;
59 
60   CRecordVector<UInt32> _SrcIn_to_DestOut;
61   CRecordVector<UInt32> _SrcOut_to_DestIn;
62   // CRecordVector<UInt32> _DestIn_to_SrcOut;
63   CRecordVector<UInt32> _DestOut_to_SrcIn;
64 
65   void InitBindConv();
66   void SetFolder(CFolder &folder);
67 
68   HRESULT CreateMixerCoder(DECL_EXTERNAL_CODECS_LOC_VARS
69       const UInt64 *inSizeForReduce);
70 
71   bool _constructed;
72 public:
73 
74   CEncoder(const CCompressionMethodMode &options);
75   ~CEncoder();
76   HRESULT EncoderConstr();
77   HRESULT Encode(
78       DECL_EXTERNAL_CODECS_LOC_VARS
79       ISequentialInStream *inStream,
80       // const UInt64 *inStreamSize,
81       const UInt64 *inSizeForReduce,
82       CFolder &folderItem,
83       CRecordVector<UInt64> &coderUnpackSizes,
84       UInt64 &unpackSize,
85       ISequentialOutStream *outStream,
86       CRecordVector<UInt64> &packSizes,
87       ICompressProgressInfo *compressProgress);
88 };
89 
90 }}
91 
92 #endif
93