Search
lxdream.org :: lxdream/src/gdrom/ecc.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/ecc.h
changeset 644:ccae4bfa5f82
author nkeynes
date Thu May 29 11:00:26 2008 +0000 (15 years ago)
permissions -rw-r--r--
last change Split gdrom.h into public and private gddriver.h
Reorganize gdrom mount to use a disc change hook
view annotate diff log raw
     1 /*
     2  * This file has been modified for the cdrkit suite.
     3  *
     4  * The behaviour and appearence of the program code below can differ to a major
     5  * extent from the version distributed by the original author(s).
     6  *
     7  * For details, see Changelog file distributed with the cdrkit package. If you
     8  * received this file from another source then ask the distributing person for
     9  * a log of modifications.
    10  *
    11  */
    13 /* @(#)ecc.h	1.4 02/10/19 Copyright 1998-2002 Heiko Eissfeldt, Joerg Schilling */
    15 /*
    16  * compact disc reed-solomon routines
    17  *
    18  * (c) 1998-2002 by Heiko Eissfeldt, heiko@colossus.escape.de
    19  * (c) 2002 by Joerg Schilling
    20  */
    21 /*
    22  * This program is free software; you can redistribute it and/or modify
    23  * it under the terms of the GNU General Public License version 2
    24  * as published by the Free Software Foundation.
    25  *
    26  * This program is distributed in the hope that it will be useful,
    27  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    29  * GNU General Public License for more details.
    30  *
    31  * You should have received a copy of the GNU General Public License along with
    32  * this program; see the file COPYING.  If not, write to the Free Software
    33  * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    34  */
    36 #define RS_L12_BITS 8
    38 /* audio sector definitions for CIRC */
    39 #define FRAMES_PER_SECTOR 98
    40 /* user data bytes per frame */
    41 #define L1_RAW 24
    42 /* parity bytes with 8 bit */
    43 #define L1_Q   4
    44 #define L1_P   4
    46 int cd_build_address(unsigned char inout[], int sectortype, unsigned address);
    48 /* audio sector Cross Interleaved Reed-Solomon Code (CIRC) encoder (layer 1) */
    49 /* adds P- and Q- parity information to audio (f2) frames. Also
    50    optionally handles the various delays and permutations. The output with all
    51    stages enabled can be fed into the Eight-Fourteen-Modulator.
    52    On input: 2352 bytes of audio data is given.
    53    On output: 3136 bytes of CIRC enriched audio data are returned.
    54  */
    55 int do_encode_L1(unsigned char in[L1_RAW*FRAMES_PER_SECTOR],
    56 					  unsigned char out[(L1_RAW+L1_Q+L1_P)*FRAMES_PER_SECTOR],
    57 					  int delay1, int delay2, int delay3, int scramble);
    59 /* data sector definitions for RSPC */
    60 /* user data bytes per frame */
    61 #define L2_RAW (1024*2)
    62 /* parity bytes for 16 bit units */
    63 #define L2_Q   (26*2*2)
    64 #define L2_P   (43*2*2)
    66 /* known sector types */
    67 #define MODE_0	GDROM_MODE0
    68 #define MODE_1	GDROM_MODE1
    69 #define MODE_2	GDROM_MODE2_FORMLESS
    70 #define MODE_2_FORM_1	GDROM_MODE2_FORM1
    71 #define MODE_2_FORM_2	GDROM_MODE2_FORM2
    73 /* set one of the MODE_* constants for subsequent data sector formatting */
    74 int set_sector_type(int st);
    75 /* get the current sector type setting for data sector formatting */
    76 int get_sector_type(void);
    78 /* data sector layer 2 Reed-Solomon Product Code encoder */
    79 /* encode the given data portion depending on sector type (see
    80    get/set_sector_type() functions). Use the given address for the header.
    81    The returned data is __unscrambled__ and not in F2-frame format (for that
    82    see function scramble_L2()).
    83    Supported sector types:
    84      MODE_0: a 12-byte sync field, a header and 2336 zeros are returned.
    85      MODE_1: the user data portion (2048 bytes) has to be given
    86              at offset 16 in the inout array.
    87              Sync-, header-, edc-, spare-, p- and q- fields will be added.
    88      MODE_2: the user data portion (2336 bytes) has to be given
    89              at offset 16 in the inout array.
    90              Sync- and header- fields will be added.
    91      MODE_2_FORM_1: the user data portion (8 bytes subheader followed
    92                     by 2048 bytes data) has to be given at offset 16
    93                     in the inout array.
    94                     Sync-, header-, edc-, p- and q- fields will be added.
    95      MODE_2_FORM_2: the user data portion (8 bytes subheader followed
    96                     by 2324 bytes data) has to be given at offset 16
    97                     in the inout array.
    98                     Sync-, header- and edc- fields will be added.
    99 */
   100 int do_encode_L2(unsigned char *inout, int sectortype, unsigned address);
   101 int decode_L2_Q(unsigned char inout[4 + L2_RAW + 12 + L2_Q]);
   102 int decode_L2_P(unsigned char inout[4 + L2_RAW + 12 + L2_Q + L2_P]);
   103 unsigned int build_edc(unsigned char inout[], int from, int upto);
   105 /* generates f2 frames from otherwise fully formatted sectors (generated by
   106    do_encode_L2()). */
   107 #define	EDC_SCRAMBLE_NOSWAP	1	/* Do not swap bytes while scrambling */
   108 int scramble_L2(unsigned char *inout);
   110 /* r-w sub channel definitions */
   111 #define RS_SUB_RW_BITS 6
   113 #define PACKETS_PER_SUBCHANNELFRAME 4
   114 #define LSUB_RAW 18
   115 #define LSUB_QRAW 2
   116 /* 6 bit */
   117 #define LSUB_Q 2
   118 #define LSUB_P 4
   120 /* R-W subchannel encoder */
   121 /* On input: 72 bytes packed user data, four frames with each 18 bytes.
   122    On output: per frame: 2 bytes user data, 2 bytes Q parity, 
   123                          16 bytes user data, 4 bytes P parity.
   124    Options:
   125      delay1: use low level delay line
   126      scramble: perform low level permutations
   127  */
   128 int do_encode_sub(unsigned char in[LSUB_RAW*PACKETS_PER_SUBCHANNELFRAME],
   129 		unsigned char out[(LSUB_RAW+LSUB_Q+LSUB_P)*PACKETS_PER_SUBCHANNELFRAME],
   130 		int delay1, int scramble);
   131 int do_decode_sub(unsigned char in[(LSUB_RAW+LSUB_Q+LSUB_P)*PACKETS_PER_SUBCHANNELFRAME],
   132 						unsigned char out[LSUB_RAW*PACKETS_PER_SUBCHANNELFRAME],
   133 						int delay1, int scramble);
   135 int decode_LSUB_Q(unsigned char inout[LSUB_QRAW + LSUB_Q]);
   136 int decode_LSUB_P(unsigned char inout[LSUB_RAW + LSUB_Q + LSUB_P]);
.