/* Exercise an RS codec a specified number of times using random * data and error patterns * * Copyright 2002 Phil Karn, KA9Q * May be used under the terms of the GNU General Public License (GPL) */ #define FLAG_ERASURE 1 /* Randomly flag 50% of errors as erasures */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #ifdef FIXED #include "fixed.h" #define EXERCISE exercise_8 #elif defined(CCSDS) #include "fixed.h" #include "ccsds.h" #define EXERCISE exercise_ccsds #elif defined(BIGSYM) #include "int.h" #define EXERCISE exercise_int #else #include "char.h" #define EXERCISE exercise_char #endif #ifdef FIXED #define PRINTPARM printf("(255,223):"); #elif defined(CCSDS) #define PRINTPARM printf("CCSDS (255,223):"); #else #define PRINTPARM printf("(%d,%d):",rs->nn,rs->nn-rs->nroots); #endif /* Exercise the RS codec passed as an argument */ int EXERCISE( #if !defined(CCSDS) && !defined(FIXED) void *p, #endif int trials){ #if !defined(CCSDS) && !defined(FIXED) struct rs *rs = (struct rs *)p; #endif DTYPE block[NN],tblock[NN]; int i; int errors; int errlocs[NN]; int derrlocs[NROOTS]; int derrors; int errval,errloc; int erasures; int decoder_errors = 0; while(trials-- != 0){ /* Test up to the error correction capacity of the code */ for(errors=0;errors <= NROOTS/2;errors++){ /* Load block with random data and encode */ for(i=0;i