⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rs-readme.txt

📁 一些纠错编码算法的源代码
💻 TXT
字号:
Reed-Solomon coding/decoding packagePhil Karn, KA9QVersion 1.0 September 1996Version 2.0 May 1999 -- CCSDS standard code support added, init_rs() deletedThis package implements general purpose Reed-Solomon encoding anddecoding for a wide range of code parameters. It is a rewrite of codeby Robert Morelos-Zaragoza (robert@spectra.eng.hawaii.edu) and HariThirumoorthy (harit@spectra.eng.hawaii.edu), which was in turn basedon an earlier program by Simon Rockliff (simon@augean.ua.oz.au). Thispackage would not exist without the excellent work of these earlierauthors.Version 2.0 adds support for the CCSDS standard (255,223) code.Simply define CCSDS in rs.h and all the appropriate parameters will beset. See http://ftp.ccsds.org/ccsds/documents/pdf/CCSDS-101.0-B-3.pdffor details on this standard code. Note that aside from specifying aparticular set of code parameters, the CCSDS standard uses a "dualbasis" symbol representation. Defining CCSDS automatically includesthe necessary conversions.The CCSDS code has the same error correcting performance as anon-CCSDS (255,223) RS code, but it executes a little more slowlybecause of the dual-basis conversions.  Correcting 16 errors in ablock with the CCSDS code takes about 580 microseconds on a 400 MHzPentium II, while the non-CCSDS equivalent takes about 500microseconds. Therefore, the CCSDS code is not recommended unless youneed to be compatible (or don't care about maximum speed).This package includes the following files:readme - this filers.h - include in user programs. Code params are defined here.rs.c - the initialization, encoder and decoder routinesrstest.c - test programmakefile - makefile for the test program and encoder/decoderAny good coding theory textbook will describe the error-correctingproperties of Reed-Solomon codes in far more detail than can beincluded here. Here is a brief summary of the properties of thestandard (nonextended) Reed-Solomon codes implemented in this package:MM - the code symbol size in bitsKK - the number of data symbols per block, KK < NNNN - the block size in symbols, which is always (2**MM - 1)The integer parameters MM and KK are specified by the user in rs.h(except when CCSDS is defined).  The code currently supports values ofMM ranging from 2 to 16, which is almost certainly a wider range thanis really useful.Note that Reed-Solomon codes are non-binary. Each RS "symbol" isactually a group of MM bits. Just one bit error anywhere in a givensymbol spoils the whole symbol. That's why RS codes are often called"burst-error-correcting" codes; if you're going to have bit errors,you'd like to concentrate them into as few RS symbols as possible.In the literature you will often see RS code parameters given in theform "(255,223) over GF(2**8)". The first number inside theparentheses is the block length NN, and the second number is KK.  Thenumber inside the GF() gives the size of each code symbol, writteneither in exponential form e.g., GF(2**8), or as an integer that is apower of 2, e.g., GF(256). Both indicate an 8-bit symbol.Note that many RS codes in use are "shortened", i.e., the block sizeis smaller than the symbol size would indicate.  Examples include the(32,28) and (28,24) RS codes over GF(256) in the Compact Disc and the(204,188) RS code used in digital video broadcasting.  This packagedoes not directly support shortened codes, but they can be implementedby simply padding the data array with zeros before encoding, omittingthem for transmission and then reinserting them locally beforedecoding. A future version of this code will probably support a moreefficient implementation of shortened RS codes.The error-correcting ability of a Reed-Solomon code depends on NN-KK,the number of parity symbols in the block. In the pure error-correcting mode (no erasures indicated by the calling function), thedecoder can correct up to (NN-KK)/2 symbol errors per block and nomore.The decoder can correct more than (NN-KK)/2 errors if the callingprogram can say where at least some of the errors are. These knownerror locations are called "erasures". (Note that knowing where theerrors are isn't enough by itself to correct them because the code isnon-binary -- we don't know *which* bits in the symbol are in error.)If all the error locations are known in advance, the decoder cancorrect as many as NN-KK errors, the number of parity symbols in thecode block. (Note that when this many erasures is specified, there isno redundancy left to detect additional uncorrectable errors so thedecoder may yield uncorrected errors.)In the most general case there are both errors and erasures.  Eacherror counts as two erasures, i.e., the number of erasures plus twicethe number of non-erased errors cannot exceed NN-KK. For example, a(255,223) RS code operating on 8-bit symbols can handle up to 16errors OR 32 erasures OR various combinations such as 8 errors and 16erasures.This version no longer requires the user to call init_rs() beforeencoding or decoding. That function is no longer exported.The two user-callable functions in rs.c are as follows:1. int encode_rs(dtype data[KK],dtype bb[NN-KK]);Encodes a block in the Reed-Solomon code.  The first argument containsthe KK symbols of user data to be encoded, and the second argumentcontains the array into which the encoder will place the NN-KK paritysymbols. The data argument is unchanged.  For user convenience, thedata and bb arrays may be part of a single contiguous array of NNelements, e.g., for a (255,223) code:	encode_rs(&data[0],&data[223]);The encode_rs() function returns 0 on success, -1 on error. (The onlypossible error is an illegal (i.e., too large) symbol in the user dataarray.Note that the typedef for the "dtype" type depends on the value of MMspecified in rs.h. For MM <= 8, dtype is equivalent to "unsignedchar"; for larger values, dtype is equivalent to "unsigned int".2. int eras_dec_rs(dtype data[NN], int eras_pos[NN-KK], int no_eras);Decodes a encoded block with errors and/or erasures. The firstargument contains the NN symbols of the received codeword, the firstKK of which are the user data and the latter NN-KK are the paritysymbols.Caller-specified erasures, if any, are passed in the second argumentas an array of integers with the third argument giving the number ofentries. E.g., to specify that symbols 10 and 20 (counting from 0) areto be treated as erasures the caller would say	eras_pos[0] = 10;	eras_pos[1] = 20;	eras_dec_rs(data,eras_pos,2);	The return value from eras_dec_rs() will give the number of errors(including erasures) corrected by the decoder. If the codeword couldnot be corrected due to excessive errors, -1 will be returned. Thedecoder will also return -1 if the data array contains an illegalsymbol, i.e., one exceeding the defined symbol size.The test program in rstest.c is called as follows:rstest [-e errors/block] [-E erasures/block ] [-n trials] [-v] [-t]You should be able to specify values for -e and -E such that thenumber of erasures plus twice the number of errors is equal to or lessthan NN-KK (the number of parity symbols in the block) and the decodershould succeed. If you exceed that number, the decoder will fail (tryit!) For incredible verbosity, specify -v.  For CPU timing tests,specify the -t test; this will cause the same block of encoded data tobe repeatedly decoded instead of generating a new random block anderror pattern each time (so you can exclude the time spent in therandom number generator from your measurements).Copyright 1999, Phil Karn, KA9QMay be used under the terms of the GNU Public License

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -