Re: Ogg encapsulation

Gavin Lambert <[email protected]> Sat, 03 Apr 2004 12:01:58 +1200
Newsgroups gmane.comp.graphics.mng.general
Organization Mirality Systems
Message-ID <5.1.1.6.0.20040403113940.01f75888@localhost>
At 21:05 1/04/2004 +0200, Gerard Juyn wrote:
 >
 >0x0001 crc present (or not)
 >0x0010 crc must be checked for ancillary chunks (or not)
 >0x0020 faulty crc on ancillary chunks generate a warning (or 
not)
 >0x0040 faulty crc on ancillary chunks generate an error (or not)
 >0x0080 ancillary chunks with faulty crc get used (or discarded)
 >0x0100 crc must be checked for critical chunks (or not)
 >0x0200 faulty crc on critical chunks generate a warning (or not)
 >0x0400 faulty crc on critical chunks generate an error (or not)
 >0x0800 critical chunks with faulty crc get used (or discarded)

Maybe I'm just being too picky, or something, but this just seems 
wasteful of flag bits to me, given that most of these options are 
mutually exclusive.

How about the following instead:

0x0001  crc present in datastream
0x0010  crc checked for ancillary chunks; warning on mismatch
0x0020  crc checked for ancillary chunks; error on mismatch
0x0030  crc checked for ancillary chunks; discard on mismatch
0x0040  crc checked for critical chunks; warning on mismatch
0x0080  crc checked for critical chunks; error on mismatch

The defines would go like so:

#define MODE_CRC_PRESENT        0x0001
#define MODE_ANCILLIARY         0x0030
#define MODE_CRITICAL           0x00C0
#define MODE_ANCILLIARY_IGNORE  0x0000
#define MODE_ANCILLIARY_WARNING 0x0010
#define MODE_ANCILLIARY_ERROR   0x0020
#define MODE_ANCILLIARY_DISCARD 0x0030
#define MODE_CRITICAL_IGNORE    0x0000
#define MODE_CRITICAL_WARNING   0x0040
#define MODE_CRITICAL_ERROR     0x0080
#define MODE_DEFAULT            0x0091

Extract the various values like so;
   bIsCRCPresent = iMode & MODE_CRC_PRESENT
   iAncillaryMode = iMode & MODE_ANCILLIARY
   iCriticalMode = iMode & MODE_CRITICAL
(the modes are then tested for equality, not further 
bitwise-anded)

If bIsCRCPresent is false, iAncillaryMode is treated as if it were 
MODE_ANCILLARY_IGNORE, and iCriticalMode is treated as if it were 
MODE_CRITICAL_IGNORE (ie. all chunks are used); additionally the 
CRC is never read from the stream.  If it's true, then the CRC is 
read from the stream, even if the other flags are set to ignore 
it.

The _IGNORE style means "don't check the CRC"; ie. you don't care 
whether it's good or bad, you just want to use the chunk 
anyway.  Maybe rename this one to _USE if you think it makes more 
sense that way.

The _WARNING style means "warn if the CRC is bad".  The _ERROR 
style means "show an error if the CRC is bad".  The _DISCARD style 
means "discard the chunk if the CRC is bad".  All three styles 
check the CRC.  Note that _DISCARD is not valid for critical 
chunks, as per the spec.

I think this still covers all (sensible) possibilities, while 
keeping the bitcount down :)

-- 
Gavin Lambert, Mirality Systems
<http://www.mirality.co.nz/>
----
I'm not tense, just terribly, terribly alert.


--
Send the message body "help" to [email protected]