filename | src/gdrom/README.LIBEDC |
changeset | 644:ccae4bfa5f82 |
author | nkeynes |
date | Tue Jul 29 06:35:28 2008 +0000 (15 years ago) |
permissions | -rw-r--r-- |
last change | Workaround OS X's inability to handle CD reads of unknown size (ie where the read request failed to specify an expected sector type) - read raw sectors and parse it out by hand. |
file | annotate | diff | log | raw |
nkeynes@644 | 1 | This describes the program as shipped with cdrkit, a spinoff from the |
nkeynes@644 | 2 | cdrtools project. However, the cdrtools developers are no longer |
nkeynes@644 | 3 | involved in the development of this spinoff and therefore shall not |
nkeynes@644 | 4 | be made responsible for any problem caused by it. Do not try to get |
nkeynes@644 | 5 | support for this program by contacting the original authors. |
nkeynes@644 | 6 | |
nkeynes@644 | 7 | This is a small description for the Reed-Solomon library intended for |
nkeynes@644 | 8 | CD sector formatting. |
nkeynes@644 | 9 | |
nkeynes@644 | 10 | Basics: |
nkeynes@644 | 11 | It is assumed that you have a basic knowledge of cd sector formats. |
nkeynes@644 | 12 | |
nkeynes@644 | 13 | The library can handle three types of sector data: |
nkeynes@644 | 14 | data sectors, |
nkeynes@644 | 15 | audio sectors, and |
nkeynes@644 | 16 | sub channel r-w sectors |
nkeynes@644 | 17 | |
nkeynes@644 | 18 | Currently only encoding is implemented. Decoding and optionally |
nkeynes@644 | 19 | error correction is planned for later. |
nkeynes@644 | 20 | |
nkeynes@644 | 21 | Stages: |
nkeynes@644 | 22 | |
nkeynes@644 | 23 | The process of sector formatting has several stages. Beginning with |
nkeynes@644 | 24 | a data sector (2048, 2324, or 2336 bytes) a sector of 2352 bytes is |
nkeynes@644 | 25 | built. This format can be read raw by SCSI MMC-2 and ATAPI drives and |
nkeynes@644 | 26 | is accepted by cd burners. The additions are an optionally 32 bit CRC |
nkeynes@644 | 27 | checksum and two layers of Reed-Solomon codes (called Reed-Solomon |
nkeynes@644 | 28 | Product Code RSPC). |
nkeynes@644 | 29 | This sector is then scrambled (exor'ed with a bitstream). |
nkeynes@644 | 30 | The result is called F1 frames. Afterwards even and odd bytes are |
nkeynes@644 | 31 | swapped, this is called F2 frames. The result is equivalent to an |
nkeynes@644 | 32 | audio sector and is treated as such by the cd burner. |
nkeynes@644 | 33 | So, if we wrote a series of sectors (F2 frames) into a CDR file and |
nkeynes@644 | 34 | later burned them as 'audio', they would turn up as perfect data sectors. |
nkeynes@644 | 35 | |
nkeynes@644 | 36 | So, now we are at the level of audio sectors. Audio sectors get their |
nkeynes@644 | 37 | own error correction data (called CIRC). Sector size goes up to |
nkeynes@644 | 38 | 3136 bytes (that is 4/3 times 2352 bytes). Furthermore different |
nkeynes@644 | 39 | words get delayed differently and swap positions. The result is ready |
nkeynes@644 | 40 | to be fed into the so-called EightFourteenModulator (when subchannels |
nkeynes@644 | 41 | have been added). |
nkeynes@644 | 42 | |
nkeynes@644 | 43 | Now, only sub channels are missing. While the p and q sub |
nkeynes@644 | 44 | channels have to be generated elsewhere, any supplied r-w subchannel |
nkeynes@644 | 45 | user data is protected by two levels of error correction |
nkeynes@644 | 46 | codes. This format is read by cd burners when burning cd+graphics. |
nkeynes@644 | 47 | The cdimage is a sequence of sectors, each containing audio data and |
nkeynes@644 | 48 | after that subchannel data. |
nkeynes@644 | 49 | Similar to audio sectors delaying and permutation of words |
nkeynes@644 | 50 | takes place. After that the cd burner would mix sub channel data with |
nkeynes@644 | 51 | the formatted audio sectors to feed the EFModulator. |
nkeynes@644 | 52 | |
nkeynes@644 | 53 | NOTE: Most of the described stages need not to be done in order to |
nkeynes@644 | 54 | prepare sectors for burning, since all cd burners do at least CIRC, |
nkeynes@644 | 55 | delaying and swaps. For data sectors they also do scrambling and f2 |
nkeynes@644 | 56 | frame generation. |
nkeynes@644 | 57 | |
nkeynes@644 | 58 | Encoding routines: |
nkeynes@644 | 59 | |
nkeynes@644 | 60 | For data sectors |
nkeynes@644 | 61 | int do_encode_L2(unsigned char *inout, int sectortype, unsigned address); |
nkeynes@644 | 62 | |
nkeynes@644 | 63 | encodes data sectors. The returned data is __unscrambled__ and not in |
nkeynes@644 | 64 | F2-frame format. |
nkeynes@644 | 65 | |
nkeynes@644 | 66 | Parameters are: |
nkeynes@644 | 67 | inout pointer to an array of at least 2352 bytes. |
nkeynes@644 | 68 | sectortype One of the MODE_* constants from ecc.h. This defines |
nkeynes@644 | 69 | how to format the sector. |
nkeynes@644 | 70 | address The logical address to be used in the header |
nkeynes@644 | 71 | (150 = 0:2.0 MSF). |
nkeynes@644 | 72 | |
nkeynes@644 | 73 | NOTE: the data portion has be to aligned properly for performance |
nkeynes@644 | 74 | reasons (see ecc.h for details). So, no moves are necessary here. |
nkeynes@644 | 75 | |
nkeynes@644 | 76 | Generating f2 frames to be used like audio sectors |
nkeynes@644 | 77 | int scramble_L2(unsigned char *inout) |
nkeynes@644 | 78 | |
nkeynes@644 | 79 | generates f2 frames in place from sectors generated by do_encode_L2(). |
nkeynes@644 | 80 | |
nkeynes@644 | 81 | Parameters are: |
nkeynes@644 | 82 | inout pointer to an array of at least 2352 bytes. |
nkeynes@644 | 83 | |
nkeynes@644 | 84 | |
nkeynes@644 | 85 | |
nkeynes@644 | 86 | For sub channels |
nkeynes@644 | 87 | int do_encode_sub(unsigned char in[LSUB_RAW*PACKETS_PER_SUBCHANNELFRAME], |
nkeynes@644 | 88 | unsigned char out[(LSUB_RAW+LSUB_Q+LSUB_P)* |
nkeynes@644 | 89 | PACKETS_PER_SUBCHANNELFRAME], |
nkeynes@644 | 90 | int delay1, int permute); |
nkeynes@644 | 91 | |
nkeynes@644 | 92 | repack user data and add error correction data. P and q subchannels |
nkeynes@644 | 93 | should be added later, since all bytes are in place then. |
nkeynes@644 | 94 | |
nkeynes@644 | 95 | Parameters are: |
nkeynes@644 | 96 | in pointer to an array of at least 72 bytes. It contains |
nkeynes@644 | 97 | the user data for one frame. |
nkeynes@644 | 98 | out pointer to an array of at least 96 bytes. Here is |
nkeynes@644 | 99 | output frame is placed. |
nkeynes@644 | 100 | delay1 do low level delaying, when set to 1. |
nkeynes@644 | 101 | permute do low level permutations, when set to 1. |
nkeynes@644 | 102 | |
nkeynes@644 | 103 | NOTE: Probably both options need either to be set on (1) or off (0) together. |
nkeynes@644 | 104 | |
nkeynes@644 | 105 | There is more, but that is seldomly used. |
nkeynes@644 | 106 | |
nkeynes@644 | 107 | Tests: |
nkeynes@644 | 108 | The library is accompanied by small verify programs, that compare real |
nkeynes@644 | 109 | raw sectors with the formatted results. They are also intended as demo |
nkeynes@644 | 110 | applications (how to use the library). In order to be able to feed |
nkeynes@644 | 111 | real raw sectors into them, the package read2448 is recommended/needed. |
nkeynes@644 | 112 | You can only verify sector streams of one sector type, currently no mix. |
nkeynes@644 | 113 | |
nkeynes@644 | 114 | For more information have a look into ecc.h |
nkeynes@644 | 115 | |
nkeynes@644 | 116 | recommended Documents: |
nkeynes@644 | 117 | Yellow Book or ISO 10149 |
nkeynes@644 | 118 | Appendix Red Book |
nkeynes@644 | 119 | Red Book or IEC 908 |
nkeynes@644 | 120 | |
nkeynes@644 | 121 | Source: libedc/README from cdrtools package |
nkeynes@644 | 122 | Edited for cdrkit by Christian Fromme <kaner@strace.org> |
nkeynes@644 | 123 |
.