1baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// CoderMixer2.h 2baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 3baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#ifndef __CODER_MIXER2_H 4baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#define __CODER_MIXER2_H 5baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 6baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "../../../Common/MyCom.h" 7cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky#include "../../../Common/MyVector.h" 8cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky 9baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "../../ICoder.h" 10baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 11baa3858d3f5d128a5c8466b700098109edcad5f2repo syncnamespace NCoderMixer { 12baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 13baa3858d3f5d128a5c8466b700098109edcad5f2repo syncstruct CBindPair 14baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 15baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UInt32 InIndex; 16baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UInt32 OutIndex; 17baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}; 18baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 19baa3858d3f5d128a5c8466b700098109edcad5f2repo syncstruct CCoderStreamsInfo 20baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 21baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UInt32 NumInStreams; 22baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UInt32 NumOutStreams; 23baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}; 24baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 25baa3858d3f5d128a5c8466b700098109edcad5f2repo syncstruct CBindInfo 26baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 27baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CRecordVector<CCoderStreamsInfo> Coders; 28baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CRecordVector<CBindPair> BindPairs; 29baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CRecordVector<UInt32> InStreams; 30baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CRecordVector<UInt32> OutStreams; 31baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 32baa3858d3f5d128a5c8466b700098109edcad5f2repo sync void Clear() 33baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 34baa3858d3f5d128a5c8466b700098109edcad5f2repo sync Coders.Clear(); 35baa3858d3f5d128a5c8466b700098109edcad5f2repo sync BindPairs.Clear(); 36baa3858d3f5d128a5c8466b700098109edcad5f2repo sync InStreams.Clear(); 37baa3858d3f5d128a5c8466b700098109edcad5f2repo sync OutStreams.Clear(); 38baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 39baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 40baa3858d3f5d128a5c8466b700098109edcad5f2repo sync /* 41baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UInt32 GetCoderStartOutStream(UInt32 coderIndex) const 42baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 43baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UInt32 numOutStreams = 0; 44baa3858d3f5d128a5c8466b700098109edcad5f2repo sync for (UInt32 i = 0; i < coderIndex; i++) 45baa3858d3f5d128a5c8466b700098109edcad5f2repo sync numOutStreams += Coders[i].NumOutStreams; 46baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return numOutStreams; 47baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 48baa3858d3f5d128a5c8466b700098109edcad5f2repo sync */ 49baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 50baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 51baa3858d3f5d128a5c8466b700098109edcad5f2repo sync void GetNumStreams(UInt32 &numInStreams, UInt32 &numOutStreams) const 52baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 53baa3858d3f5d128a5c8466b700098109edcad5f2repo sync numInStreams = 0; 54baa3858d3f5d128a5c8466b700098109edcad5f2repo sync numOutStreams = 0; 55cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky FOR_VECTOR (i, Coders) 56baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 57baa3858d3f5d128a5c8466b700098109edcad5f2repo sync const CCoderStreamsInfo &coderStreamsInfo = Coders[i]; 58baa3858d3f5d128a5c8466b700098109edcad5f2repo sync numInStreams += coderStreamsInfo.NumInStreams; 59baa3858d3f5d128a5c8466b700098109edcad5f2repo sync numOutStreams += coderStreamsInfo.NumOutStreams; 60baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 61baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 62baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 63baa3858d3f5d128a5c8466b700098109edcad5f2repo sync int FindBinderForInStream(UInt32 inStream) const 64baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 65cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky FOR_VECTOR (i, BindPairs) 66baa3858d3f5d128a5c8466b700098109edcad5f2repo sync if (BindPairs[i].InIndex == inStream) 67baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return i; 68baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return -1; 69baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 70baa3858d3f5d128a5c8466b700098109edcad5f2repo sync int FindBinderForOutStream(UInt32 outStream) const 71baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 72cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky FOR_VECTOR (i, BindPairs) 73baa3858d3f5d128a5c8466b700098109edcad5f2repo sync if (BindPairs[i].OutIndex == outStream) 74baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return i; 75baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return -1; 76baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 77baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 78baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UInt32 GetCoderInStreamIndex(UInt32 coderIndex) const 79baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 80baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UInt32 streamIndex = 0; 81baa3858d3f5d128a5c8466b700098109edcad5f2repo sync for (UInt32 i = 0; i < coderIndex; i++) 82baa3858d3f5d128a5c8466b700098109edcad5f2repo sync streamIndex += Coders[i].NumInStreams; 83baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return streamIndex; 84baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 85baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 86baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UInt32 GetCoderOutStreamIndex(UInt32 coderIndex) const 87baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 88baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UInt32 streamIndex = 0; 89baa3858d3f5d128a5c8466b700098109edcad5f2repo sync for (UInt32 i = 0; i < coderIndex; i++) 90baa3858d3f5d128a5c8466b700098109edcad5f2repo sync streamIndex += Coders[i].NumOutStreams; 91baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return streamIndex; 92baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 93baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 94baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 95baa3858d3f5d128a5c8466b700098109edcad5f2repo sync void FindInStream(UInt32 streamIndex, UInt32 &coderIndex, 96baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UInt32 &coderStreamIndex) const 97baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 98baa3858d3f5d128a5c8466b700098109edcad5f2repo sync for (coderIndex = 0; coderIndex < (UInt32)Coders.Size(); coderIndex++) 99baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 100baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UInt32 curSize = Coders[coderIndex].NumInStreams; 101baa3858d3f5d128a5c8466b700098109edcad5f2repo sync if (streamIndex < curSize) 102baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 103baa3858d3f5d128a5c8466b700098109edcad5f2repo sync coderStreamIndex = streamIndex; 104baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return; 105baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 106baa3858d3f5d128a5c8466b700098109edcad5f2repo sync streamIndex -= curSize; 107baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 108baa3858d3f5d128a5c8466b700098109edcad5f2repo sync throw 1; 109baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 110baa3858d3f5d128a5c8466b700098109edcad5f2repo sync void FindOutStream(UInt32 streamIndex, UInt32 &coderIndex, 111baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UInt32 &coderStreamIndex) const 112baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 113baa3858d3f5d128a5c8466b700098109edcad5f2repo sync for (coderIndex = 0; coderIndex < (UInt32)Coders.Size(); coderIndex++) 114baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 115baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UInt32 curSize = Coders[coderIndex].NumOutStreams; 116baa3858d3f5d128a5c8466b700098109edcad5f2repo sync if (streamIndex < curSize) 117baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 118baa3858d3f5d128a5c8466b700098109edcad5f2repo sync coderStreamIndex = streamIndex; 119baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return; 120baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 121baa3858d3f5d128a5c8466b700098109edcad5f2repo sync streamIndex -= curSize; 122baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 123baa3858d3f5d128a5c8466b700098109edcad5f2repo sync throw 1; 124baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 125baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}; 126baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 127baa3858d3f5d128a5c8466b700098109edcad5f2repo syncclass CBindReverseConverter 128baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 129baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UInt32 _numSrcOutStreams; 130baa3858d3f5d128a5c8466b700098109edcad5f2repo sync NCoderMixer::CBindInfo _srcBindInfo; 131baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CRecordVector<UInt32> _srcInToDestOutMap; 132baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CRecordVector<UInt32> _srcOutToDestInMap; 133baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CRecordVector<UInt32> _destInToSrcOutMap; 134baa3858d3f5d128a5c8466b700098109edcad5f2repo syncpublic: 135baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UInt32 NumSrcInStreams; 136baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CRecordVector<UInt32> DestOutToSrcInMap; 137baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 138baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CBindReverseConverter(const NCoderMixer::CBindInfo &srcBindInfo); 139baa3858d3f5d128a5c8466b700098109edcad5f2repo sync void CreateReverseBindInfo(NCoderMixer::CBindInfo &destBindInfo); 140baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}; 141baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 142cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbeckyvoid SetSizes(const UInt64 **srcSizes, CRecordVector<UInt64> &sizes, 143cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky CRecordVector<const UInt64 *> &sizePointers, UInt32 numItems); 144cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky 145baa3858d3f5d128a5c8466b700098109edcad5f2repo syncstruct CCoderInfo2 146baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 147baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CMyComPtr<ICompressCoder> Coder; 148baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CMyComPtr<ICompressCoder2> Coder2; 149baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UInt32 NumInStreams; 150baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UInt32 NumOutStreams; 151baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 152baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CRecordVector<UInt64> InSizes; 153baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CRecordVector<UInt64> OutSizes; 154baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CRecordVector<const UInt64 *> InSizePointers; 155baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CRecordVector<const UInt64 *> OutSizePointers; 156baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 157cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky CCoderInfo2(UInt32 numInStreams, UInt32 numOutStreams): 158cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky NumInStreams(numInStreams), 159cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky NumOutStreams(numOutStreams) {} 160baa3858d3f5d128a5c8466b700098109edcad5f2repo sync void SetCoderInfo(const UInt64 **inSizes, const UInt64 **outSizes); 161baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 162baa3858d3f5d128a5c8466b700098109edcad5f2repo sync HRESULT QueryInterface(REFGUID iid, void** pp) const 163baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 164baa3858d3f5d128a5c8466b700098109edcad5f2repo sync IUnknown *p = Coder ? (IUnknown *)Coder : (IUnknown *)Coder2; 165baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return p->QueryInterface(iid, pp); 166baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 167baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}; 168baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 169baa3858d3f5d128a5c8466b700098109edcad5f2repo syncclass CCoderMixer2 170baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 171baa3858d3f5d128a5c8466b700098109edcad5f2repo syncpublic: 172baa3858d3f5d128a5c8466b700098109edcad5f2repo sync virtual HRESULT SetBindInfo(const CBindInfo &bindInfo) = 0; 173baa3858d3f5d128a5c8466b700098109edcad5f2repo sync virtual void ReInit() = 0; 174baa3858d3f5d128a5c8466b700098109edcad5f2repo sync virtual void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes) = 0; 175baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}; 176baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 177baa3858d3f5d128a5c8466b700098109edcad5f2repo sync} 178baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 179cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky#endif 180