This describes the program as shipped with cdrkit, a spinoff from the cdrtools project. However, the cdrtools developers are no longer involved in the development of this spinoff and therefore shall not be made responsible for any problem caused by it. Do not try to get support for this program by contacting the original authors. This is a small description for the Reed-Solomon library intended for CD sector formatting. Basics: It is assumed that you have a basic knowledge of cd sector formats. The library can handle three types of sector data: data sectors, audio sectors, and sub channel r-w sectors Currently only encoding is implemented. Decoding and optionally error correction is planned for later. Stages: The process of sector formatting has several stages. Beginning with a data sector (2048, 2324, or 2336 bytes) a sector of 2352 bytes is built. This format can be read raw by SCSI MMC-2 and ATAPI drives and is accepted by cd burners. The additions are an optionally 32 bit CRC checksum and two layers of Reed-Solomon codes (called Reed-Solomon Product Code RSPC). This sector is then scrambled (exor'ed with a bitstream). The result is called F1 frames. Afterwards even and odd bytes are swapped, this is called F2 frames. The result is equivalent to an audio sector and is treated as such by the cd burner. So, if we wrote a series of sectors (F2 frames) into a CDR file and later burned them as 'audio', they would turn up as perfect data sectors. So, now we are at the level of audio sectors. Audio sectors get their own error correction data (called CIRC). Sector size goes up to 3136 bytes (that is 4/3 times 2352 bytes). Furthermore different words get delayed differently and swap positions. The result is ready to be fed into the so-called EightFourteenModulator (when subchannels have been added). Now, only sub channels are missing. While the p and q sub channels have to be generated elsewhere, any supplied r-w subchannel user data is protected by two levels of error correction codes. This format is read by cd burners when burning cd+graphics. The cdimage is a sequence of sectors, each containing audio data and after that subchannel data. Similar to audio sectors delaying and permutation of words takes place. After that the cd burner would mix sub channel data with the formatted audio sectors to feed the EFModulator. NOTE: Most of the described stages need not to be done in order to prepare sectors for burning, since all cd burners do at least CIRC, delaying and swaps. For data sectors they also do scrambling and f2 frame generation. Encoding routines: For data sectors int do_encode_L2(unsigned char *inout, int sectortype, unsigned address); encodes data sectors. The returned data is __unscrambled__ and not in F2-frame format. Parameters are: inout pointer to an array of at least 2352 bytes. sectortype One of the MODE_* constants from ecc.h. This defines how to format the sector. address The logical address to be used in the header (150 = 0:2.0 MSF). NOTE: the data portion has be to aligned properly for performance reasons (see ecc.h for details). So, no moves are necessary here. Generating f2 frames to be used like audio sectors int scramble_L2(unsigned char *inout) generates f2 frames in place from sectors generated by do_encode_L2(). Parameters are: inout pointer to an array of at least 2352 bytes. For sub channels int do_encode_sub(unsigned char in[LSUB_RAW*PACKETS_PER_SUBCHANNELFRAME], unsigned char out[(LSUB_RAW+LSUB_Q+LSUB_P)* PACKETS_PER_SUBCHANNELFRAME], int delay1, int permute); repack user data and add error correction data. P and q subchannels should be added later, since all bytes are in place then. Parameters are: in pointer to an array of at least 72 bytes. It contains the user data for one frame. out pointer to an array of at least 96 bytes. Here is output frame is placed. delay1 do low level delaying, when set to 1. permute do low level permutations, when set to 1. NOTE: Probably both options need either to be set on (1) or off (0) together. There is more, but that is seldomly used. Tests: The library is accompanied by small verify programs, that compare real raw sectors with the formatted results. They are also intended as demo applications (how to use the library). In order to be able to feed real raw sectors into them, the package read2448 is recommended/needed. You can only verify sector streams of one sector type, currently no mix. For more information have a look into ecc.h recommended Documents: Yellow Book or ISO 10149 Appendix Red Book Red Book or IEC 908 Source: libedc/README from cdrtools package Edited for cdrkit by Christian Fromme