Esempio n. 1
0
        public bool CheckStructure()
        {
            const int kNumCodersMax = 32; // don't change it
            const int kMaskSize = 32; // it must be >= kNumCodersMax
            const int kNumBindsMax = 32;

            if (Coders.Count > kNumCodersMax || BindPairs.Count > kNumBindsMax)
                return false;

            {
                var v = new BitVector(BindPairs.Count + PackStreams.Count);

                for (int i = 0; i < BindPairs.Count; i++)
                    if (v.GetAndSet(BindPairs[i].InIndex))
                        return false;

                for (int i = 0; i < PackStreams.Count; i++)
                    if (v.GetAndSet(PackStreams[i]))
                        return false;
            }

            {
                var v = new BitVector(UnpackSizes.Count);
                for (int i = 0; i < BindPairs.Count; i++)
                    if (v.GetAndSet(BindPairs[i].OutIndex))
                        return false;
            }

            uint[] mask = new uint[kMaskSize];

            {
                List<int> inStreamToCoder = new List<int>();
                List<int> outStreamToCoder = new List<int>();
                for (int i = 0; i < Coders.Count; i++)
                {
                    CCoderInfo coder = Coders[i];
                    for (int j = 0; j < coder.NumInStreams; j++)
                        inStreamToCoder.Add(i);
                    for (int j = 0; j < coder.NumOutStreams; j++)
                        outStreamToCoder.Add(i);
                }

                for (int i = 0; i < BindPairs.Count; i++)
                {
                    CBindPair bp = BindPairs[i];
                    mask[inStreamToCoder[bp.InIndex]] |= (1u << outStreamToCoder[bp.OutIndex]);
                }
            }

            for (int i = 0; i < kMaskSize; i++)
                for (int j = 0; j < kMaskSize; j++)
                    if (((1u << j) & mask[i]) != 0)
                        mask[i] |= mask[j];

            for (int i = 0; i < kMaskSize; i++)
                if (((1u << i) & mask[i]) != 0)
                    return false;

            return true;
        }
Esempio n. 2
0
 public bool CheckStructure()
 {
     int num;
     int num2;
     if ((this.Coders.Count > 0x20) || (this.BindPairs.Count > 0x20))
     {
         return false;
     }
     BitVector vector = new BitVector(this.BindPairs.Count + this.PackStreams.Count);
     for (num = 0; num < this.BindPairs.Count; num++)
     {
         if (vector.GetAndSet(this.BindPairs[num].InIndex))
         {
             return false;
         }
     }
     for (num = 0; num < this.PackStreams.Count; num++)
     {
         if (vector.GetAndSet(this.PackStreams[num]))
         {
             return false;
         }
     }
     vector = new BitVector(this.UnpackSizes.Count);
     for (num = 0; num < this.BindPairs.Count; num++)
     {
         if (vector.GetAndSet(this.BindPairs[num].OutIndex))
         {
             return false;
         }
     }
     uint[] numArray = new uint[0x20];
     List<int> list = new List<int>();
     List<int> list2 = new List<int>();
     for (num = 0; num < this.Coders.Count; num++)
     {
         CCoderInfo info = this.Coders[num];
         num2 = 0;
         while (num2 < info.NumInStreams)
         {
             list.Add(num);
             num2++;
         }
         num2 = 0;
         while (num2 < info.NumOutStreams)
         {
             list2.Add(num);
             num2++;
         }
     }
     for (num = 0; num < this.BindPairs.Count; num++)
     {
         CBindPair pair = this.BindPairs[num];
         numArray[list[pair.InIndex]] |= ((uint) 1) << list2[pair.OutIndex];
     }
     for (num = 0; num < 0x20; num++)
     {
         for (num2 = 0; num2 < 0x20; num2++)
         {
             if (((((int) 1) << num2) & numArray[num]) != 0)
             {
                 numArray[num] |= numArray[num2];
             }
         }
     }
     for (num = 0; num < 0x20; num++)
     {
         if (((((int) 1) << num) & numArray[num]) != 0)
         {
             return false;
         }
     }
     return true;
 }