Exemplo n.º 1
0
void rs_decode(uint8_t rs[2][RS_BLOCK_SIZE], uint8_t data[DATA_SIZE], int8_t error[2]) {
  uint16_t i;

  error[0] = decode_rs_8(rs[0], NULL, 0);
  error[1] = decode_rs_8(rs[1], NULL, 0);

  for (i = 0; i < DATA_SIZE; ++i) {
    data[i] = rs[i & 1][i >> 1];
  }

}
Exemplo n.º 2
0
int decode_rs_ccsds(unsigned char *data,int *eras_pos,int no_eras){
  int i,r;
  unsigned char cdata[NN];

  /* Convert data from dual basis to conventional */
  for(i=0;i<NN;i++)
    cdata[i] = Tal1tab[data[i]];

  r = decode_rs_8(cdata,eras_pos,no_eras);

  if(r > 0){
    /* Convert from conventional to dual basis */
    for(i=0;i<NN;i++)
      data[i] = Taltab[cdata[i]];
  }
  return r;
}
int main(){
  unsigned char block[255];
  int i;
  void *rs;
  struct rusage start,finish;
  double extime;
  int trials = 10000;

  for(i=0;i<223;i++)
    block[i] = 0x01;

  rs = init_rs_char(8,0x187,112,11,32,0);
  encode_rs_char(rs,block,&block[223]);

  getrusage(RUSAGE_SELF,&start);
  for(i=0;i<trials;i++){
#if 0
    block[0] ^= 0xff; /* Introduce an error */
    block[2] ^= 0xff; /* Introduce an error */
#endif
    decode_rs_char(rs,block,NULL,0);
  }
  getrusage(RUSAGE_SELF,&finish);
  extime = finish.ru_utime.tv_sec - start.ru_utime.tv_sec + 1e-6*(finish.ru_utime.tv_usec - start.ru_utime.tv_usec);
  
  printf("Execution time for %d Reed-Solomon blocks using general decoder: %.2f sec\n",trials,extime);
  printf("decoder speed: %g bits/s\n",trials*223*8/extime);


  encode_rs_8(block,&block[223],0);
  getrusage(RUSAGE_SELF,&start);
  for(i=0;i<trials;i++){
#if 0
    block[0] ^= 0xff; /* Introduce an error */
    block[2] ^= 0xff; /* Introduce an error */
#endif
    decode_rs_8(block,NULL,0,0);
  }
  getrusage(RUSAGE_SELF,&finish);
  extime = finish.ru_utime.tv_sec - start.ru_utime.tv_sec + 1e-6*(finish.ru_utime.tv_usec - start.ru_utime.tv_usec);
  printf("Execution time for %d Reed-Solomon blocks using CCSDS decoder: %.2f sec\n",trials,extime);
  printf("decoder speed: %g bits/s\n",trials*223*8/extime);

  exit(0);
}