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

📄 fecdec.c

📁 这个文件包括wimax中所有的编解码源代码
💻 C
字号:
/*****************************************************************************//*   FIle Name : fecdec.c                                                    *//*   Description : WiFi OFDM FEC Decoder                                     *//*   author : miffie                                                         *//*   Date   : Nov/23/05                                                      *//*   Copyright (c) 2005 miffie   All rights reserved.                        *//*****************************************************************************/struct binaryset fecdec(struct binaryset datain ,                               char fec_code_type,                              short *randomizer_seed ) {  register int ii , jj ;  char num_erasure ;  char RR ;  char unfixable ;  short  KK  , num_data , size  ;  struct  binaryset bset0, bset1, bset2 , bset3;  unsigned char     data[256] ;  char    Nsub = 16 ;  short   row, column, tmp1 ;  //   rs_cc           RS_K  RS_T  RATE Ncpc  char rs_cc[7][4] = {{   12,    0,   0,   1 },                      {   24,    4,   1,   2 },                      {   36,    2,   3,   2 },                      {   48,    8,   1,   4 },                      {   72,    4,   3,   4 },                      {   96,    6,   2,   6 },                      {  108,    6,   3,   6 } } ;  short btc_block[] =  {  24,  24,  48,  48,  72,  72 } ;  short ctc_block[] =  {  24,  24,  24,  48,  48,  72,  72 } ;  PRINTF("fecdec    fec_code_type=%d size=%d\n", fec_code_type , datain.size ) ;    //////////////////////////////////////////////////////////////////////////////    // Inner Code     //////////////////////////////////////////////////////////////////////////////    if  (fec_code_type<=6) {      //depuncturing      bset0 = depuncturing(datain , rs_cc[fec_code_type][2] ) ; //rate 2:3/4      bset1 = pad_binaryset(138) ;      bset0 = cat_binaryset(bset0 , bset1) ;      print_binaryset( bset0 ) ;      bset0 = viterbi_cc( bset0 ) ;          print_binaryset(bset0) ;      bset0 = binary2byte_MSB(bset0) ;      print_binaryset(bset0) ;    }    else if (fec_code_type<=12) { //BTC      ii= 0 ;      bset2.size= 0 ;      bset2.format= 1 ; //Byte      while (ii < datain.size ) { //while            printf("btc_block=%d\n",  (btc_block[fec_code_type-7]*Nsub) ) ;            bset1 = extract_binaryset( datain, ii, (btc_block[fec_code_type-7]*Nsub) ) ;             bset1 = turbo_decoder( bset1, fec_code_type, Nsub ) ;            bset2 = cat_binaryset( bset2, bset1 ) ;            ii += (btc_block[fec_code_type-7]*Nsub) ;      } //while    } //BTC    else if (fec_code_type<=19) { //CTC      ii= 0 ;      bset2.size= 0 ;      bset2.format= 1 ; //Byte      while (ii < datain.size ) { //while            printf("ctc_block=%d\n",  (ctc_block[fec_code_type-13]*Nsub) ) ;            bset1 = extract_binaryset( datain, ii, (ctc_block[fec_code_type-13]*Nsub) ) ;             bset1 = ctc_decoder( bset1, fec_code_type, Nsub ) ;            bset2 = cat_binaryset( bset2, bset1 ) ;            printf("cat_binaryset done\n") ;            ii += (ctc_block[fec_code_type-13]*Nsub) ;      } //while    } //CTC    //////////////////////////////////////////////////////////////////////////////    // Outer Code ( Reed-Solomon)    //////////////////////////////////////////////////////////////////////////////    if (fec_code_type==0) { //NO RS      bset2 = copy_binaryset( bset0 ) ;    } //NO RS    else if (fec_code_type<=6) { //RS      unfixable=0 ;      bset2.size= 0 ;      bset2.format= 0 ; //Binary      size=bset0.size ;        ii= 0 ;        while (ii < bset0.size ) { //while          if ( (bset0.size-ii) >= rs_cc[fec_code_type][0] + rs_cc[fec_code_type][1]*2 ) { //fixed size            bset1 = extract_binaryset( bset0, ii,                     rs_cc[fec_code_type][0] + rs_cc[fec_code_type][1]*2 ) ;            bset1 =  decode_rs(bset1, rs_cc[fec_code_type][1]*2) ;            if (bset1.size > rs_cc[fec_code_type][0] ) { //unfixable               unfixable = 1 ;              bset1.size -= rs_cc[fec_code_type][1]*2 ;            }  //unfixable            bset2 = cat_binaryset( bset2, bset1 ) ;          }           else if ((bset0.size-ii) >= 6 + rs_cc[fec_code_type][1]*2 ) {//lastword            bset1 = extract_binaryset( bset0, ii,                     bset0.size-ii ) ;            bset1 =  decode_rs(bset1, rs_cc[fec_code_type][1]*2  ) ;            if (bset1.size == bset0.size-ii ) { //unfixable               unfixable = 1 ;              bset1.size -= rs_cc[fec_code_type][1]*2  ;            }  //unfixable            bset2 = cat_binaryset( bset2, bset1 ) ;          } //lastword          ii += rs_cc[fec_code_type][0] + rs_cc[fec_code_type][1]*2 ;        } //while      print_binaryset(bset2) ;    } //RS      //////////////////////////////////////////////////////////////////////////////    // randomization    //////////////////////////////////////////////////////////////////////////////    if (fec_code_type<=6) {      bset2 = extract_binaryset( bset2, 0 , bset2.size-1 ) ; //remove tail byte    }    bset2 = byte2binary_MSB( bset2 ) ;    bset2 = randomizer( bset2 , randomizer_seed ) ; //only accept format= 0 (binary);    bset2 = binary2byte_MSB( bset2 ) ;     print_binaryset(bset2) ;    return( bset2 ) ;} //fecdec

⌨️ 快捷键说明

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