michael@0: // CoderMixer2.h michael@0: michael@0: #ifndef __CODER_MIXER2_H michael@0: #define __CODER_MIXER2_H michael@0: michael@0: #include "../../../Common/Vector.h" michael@0: #include "../../../Common/Types.h" michael@0: #include "../../../Common/MyCom.h" michael@0: #include "../../ICoder.h" michael@0: michael@0: namespace NCoderMixer2 { michael@0: michael@0: struct CBindPair michael@0: { michael@0: UInt32 InIndex; michael@0: UInt32 OutIndex; michael@0: }; michael@0: michael@0: struct CCoderStreamsInfo michael@0: { michael@0: UInt32 NumInStreams; michael@0: UInt32 NumOutStreams; michael@0: }; michael@0: michael@0: struct CBindInfo michael@0: { michael@0: CRecordVector Coders; michael@0: CRecordVector BindPairs; michael@0: CRecordVector InStreams; michael@0: CRecordVector OutStreams; michael@0: michael@0: void Clear() michael@0: { michael@0: Coders.Clear(); michael@0: BindPairs.Clear(); michael@0: InStreams.Clear(); michael@0: OutStreams.Clear(); michael@0: } michael@0: michael@0: /* michael@0: UInt32 GetCoderStartOutStream(UInt32 coderIndex) const michael@0: { michael@0: UInt32 numOutStreams = 0; michael@0: for (UInt32 i = 0; i < coderIndex; i++) michael@0: numOutStreams += Coders[i].NumOutStreams; michael@0: return numOutStreams; michael@0: } michael@0: */ michael@0: michael@0: michael@0: void GetNumStreams(UInt32 &numInStreams, UInt32 &numOutStreams) const michael@0: { michael@0: numInStreams = 0; michael@0: numOutStreams = 0; michael@0: for (int i = 0; i < Coders.Size(); i++) michael@0: { michael@0: const CCoderStreamsInfo &coderStreamsInfo = Coders[i]; michael@0: numInStreams += coderStreamsInfo.NumInStreams; michael@0: numOutStreams += coderStreamsInfo.NumOutStreams; michael@0: } michael@0: } michael@0: michael@0: int FindBinderForInStream(UInt32 inStream) const michael@0: { michael@0: for (int i = 0; i < BindPairs.Size(); i++) michael@0: if (BindPairs[i].InIndex == inStream) michael@0: return i; michael@0: return -1; michael@0: } michael@0: int FindBinderForOutStream(UInt32 outStream) const michael@0: { michael@0: for (int i = 0; i < BindPairs.Size(); i++) michael@0: if (BindPairs[i].OutIndex == outStream) michael@0: return i; michael@0: return -1; michael@0: } michael@0: michael@0: UInt32 GetCoderInStreamIndex(UInt32 coderIndex) const michael@0: { michael@0: UInt32 streamIndex = 0; michael@0: for (UInt32 i = 0; i < coderIndex; i++) michael@0: streamIndex += Coders[i].NumInStreams; michael@0: return streamIndex; michael@0: } michael@0: michael@0: UInt32 GetCoderOutStreamIndex(UInt32 coderIndex) const michael@0: { michael@0: UInt32 streamIndex = 0; michael@0: for (UInt32 i = 0; i < coderIndex; i++) michael@0: streamIndex += Coders[i].NumOutStreams; michael@0: return streamIndex; michael@0: } michael@0: michael@0: michael@0: void FindInStream(UInt32 streamIndex, UInt32 &coderIndex, michael@0: UInt32 &coderStreamIndex) const michael@0: { michael@0: for (coderIndex = 0; coderIndex < (UInt32)Coders.Size(); coderIndex++) michael@0: { michael@0: UInt32 curSize = Coders[coderIndex].NumInStreams; michael@0: if (streamIndex < curSize) michael@0: { michael@0: coderStreamIndex = streamIndex; michael@0: return; michael@0: } michael@0: streamIndex -= curSize; michael@0: } michael@0: throw 1; michael@0: } michael@0: void FindOutStream(UInt32 streamIndex, UInt32 &coderIndex, michael@0: UInt32 &coderStreamIndex) const michael@0: { michael@0: for (coderIndex = 0; coderIndex < (UInt32)Coders.Size(); coderIndex++) michael@0: { michael@0: UInt32 curSize = Coders[coderIndex].NumOutStreams; michael@0: if (streamIndex < curSize) michael@0: { michael@0: coderStreamIndex = streamIndex; michael@0: return; michael@0: } michael@0: streamIndex -= curSize; michael@0: } michael@0: throw 1; michael@0: } michael@0: }; michael@0: michael@0: class CBindReverseConverter michael@0: { michael@0: UInt32 _numSrcOutStreams; michael@0: const NCoderMixer2::CBindInfo _srcBindInfo; michael@0: CRecordVector _srcInToDestOutMap; michael@0: CRecordVector _srcOutToDestInMap; michael@0: CRecordVector _destInToSrcOutMap; michael@0: public: michael@0: UInt32 NumSrcInStreams; michael@0: CRecordVector DestOutToSrcInMap; michael@0: michael@0: CBindReverseConverter(const NCoderMixer2::CBindInfo &srcBindInfo); michael@0: void CreateReverseBindInfo(NCoderMixer2::CBindInfo &destBindInfo); michael@0: }; michael@0: michael@0: struct CCoderInfo michael@0: { michael@0: CMyComPtr Coder; michael@0: CMyComPtr Coder2; michael@0: UInt32 NumInStreams; michael@0: UInt32 NumOutStreams; michael@0: michael@0: CRecordVector InSizes; michael@0: CRecordVector OutSizes; michael@0: CRecordVector InSizePointers; michael@0: CRecordVector OutSizePointers; michael@0: michael@0: CCoderInfo(UInt32 numInStreams, UInt32 numOutStreams); michael@0: void SetCoderInfo(const UInt64 **inSizes, const UInt64 **outSizes); michael@0: }; michael@0: michael@0: class CCoderMixer2 michael@0: { michael@0: public: michael@0: virtual void SetBindInfo(const CBindInfo &bindInfo) = 0; michael@0: virtual void ReInit() = 0; michael@0: virtual void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes) = 0; michael@0: }; michael@0: michael@0: } michael@0: #endif michael@0: