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

📄 ctc_decoder.c

📁 这个文件包括wimax中所有的编解码源代码
💻 C
字号:
/*****************************************************************************//*   FIle Name : ctc_decoder.c                                               *//*   Description : WiMax OFDM FEC CTC Decoder                                *//*   author : miffie                                                         *//*   Date   : Nov/15/05                                                      *//*   Copyright (c) 2005 miffie   All rights reserved.                        *//*****************************************************************************/struct binaryset ctc_decoder (struct binaryset datain,                               char fec_code_type, char Nsub ) {//input format must be 1  and each bit data is SOFT(0x0-0xf)int 	ii , jj , NN, repeat ;char 	tmp1 , tmp2 , shifter ;char	*top ;struct 	binaryset bset0, bset1 , bset2 ;char    bdat[ 64 ] ;char    edat[ 64 ] ;char    fdat[ 64 ] ;char  	parity, sum_parity, previous_sum ;char    fail ;char    rowtype, columntype ;char    row, column , nx, ny;static  UNKWN= 8 ;//                               row column Ix  Iy  B  Qchar  ctc_parameters[7][3] = { {  6,  7,  1 },                               {  8, 11,  2 },                               {  9, 17,  3 },                               { 12, 11,  1 },                               { 18, 13,  3 },                               { 24, 17,  2 },                               { 27, 17,  3 } } ;char Npsub[7] = { 24, 24, 24, 48, 48, 72, 72} ;  //Main    NN = ctc_parameters[fec_code_type-13][0] * Nsub ;    if ((top = (char *)malloc(NN*4*sizeof(char)) ) == NULL) {        PRINTF( " malloc failed in ctc_decoder.c\n") ;    } //fail    else { //allocated     PRINTF( "ctc_decoder.c size=0x%x\n", datain.size ) ;     bset0.format= 1 ;     bset0.size= NN*4 ;     bset0.data= top ;     //bset0 MAP      //0 - 2*NN-1   A0,B0,....,An-1,Bn-1     //2*NN -3*NN-1 Y10,Y11,....Y1n-1 (before Puncturing)     //3*NN -4*NN-1 Y20,Y21,....Y2n-1 (before Puncturing)     for(ii=0;ii<2*NN;ii++) {//for        bset0.data[ii]  = datain.data[ii] ;     }//for     /////////////////////////////////////////////////////////     //DePuncturing     if (ctc_parameters[fec_code_type-13][2]==1) { //1:1/2       for(ii=2*NN;ii<4*NN;ii++) { //for         bset0.data[ii]  = datain.data[ii] ;       }//for     } else if (ctc_parameters[fec_code_type-13][2]==2) { //2:2/3       for(ii=0;ii<(NN/2);ii++) { //for         bset0.data[2*NN+2*ii]  = datain.data[2*NN+ii] ;         bset0.data[2*NN+2*ii+1]  = UNKWN ;         bset0.data[3*NN+2*ii]  = datain.data[2*NN+(NN/2)+ii] ;         bset0.data[3*NN+2*ii+1]  = UNKWN ;       }//for     } else if (ctc_parameters[fec_code_type-13][2]==3) { //3:3/4       for(ii=0;ii<(NN/3);ii++) { //for         bset0.data[2*NN+3*ii]  = datain.data[2*NN+ii] ;         bset0.data[2*NN+3*ii+1]  = UNKWN ;         bset0.data[2*NN+3*ii+2]  = UNKWN ;         bset0.data[3*NN+3*ii]  = datain.data[2*NN+(NN/3)+ii] ;         bset0.data[3*NN+3*ii+1]  = UNKWN ;         bset0.data[3*NN+3*ii+2]  = UNKWN ;       }//for     } //3:3/4     //Loop     print_binaryset( bset0 ) ;     for (repeat=0; repeat<2; repeat++) {//repeat       /////////////////////////////////////////////////////////       //Natural order Decoder       /////////////////////////////////////////////////////////       bset1 = extract_binaryset( bset0, 0,  NN*3 ) ;       bset1 = viterbi_ctc( bset1 ) ;       //Copy back to SoftOutput to bset0       for (jj=0;jj<NN*3;jj++) { //for         bset0.data[jj] = bset1.data[jj] ;       } //for       print_binaryset( bset0 ) ;       /////////////////////////////////////////////////////////       //Interleaved Decoder       /////////////////////////////////////////////////////////       bset1 = extract_binaryset( bset0, 0,  NN*2 ) ;       bset1 = ctc_interleaver( bset1 ,  ctc_parameters[fec_code_type-13][1]) ;       bset2 = extract_binaryset( bset0, NN*3,  NN ) ;       bset1 = cat_binaryset( bset1, bset2 ) ;       bset1 = viterbi_ctc( bset1 ) ;       bset2 = extract_binaryset( bset1, 0,  NN*2 ) ;       bset2 = ctc_deinterleaver( bset2 ,  ctc_parameters[fec_code_type-13][1]) ;       //Copy back to SoftOutput to bset0       for (jj=0;jj<NN*2;jj++) { //for         bset0.data[jj] = bset2.data[jj] ;       } //for       for (jj=0;jj<NN;jj++) { //for         bset0.data[jj+3*NN] = bset1.data[jj+2*NN] ;       } //for       print_binaryset( bset0 ) ;     } //repeat     /////////////////////////////////////////////////////////     //Soft to Hard Decision     bset0.data = top ;     bset0.size = NN*2 ;     bset0.format = 0 ;     for(jj=0;jj<bset0.size;jj++) { //each data              bset0.data[jj] = (bset0.data[jj]>=8) ? 1 : 0 ;     } //each data      /////////////////////////////////////////////////////////    } //allocated    free ( datain.data ) ;    bset0 = binary2byte_MSB( bset0 ) ;    return ( bset0 ) ;} //ctc_decoder

⌨️ 快捷键说明

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