#include <stdio.h>
Go to the source code of this file.
Defines | |
#define | X22 0x00400000 |
#define | X11 0x00000800 |
#define | MASK12 0xfffff800 |
#define | GENPOL 0x00000c75 |
Functions | |
long | arr2int (int *a, int r) |
void | nextcomb (int n, int r, int *a) |
long | get_syndrome (long pattern) |
void | gen_enc_table (void) |
void | gen_dec_table (void) |
long | encode_golay (long data) |
long | decode_golay (long codeword) |
Variables | |
long | pattern |
long | encoding_table [4096] |
long | decoding_table [2048] |
long | data |
long | codeword |
long | recd |
long | position [23] |
long | numerr |
long | errpos [23] |
long | decerror = 0 |
int | a [4] |
int | debug |
|
|
|
|
|
|
|
|
|
Definition at line 84 of file golay.c. References a. Referenced by gen_dec_table(). 00087 {i=1}^r 2^{a[i]-1}. 00088 */ 00089 { 00090 int i; 00091 long mul, result = 0, temp; 00092 00093 for (i=1; i<=r; i++) { 00094 mul = 1; 00095 temp = a[i]-1; 00096 while (temp--) 00097 mul = mul << 1; 00098 result += mul; 00099 } 00100 return(result); 00101 }
|
|
Definition at line 232 of file golay.c. References codeword, decoding_table, gen_dec_table(), and get_syndrome(). Referenced by deconstruct_header_level2(). 00233 { 00234 /* 00235 * decodes codeword and returns the dataword contained within. 00236 * 00237 * note: no detection is done here! 00238 * codeword is assumed to contain the 23 bits in the LSB positions 00239 * the returned bits contain the bits in the LSB positions 00240 * 00241 * MSB will be ignored, since this is 23,12 code. 00242 */ 00243 static int initialized=0; 00244 00245 if (!initialized) { 00246 gen_dec_table(); 00247 initialized=1; 00248 } 00249 00250 if (debug) { 00251 printf("decode_golay() - codeword = %#012x\n", codeword); 00252 printf("decode_golay() - syndrome = %#012x\n", get_syndrome(codeword)); 00253 } 00254 00255 /* 00256 * Calculate the syndrome, look up the corresponding error pattern and 00257 * add it to the received vector. 00258 */ 00259 codeword ^= decoding_table[get_syndrome(codeword)]; 00260 00261 if (debug) { 00262 printf("decoded vector = %#012x\n", codeword); 00263 printf("recovered data = %#012x\n", (codeword>>11)); 00264 } 00265 return codeword >> 11; 00266 }
|
|
Definition at line 213 of file golay.c. References codeword, encoding_table, and gen_enc_table(). Referenced by construct_header_level2(). 00214 { 00215 /* 00216 * encodes data and returns the codeword. 00217 * data is assumed to contain 12 bits in the least significant bit positions 00218 * codeword contains the 23 bits in the LSB positions 00219 * 00220 */ 00221 static int initialized=0; 00222 00223 if (!initialized) { 00224 gen_enc_table(); 00225 initialized=1; 00226 } 00227 codeword = encoding_table[data]; 00228 if (debug) printf("encode_golay() - codeword = %#012x\n", codeword); 00229 return codeword; 00230 }
|
|
Definition at line 164 of file golay.c. References a, arr2int(), decoding_table, get_syndrome(), and nextcomb(). Referenced by decode_golay(). 00165 { 00166 /* 00167 * --------------------------------------------------------------------- 00168 * Generate DECODING TABLE 00169 * 00170 * An entry to the decoding table is a syndrome and the resulting value 00171 * is the most likely error pattern. First an error pattern is generated. 00172 * Then its syndrome is calculated and used as a pointer to the table 00173 * where the error pattern value is stored. 00174 * --------------------------------------------------------------------- 00175 * 00176 * (1) Error patterns of WEIGHT 1 (SINGLE ERRORS) 00177 */ 00178 long temp; 00179 int i; 00180 00181 decoding_table[0] = 0; 00182 decoding_table[1] = 1; 00183 temp = 1; 00184 for (i=2; i<= 23; i++) { 00185 temp *= 2; 00186 decoding_table[get_syndrome(temp)] = temp; 00187 } 00188 /* 00189 * (2) Error patterns of WEIGHT 2 (DOUBLE ERRORS) 00190 */ 00191 a[1] = 1; a[2] = 2; 00192 temp = arr2int(a,2); 00193 decoding_table[get_syndrome(temp)] = temp; 00194 for (i=1; i<253; i++) { 00195 nextcomb(23,2,a); 00196 temp = arr2int(a,2); 00197 decoding_table[get_syndrome(temp)] = temp; 00198 } 00199 /* 00200 * (3) Error patterns of WEIGHT 3 (TRIPLE ERRORS) 00201 */ 00202 a[1] = 1; a[2] = 2; a[3] = 3; 00203 temp = arr2int(a,3); 00204 decoding_table[get_syndrome(temp)] = temp; 00205 for (i=1; i<1771; i++) { 00206 nextcomb(23,3,a); 00207 temp = arr2int(a,3); 00208 decoding_table[get_syndrome(temp)] = temp; 00209 } 00210 }
|
|
Definition at line 143 of file golay.c. References encoding_table, get_syndrome(), and pattern. Referenced by encode_golay(). 00144 { 00145 /* 00146 * --------------------------------------------------------------------- 00147 * Generate ENCODING TABLE 00148 * 00149 * An entry to the table is an information vector, a 32-bit integer, 00150 * whose 12 least significant positions are the information bits. The 00151 * resulting value is a codeword in the (23,12,7) Golay code: A 32-bit 00152 * integer whose 23 least significant bits are coded bits: Of these, the 00153 * 12 most significant bits are information bits and the 11 least 00154 * significant bits are redundant bits (systematic encoding). 00155 * --------------------------------------------------------------------- 00156 */ 00157 long temp; 00158 for (pattern = 0; pattern < 4096; pattern++) { 00159 temp = pattern << 11; /* multiply information by X^{11} */ 00160 encoding_table[pattern] = temp + get_syndrome(temp);/* add redundancy */ 00161 } 00162 }
|
|
Definition at line 121 of file golay.c. References pattern. Referenced by decode_golay(), gen_dec_table(), and gen_enc_table(). 00126 : (1) pattern = infomation 00127 * bits, when constructing the encoding table; (2) pattern = error pattern, 00128 * when constructing the decoding table; and (3) pattern = received vector, to 00129 * obtain its syndrome in decoding. 00130 */ 00131 { 00132 long aux = X22; 00133 00134 if (pattern >= X11) 00135 while (pattern & MASK12) { 00136 while (!(aux & pattern)) 00137 aux = aux >> 1; 00138 pattern ^= (aux/X11) * GENPOL; 00139 } 00140 return(pattern); 00141 }
|
|
Definition at line 103 of file golay.c. References a. Referenced by gen_dec_table(). 00107 { 00108 int i, j; 00109 00110 a[r]++; 00111 if (a[r] <= n) 00112 return; 00113 j = r - 1; 00114 while (a[j] == n - r + j) 00115 j--; 00116 for (i = r; i >= j; i--) 00117 a[i] = a[j] + i - j + 1; 00118 return; 00119 }
|
|
Definition at line 81 of file golay.c. Referenced by arr2int(), close_audio_codec(), code_audio(), correlation(), decode_audio(), gen_dec_table(), minus(), new_audio_codec(), nextcomb(), parse_line(), and ratio_difference(). |
|
Definition at line 73 of file golay.c. Referenced by decode_golay(), deconstruct_header_level2(), and encode_golay(). |
|
Definition at line 73 of file golay.c. Referenced by apply_errors(), bread(), bwrite(), Clip(), CodeOneIntra(), FillChromBlock(), FillLumBlock(), FindChromBlock_P(), fwdccitthware(), lremove(), place_rcpc(), ReconChromBlock_P(), ReconImage(), ReconLumBlock_P(), and ZeroMBlock(). |
|
|
|
|
|
Definition at line 72 of file golay.c. Referenced by decode_golay(), and gen_dec_table(). |
|
Definition at line 72 of file golay.c. Referenced by encode_golay(), and gen_enc_table(). |
|
|
|
|
|
Definition at line 71 of file golay.c. Referenced by add_to_mux_table(), gen_enc_table(), get_syndrome(), write_pattern(), and write_pattern1(). |
|
Initial value: { 0x00000001, 0x00000002, 0x00000004, 0x00000008, 0x00000010, 0x00000020, 0x00000040, 0x00000080, 0x00000100, 0x00000200, 0x00000400, 0x00000800, 0x00001000, 0x00002000, 0x00004000, 0x00008000, 0x00010000, 0x00020000, 0x00040000, 0x00080000, 0x00100000, 0x00200000, 0x00400000 } Definition at line 74 of file golay.c. Referenced by Code_sac_Coeff(). |
|
|