javazoom.jl.decoder.Crc16.add_bits C# (CSharp) Метод

add_bits() публичный Метод

Feed a bitstring to the crc calculation (0 < length <= 32).
public add_bits ( int bitstring, int length ) : void
bitstring int
length int
Результат void
        public void add_bits(int bitstring, int length)
        {
            int bitmask = 1 << (length - 1);
            do
                if (((crc & 0x8000) == 0) ^ ((bitstring & bitmask) == 0))
                {
                    crc <<= 1;
                    crc ^= polynomial;
                }
                else
                    crc <<= 1;
            while ((bitmask = SupportClass.URShift(bitmask, 1)) != 0);
        }

Usage Example

 /// <summary>*
 /// </summary>
 public override void  read_allocation(Bitstream stream, Header header, Crc16 crc)
 {
     allocation          = stream.get_bits(4);
     channel2_allocation = stream.get_bits(4);
     if (crc != null)
     {
         crc.add_bits(allocation, 4);
         crc.add_bits(channel2_allocation, 4);
     }
     if (allocation != 0)
     {
         samplelength = allocation + 1;
         factor       = table_factor[allocation];
         offset       = table_offset[allocation];
     }
     if (channel2_allocation != 0)
     {
         channel2_samplelength = channel2_allocation + 1;
         channel2_factor       = table_factor[channel2_allocation];
         channel2_offset       = table_offset[channel2_allocation];
     }
 }
All Usage Examples Of javazoom.jl.decoder.Crc16::add_bits