From d10839ab23b4ac4dea5ba183c451b650dd07331a Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 9 Feb 2018 10:06:34 +0100 Subject: Move external code to lib and stop using SUBDIRS --- src/fec/init_rs.h | 106 ------------------------------------------------------ 1 file changed, 106 deletions(-) delete mode 100644 src/fec/init_rs.h (limited to 'src/fec/init_rs.h') diff --git a/src/fec/init_rs.h b/src/fec/init_rs.h deleted file mode 100644 index 2b2ae98..0000000 --- a/src/fec/init_rs.h +++ /dev/null @@ -1,106 +0,0 @@ -/* Common code for intializing a Reed-Solomon control block (char or int symbols) - * Copyright 2004 Phil Karn, KA9Q - * May be used under the terms of the GNU Lesser General Public License (LGPL) - */ -#undef NULL -#define NULL ((void *)0) - -{ - int i, j, sr,root,iprim; - - rs = NULL; - /* Check parameter ranges */ - if(symsize < 0 || symsize > 8*sizeof(data_t)){ - goto done; - } - - if(fcr < 0 || fcr >= (1<= (1<= (1<= ((1<mm = symsize; - rs->nn = (1<pad = pad; - - rs->alpha_to = (data_t *)malloc(sizeof(data_t)*(rs->nn+1)); - if(rs->alpha_to == NULL){ - free(rs); - rs = NULL; - goto done; - } - rs->index_of = (data_t *)malloc(sizeof(data_t)*(rs->nn+1)); - if(rs->index_of == NULL){ - free(rs->alpha_to); - free(rs); - rs = NULL; - goto done; - } - - /* Generate Galois field lookup tables */ - rs->index_of[0] = A0; /* log(zero) = -inf */ - rs->alpha_to[A0] = 0; /* alpha**-inf = 0 */ - sr = 1; - for(i=0;inn;i++){ - rs->index_of[sr] = i; - rs->alpha_to[i] = sr; - sr <<= 1; - if(sr & (1<nn; - } - if(sr != 1){ - /* field generator polynomial is not primitive! */ - free(rs->alpha_to); - free(rs->index_of); - free(rs); - rs = NULL; - goto done; - } - - /* Form RS code generator polynomial from its roots */ - rs->genpoly = (data_t *)malloc(sizeof(data_t)*(nroots+1)); - if(rs->genpoly == NULL){ - free(rs->alpha_to); - free(rs->index_of); - free(rs); - rs = NULL; - goto done; - } - rs->fcr = fcr; - rs->prim = prim; - rs->nroots = nroots; - - /* Find prim-th root of 1, used in decoding */ - for(iprim=1;(iprim % prim) != 0;iprim += rs->nn) - ; - rs->iprim = iprim / prim; - - rs->genpoly[0] = 1; - for (i = 0,root=fcr*prim; i < nroots; i++,root += prim) { - rs->genpoly[i+1] = 1; - - /* Multiply rs->genpoly[] by @**(root + x) */ - for (j = i; j > 0; j--){ - if (rs->genpoly[j] != 0) - rs->genpoly[j] = rs->genpoly[j-1] ^ rs->alpha_to[modnn(rs,rs->index_of[rs->genpoly[j]] + root)]; - else - rs->genpoly[j] = rs->genpoly[j-1]; - } - /* rs->genpoly[0] can never be zero */ - rs->genpoly[0] = rs->alpha_to[modnn(rs,rs->index_of[rs->genpoly[0]] + root)]; - } - /* convert rs->genpoly[] to index form for quicker encoding */ - for (i = 0; i <= nroots; i++) - rs->genpoly[i] = rs->index_of[rs->genpoly[i]]; - done:; - -} -- cgit v1.2.3