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

📄 rstest.c

📁 reed-solomon 编解码
💻 C
字号:
/* Test the Reed-Solomon codecs * for various block sizes and with random data and random error patterns * * Copyright 2002 Phil Karn, KA9Q * May be used under the terms of the GNU General Public License (GPL) */#include <stdio.h>#include <stdlib.h>#include <time.h>#include "rs.h"int exercise_char(void *,int);int exercise_int(void *,int);int exercise_8(int);int exercise_ccsds(int);struct {  int symsize;  int genpoly;  int fcs;  int prim;  int nroots;  int ntrials;} Tab[] = {  {2, 0x7,     1,   1, 1, 10 },  {3, 0xb,     1,   1, 2, 10 },  {4, 0x13,    1,   1, 4, 10 },  {5, 0x25,    1,   1, 6, 10 },  {6, 0x43,    1,   1, 8, 10 },  {7, 0x89,    1,   1, 10, 10 },  {8, 0x11d,   1,   1, 32, 10 },  {8, 0x187,   112,11, 32, 10 }, /* Duplicates CCSDS codec */  {9, 0x211,   1,   1, 32, 10 },  {10,0x409,   1,   1, 32, 10 },  {11,0x805,   1,   1, 32, 10 },  {12,0x1053,  1,   1, 32, 5 },  {13,0x201b,  1,   1, 32, 2 },  {14,0x4443,  1,   1, 32, 1 },  {15,0x8003,  1,   1, 32, 1 },  {16,0x1100b, 1,   1, 32, 1 },  {0, 0, 0, 0, 0},};int main(){  void *handle;  int errs,terrs;  int i;  terrs = 0;  srandom(time(NULL));  printf("Testing fixed (255,223) RS codec...");  fflush(stdout);  errs = exercise_8(10);  terrs += errs;  if(errs == 0){    printf("OK\n");  }  printf("Testing CCSDS standard (255,223) RS codec...");  fflush(stdout);  errs = exercise_ccsds(10);  terrs += errs;  if(errs == 0){    printf("OK\n");  }  for(i=0;Tab[i].symsize != 0;i++){    int nn,kk;    nn = (1<<Tab[i].symsize) - 1;    kk = nn - Tab[i].nroots;    printf("Testing (%d,%d) RS codec...",nn,kk);    fflush(stdout);    if(Tab[i].symsize <= 8){      if((handle = init_rs_char(Tab[i].symsize,Tab[i].genpoly,Tab[i].fcs,Tab[i].prim,Tab[i].nroots)) == NULL){	printf("init_rs_char failed!\n");	continue;      }      errs = exercise_char(handle,Tab[i].ntrials);    } else {      if((handle = init_rs_int(Tab[i].symsize,Tab[i].genpoly,Tab[i].fcs,Tab[i].prim,Tab[i].nroots)) == NULL){	printf("init_rs_int failed!\n");	continue;      }      errs = exercise_int(handle,Tab[i].ntrials);    }    terrs += errs;    if(errs == 0){      printf("OK\n");    }    free_rs_char(handle);  }  if(terrs == 0)    printf("All codec tests passed!\n");  exit(0);}

⌨️ 快捷键说明

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