Search
lxdream.org :: lxdream/src/gdrom/ecc.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/ecc.h
changeset 644:ccae4bfa5f82
author nkeynes
date Sat Jun 14 11:54:15 2008 +0000 (15 years ago)
permissions -rw-r--r--
last change Change colour params to float
Convert background processing over to scene structure (fixes some depth issues as well)
Add color unclamp when supported
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/gdrom/ecc.h Sat Jun 14 11:54:15 2008 +0000
1.3 @@ -0,0 +1,136 @@
1.4 +/*
1.5 + * This file has been modified for the cdrkit suite.
1.6 + *
1.7 + * The behaviour and appearence of the program code below can differ to a major
1.8 + * extent from the version distributed by the original author(s).
1.9 + *
1.10 + * For details, see Changelog file distributed with the cdrkit package. If you
1.11 + * received this file from another source then ask the distributing person for
1.12 + * a log of modifications.
1.13 + *
1.14 + */
1.15 +
1.16 +/* @(#)ecc.h 1.4 02/10/19 Copyright 1998-2002 Heiko Eissfeldt, Joerg Schilling */
1.17 +
1.18 +/*
1.19 + * compact disc reed-solomon routines
1.20 + *
1.21 + * (c) 1998-2002 by Heiko Eissfeldt, heiko@colossus.escape.de
1.22 + * (c) 2002 by Joerg Schilling
1.23 + */
1.24 +/*
1.25 + * This program is free software; you can redistribute it and/or modify
1.26 + * it under the terms of the GNU General Public License version 2
1.27 + * as published by the Free Software Foundation.
1.28 + *
1.29 + * This program is distributed in the hope that it will be useful,
1.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.32 + * GNU General Public License for more details.
1.33 + *
1.34 + * You should have received a copy of the GNU General Public License along with
1.35 + * this program; see the file COPYING. If not, write to the Free Software
1.36 + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1.37 + */
1.38 +
1.39 +#define RS_L12_BITS 8
1.40 +
1.41 +/* audio sector definitions for CIRC */
1.42 +#define FRAMES_PER_SECTOR 98
1.43 +/* user data bytes per frame */
1.44 +#define L1_RAW 24
1.45 +/* parity bytes with 8 bit */
1.46 +#define L1_Q 4
1.47 +#define L1_P 4
1.48 +
1.49 +int cd_build_address(unsigned char inout[], int sectortype, unsigned address);
1.50 +
1.51 +/* audio sector Cross Interleaved Reed-Solomon Code (CIRC) encoder (layer 1) */
1.52 +/* adds P- and Q- parity information to audio (f2) frames. Also
1.53 + optionally handles the various delays and permutations. The output with all
1.54 + stages enabled can be fed into the Eight-Fourteen-Modulator.
1.55 + On input: 2352 bytes of audio data is given.
1.56 + On output: 3136 bytes of CIRC enriched audio data are returned.
1.57 + */
1.58 +int do_encode_L1(unsigned char in[L1_RAW*FRAMES_PER_SECTOR],
1.59 + unsigned char out[(L1_RAW+L1_Q+L1_P)*FRAMES_PER_SECTOR],
1.60 + int delay1, int delay2, int delay3, int scramble);
1.61 +
1.62 +/* data sector definitions for RSPC */
1.63 +/* user data bytes per frame */
1.64 +#define L2_RAW (1024*2)
1.65 +/* parity bytes for 16 bit units */
1.66 +#define L2_Q (26*2*2)
1.67 +#define L2_P (43*2*2)
1.68 +
1.69 +/* known sector types */
1.70 +#define MODE_0 GDROM_MODE0
1.71 +#define MODE_1 GDROM_MODE1
1.72 +#define MODE_2 GDROM_MODE2_FORMLESS
1.73 +#define MODE_2_FORM_1 GDROM_MODE2_FORM1
1.74 +#define MODE_2_FORM_2 GDROM_MODE2_FORM2
1.75 +
1.76 +/* set one of the MODE_* constants for subsequent data sector formatting */
1.77 +int set_sector_type(int st);
1.78 +/* get the current sector type setting for data sector formatting */
1.79 +int get_sector_type(void);
1.80 +
1.81 +/* data sector layer 2 Reed-Solomon Product Code encoder */
1.82 +/* encode the given data portion depending on sector type (see
1.83 + get/set_sector_type() functions). Use the given address for the header.
1.84 + The returned data is __unscrambled__ and not in F2-frame format (for that
1.85 + see function scramble_L2()).
1.86 + Supported sector types:
1.87 + MODE_0: a 12-byte sync field, a header and 2336 zeros are returned.
1.88 + MODE_1: the user data portion (2048 bytes) has to be given
1.89 + at offset 16 in the inout array.
1.90 + Sync-, header-, edc-, spare-, p- and q- fields will be added.
1.91 + MODE_2: the user data portion (2336 bytes) has to be given
1.92 + at offset 16 in the inout array.
1.93 + Sync- and header- fields will be added.
1.94 + MODE_2_FORM_1: the user data portion (8 bytes subheader followed
1.95 + by 2048 bytes data) has to be given at offset 16
1.96 + in the inout array.
1.97 + Sync-, header-, edc-, p- and q- fields will be added.
1.98 + MODE_2_FORM_2: the user data portion (8 bytes subheader followed
1.99 + by 2324 bytes data) has to be given at offset 16
1.100 + in the inout array.
1.101 + Sync-, header- and edc- fields will be added.
1.102 +*/
1.103 +int do_encode_L2(unsigned char *inout, int sectortype, unsigned address);
1.104 +int decode_L2_Q(unsigned char inout[4 + L2_RAW + 12 + L2_Q]);
1.105 +int decode_L2_P(unsigned char inout[4 + L2_RAW + 12 + L2_Q + L2_P]);
1.106 +unsigned int build_edc(unsigned char inout[], int from, int upto);
1.107 +
1.108 +/* generates f2 frames from otherwise fully formatted sectors (generated by
1.109 + do_encode_L2()). */
1.110 +#define EDC_SCRAMBLE_NOSWAP 1 /* Do not swap bytes while scrambling */
1.111 +int scramble_L2(unsigned char *inout);
1.112 +
1.113 +/* r-w sub channel definitions */
1.114 +#define RS_SUB_RW_BITS 6
1.115 +
1.116 +#define PACKETS_PER_SUBCHANNELFRAME 4
1.117 +#define LSUB_RAW 18
1.118 +#define LSUB_QRAW 2
1.119 +/* 6 bit */
1.120 +#define LSUB_Q 2
1.121 +#define LSUB_P 4
1.122 +
1.123 +/* R-W subchannel encoder */
1.124 +/* On input: 72 bytes packed user data, four frames with each 18 bytes.
1.125 + On output: per frame: 2 bytes user data, 2 bytes Q parity,
1.126 + 16 bytes user data, 4 bytes P parity.
1.127 + Options:
1.128 + delay1: use low level delay line
1.129 + scramble: perform low level permutations
1.130 + */
1.131 +int do_encode_sub(unsigned char in[LSUB_RAW*PACKETS_PER_SUBCHANNELFRAME],
1.132 + unsigned char out[(LSUB_RAW+LSUB_Q+LSUB_P)*PACKETS_PER_SUBCHANNELFRAME],
1.133 + int delay1, int scramble);
1.134 +int do_decode_sub(unsigned char in[(LSUB_RAW+LSUB_Q+LSUB_P)*PACKETS_PER_SUBCHANNELFRAME],
1.135 + unsigned char out[LSUB_RAW*PACKETS_PER_SUBCHANNELFRAME],
1.136 + int delay1, int scramble);
1.137 +
1.138 +int decode_LSUB_Q(unsigned char inout[LSUB_QRAW + LSUB_Q]);
1.139 +int decode_LSUB_P(unsigned char inout[LSUB_RAW + LSUB_Q + LSUB_P]);
.