示例#1
0
        /// <summary>
        /// calculate EDC crc tables
        /// </summary>
        static void Prep_EDC()
        {
            //14.3 of yellowbook specifies EDC crc as P(x) = (x^16 + x^15 + x^2 + 1) . (x^16 + x^2 + x + 1)
            //confirmation at http://cdmagediscussion.yuku.com/topic/742/EDC-calculation
            //int Pa = 0x18005;
            //int Pb = 0x10007;
            //long Px = 0;
            //for (int i = 0; i <= 16; i++)
            //  for (int j = 0; j <= 16; j++)
            //  {
            //    //multiply Pa[i] * Pb[j]
            //    int bit = (Pa >> i) & (Pb >> j) & 1;
            //    //xor into result, achieving modulo-2 thereby
            //    Px ^= (long)bit << (i + j);
            //  }
            //uint edc_poly = (uint)Px;
            const uint edc_poly = 0x8001801B;

            //generate the CRC table
            uint reverse_edc_poly = BitReverse.Reverse32(edc_poly);

            for (uint i = 0; i < 256; ++i)
            {
                uint crc = i;
                for (int j = 8; j > 0; --j)
                {
                    if ((crc & 1) == 1)
                    {
                        crc = ((crc >> 1) ^ reverse_edc_poly);
                    }
                    else
                    {
                        crc >>= 1;
                    }
                }
                edc_table[i] = crc;
            }
        }
示例#2
0
 public static void Setup()
 {
     BitReverse.Setup();
     TwiddleFactors.Setup();
 }
示例#3
0
 static Transform()
 {
     BitReverse.Setup();
     TwiddleFactors.Setup();
 }