Main Page | Class List | File List | Class Members | File Members

bch.h File Reference

Go to the source code of this file.

Enumerations

enum  bch_type {
  BCHNONE, BCH15_5, BCH15_7, BCH15_11,
  BCH31_6, BCH31_11, BCH63_7, BCH63_10,
  GOLAY23_12
}

Functions

void generate_gf ()
void gen_poly ()
void encode_bch (unsigned long bits, byte *block, bch_type type)
int decode_bch (unsigned long *bits, byte *block, bch_type type, int t0)
bch_type strtobch_type (char *str)
int code_length (bch_type b)
int info_length (bch_type b)
char * bch_type_str (bch_type type)


Enumeration Type Documentation

enum bch_type
 

Enumeration values:
BCHNONE 
BCH15_5 
BCH15_7 
BCH15_11 
BCH31_6 
BCH31_11 
BCH63_7 
BCH63_10 
GOLAY23_12 

Definition at line 6 of file bch.h.

Referenced by bch_init(), and strtobch_type().

00006 { BCHNONE, BCH15_5, BCH15_7, BCH15_11, BCH31_6, BCH31_11, BCH63_7, BCH63_10, GOLAY23_12,} bch_type;


Function Documentation

char* bch_type_str bch_type  type  ) 
 

Definition at line 682 of file bch.c.

References BCH15_11, BCH15_5, BCH15_7, BCH31_11, BCH31_6, BCH63_10, BCH63_7, and BCHNONE.

Referenced by decode_bch(), and encode_bch().

00683 {
00684   switch(type) {
00685   case BCHNONE:  return "None";
00686   case BCH15_5:  return "(15,5)";
00687   case BCH15_7:  return "(15,7)";
00688   case BCH15_11: return "(15,11)";
00689   case BCH31_6:  return "(31,6)";
00690   case BCH31_11: return "(31,11)";
00691   case BCH63_7:  return "(63,7)";
00692   case BCH63_10: return "(63,10)";
00693   }
00694 }

int code_length bch_type  b  ) 
 

Definition at line 697 of file bch.c.

References BCH15_11, BCH15_5, BCH15_7, BCH31_11, BCH31_6, BCH63_10, BCH63_7, BCHNONE, and GOLAY23_12.

Referenced by demultiplex(), and shift_in().

00698 {
00699   switch(b)
00700     {
00701     case BCHNONE:
00702       return 7;
00703     case BCH15_5: 
00704     case BCH15_7: 
00705     case BCH15_11:      
00706       return 15;
00707     case BCH31_6:
00708     case BCH31_11:
00709       return 31;
00710     case BCH63_7:
00711     case BCH63_10:
00712       return 63;
00713     case GOLAY23_12:
00714       return 23;
00715     }
00716   return 0;
00717 }

int decode_bch unsigned long *  bits,
byte block,
bch_type  type,
int  t0
 

Definition at line 580 of file bch.c.

References bch_init(), bch_type_str(), debug, error(), getbit(), length, m, mdecode_bch(), and recd.

Referenced by deconstruct_header(), and deconstruct_mpl().

00593 {
00594   int i, j;
00595   unsigned int r=0;
00596   int returnval=0;
00597 
00598 
00599   if ((correction!=0)&&(correction!=1))
00600     error("decode_bch","incorrect correction mode");
00601   
00602   /*
00603    * begin the decoding process 
00604    */
00605   if (debug >= 3) {
00606     printf("BCH: decode_bch() - bch_code = %s\n", bch_type_str(type));
00607   }
00608 
00609   if (type == BCHNONE) {
00610     *bits = block[0];
00611     return 1;
00612   }
00613 
00614   /* 
00615    * init codec if necessary
00616    */
00617   bch_init(type);
00618  
00619 
00620   /* 
00621    * copy input to decoder to recd[]
00622    */
00623   
00624   for (i=0;i<m-1;i++) 
00625     for (j=1;j<8;j++)
00626       recd[(8*i)+j-1] = getbit(block[i],j);
00627   
00628   /*
00629    * run the BCH decoding algorithm
00630    */
00631   returnval = mdecode_bch(correction);  
00632 
00633   /*
00634    * put output of bch coder into *bits;
00635    */
00636 
00637   j=1;
00638   r = 0;
00639   for (i=length-k;i<length;i++) {
00640     r += j*recd[i];
00641     j*=2;
00642   }
00643   *bits = r;
00644  
00645   if (debug >= 3) {
00646     printf("BCH: decode_bch() bits = %d\n", *bits);
00647   }
00648 
00649   return (returnval);
00650 }

void encode_bch unsigned long  bits,
byte block,
bch_type  type
 

Definition at line 529 of file bch.c.

References bb, bch_init(), bch_type_str(), data, debug, getbitint(), length, mencode_bch(), recd, and setbit().

Referenced by construct_mpl(), make_backward_control(), and make_forward_control().

00533 {
00534   int i,j;
00535 
00536   if (debug >= 3) {
00537     printf("BCH: encode_bch() type = %s\n",  bch_type_str(type));
00538   }
00539 
00540   if (type == BCHNONE) {
00541     block[0] = bits & 0xFF;
00542     return;
00543   }
00544 
00545   /* 
00546    * init codec if necessary
00547    */
00548   bch_init(type);
00549  
00550   /* 
00551    * put input into encoder.
00552    */
00553 
00554   for (i=0;i<k;i++) 
00555     data[i] = getbitint(bits,(16-i)); /* data stores the field in REVERSE */
00556 
00557   /*
00558    * Run the encoder.
00559    */
00560   mencode_bch();   
00561 
00562   /* 
00563    * Put the redundancy + data into recd[] 
00564    */
00565   for (i = 0; i < length - k; i++)
00566     recd[i] = bb[i];
00567   for (i = 0; i < k; i++)
00568     recd[i + length - k] = data[i];
00569   
00570   /*
00571    * recd[] now contains the code.  put this into Block and return 
00572    */
00573     for (i=0;i<=(length/8);i++)
00574       for(j=1;j<=8;j++)
00575         setbit(&(block[i]),j,recd[(8*i)+j-1]);
00576 
00577 }

void gen_poly  )  [static]
 

void generate_gf  )  [static]
 

int info_length bch_type  b  ) 
 

Definition at line 720 of file bch.c.

References BCH15_11, BCH15_5, BCH15_7, BCH31_11, BCH31_6, BCH63_10, BCH63_7, and BCHNONE.

00721 {
00722   switch(b)
00723     {
00724     case BCHNONE: return 8;
00725     case BCH15_5: return 5;
00726     case BCH15_7: return 7;
00727     case BCH15_11: return 11;
00728     case BCH31_6: return 6;
00729     case BCH31_11: return 11;
00730     case BCH63_7: return 7;
00731     case BCH63_10: return 10;
00732     }
00733   return 0;
00734 }

bch_type strtobch_type char *  str  ) 
 

Definition at line 655 of file bch.c.

References bch_type, and equals().

Referenced by mux_config().

00656 {
00657   int i;
00658   i=strlen(str)-1;
00659   while (i > 0 && (str[i]==' ' || str[i]=='\t'))
00660     str[i]=0;
00661 
00662   if (equals(str, "BCH15_5"))
00663     return BCH15_5;
00664   else if (equals(str, "BCH15_7"))
00665     return BCH15_7;
00666   else if (equals(str, "BCH15_11"))
00667     return BCH15_11;
00668   else if (equals(str, "BCH31_6"))
00669     return BCH31_6;
00670   else if (equals(str, "BCH31_11"))
00671     return BCH31_11;
00672   else if (equals(str, "BCH63_7"))
00673     return BCH63_7;
00674   else if (equals(str, "BCH63_10"))
00675     return BCH63_10;
00676   else if (equals(str, "GOLAY23_12"))
00677     return GOLAY23_12;
00678   else
00679     return BCHNONE;
00680 }


Generated on Sun Jul 16 16:27:45 2006 by  doxygen 1.3.9.1