[vorbis-dev] OGG header

Keith Wright kwright at gis.net
Wed Aug 28 22:50:26 PDT 2002



> From: Keith Wright <kwright at gis.net>
> 
> the code to compute the |crc_lookup| table is right above
> the table in #if 0...#endif brackets.  The CRC algorithm
> is shift left, if a one comes out XOR with a magic number.
> The code is made more efficient by building a table with
> the result of doing this to each possible byte.

Err.  Except I begin to doubt my own words.  The algorithm
I described above would be

for(i=0;i<og->header_len;i++)
  crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)]^og->header[i];

whereas in framing.c we find
  crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->header[i]];

(note change in position of left bracket of subscript.)

That is, if you have a 32-bit shift register shifting in one bit at
a time into the low order, then the new bits shifted in do not
affect the addition of the generator "polynomial" until they
have been shifted through the intervening 24 bits, while the 
Ogg algorithm makes the new data byte affect the XORed generator
immediately.

I do not know if this difference is deliberate, or whether it
affects the error checking properties of the algorithm.  You might
just say the algorithm is what it is (the Popeye defense) and
it doesn't matter so long as it is the same every time, but
this might piss off somebody who is trying to do the checksum
in hardware with a real shift register.

Or is it so late at night that I am hallucinating without drugs?


-- 
     -- Keith Wright  <kwright at free-comp-shop.com>

Programmer in Chief, Free Computer Shop <http://www.free-comp-shop.com>
         ---  Food, Shelter, Source code.  ---
--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.




More information about the Vorbis-dev mailing list