lib/parsers/ogg_parser.rb
# Calculate the CRC using the 0x04C11DB7 polynomial. We cannot use Zlib since
# it generates different checksums. Copied from https://github.com/anibali/ruby-ogg
Calculate the CRC using the 0x04C11DB7 polynomial. We cannot use Zlib since
it generates different checksums.
Calculate the CRC using the 0x04C11DB7 polynomial . We cannot use Zlib since it generates different checksums .
def calculate_checksum(data)
    crc_reg = 0
    data.each_byte.with_index do |byte, i|
      b = (22..25).cover?(i) ? 0 : byte
      crc_reg = (crc_reg << 8) ^ CRC_LOOKUP[((crc_reg >> 24) & 0xff) ^ b]
      crc_reg = crc_reg % 2**32
    end
    crc_reg
  end
def calculate_checksum ( data ) crc_reg = 0 data . each_byte . with_index do | byte , i | b = ( 22 .. 25 ) . cover? ( i ) ? 0 : byte crc_reg = ( crc_reg << 8 ) ^ CRC_LOOKUP [ ( ( crc_reg >> 24 ) & 0xff ) ^ b ] crc_reg = crc_reg % 2 ** 32 end crc_reg end
Calculate the CRC using the 0x04C11DB7 polynomial.
Calculate the CRC using the 0x04C11DB7 polynomial .
# The checksum is calculated over _the entire page_ but with the # placeholder for the checksum - the 4 bytes - zeroed out. The checksum # is then substituted _into_ the page at that offset. So when we go # over bytes at these offsets we will substitute them with 0s
data