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

📄 csl_tcp2.c

📁 Dm6455 driver,magbe useful to you!
💻 C
📖 第 1 页 / 共 5 页
字号:
      * processing a non-interleaved MAP(as MAP1 in SA mode) x10, p10, and 
      * p11 must be non-interleaved data. And when processing the interleaved 
      * MAP (As MAP2 in SA mode) x10, p10, and p11 must be the interleaved data 
      * that has been deinterleaved.
      */
      
    /* Form the de-interleave table */
    for (cnt = 0; cnt < frameLen; cnt++)
        deInterleaveTbl [ interleaver [cnt] ] = cnt;
        
	/* Form the output for MAP1 and MAP2 */ 
    

    switch (rate) {
        case TCP2_RATE_1_5: {
            /* for code rate = 1/5 */
            /* Set of 5 symbols are processed at once */
            
             /* input (Uint8):
              * x0a0b0a0'b0'x1a1b1a1'b1'
              * 
              * output (Uint32)
              * non interleaved: 
              *  b0 a0 x0       
              *  b1 a1 x1
              *   
              * interleaved: 
              *  b0' a0' x0       
              *  b1' a1' x1
              */
        
            outCnt = 0;
            for (inCnt = 0; inCnt < frameLen * rate; inCnt += rate) {
                /*  Form the non interleaved data */                  
                output0 [outCnt] = input [inCnt + 2] << 12 |
                                input [inCnt + 1] << 6 | 
                                input [inCnt];  
            
                /*  Form the interleaved data */  
                tableIndex = inCnt / rate;
                dataIndex =  deInterleaveTbl [tableIndex] * rate;
                               
                output1 [outCnt] = input [dataIndex + 4] << 12 |
                                input [dataIndex + 3] << 6 | 
                                input [inCnt];  
                                
                /* Fill the next Uint32 value */
                outCnt++;
            }
            break; 
        }/* TCP2_RATE_1_5 */

        case TCP2_RATE_1_4: {
            /* for code rate = 1/4 */
            /* Set of 4 symbols are processed at once */
            
             /* input (Uint8):
              * x0a0b0b0'x1a1a1'b1'
              * 
              * output (Uint32)
              * non interleaved: 
              *  b0 a0 x0       (even)
              *  0 a1 x1        (odd)
              *   
              * interleaved: 
              *  b0' 0  x0       
              *  b1' a1' x1
              */
        
            outCnt = 0;

             /* Used to handle the  difference in the input data symbols for 
              * 2 consecutive set of 4 symbols
              */
            iter = 0;  
            
            for (inCnt = 0; inCnt < frameLen * rate; inCnt += rate) {
                if (0 == iter) {
                    /*  Form the non interleaved data */                  
                    output0 [outCnt] = input [inCnt + 2] << 12 |
                                    input [inCnt + 1] << 6 | 
                                    input [inCnt];  
            
                    /*  Form the interleaved data */  
                    tableIndex = inCnt / rate;

                    dataIndex =  deInterleaveTbl [tableIndex] * rate;
                    
                    if ((deInterleaveTbl [tableIndex] % 2) == 0) {                                  
                        output1 [outCnt] = input [dataIndex + 3] << 12 | 
                                    input [inCnt];  
                    }
                    else {
                        output1 [outCnt] = input [dataIndex + 3] << 12 |
                                          input [dataIndex + 2] << 6 | 
                                          input [inCnt];  
                    }
                    
                    iter = 1;
                } /* end of if (0 == iter) */   
                else {
                
                    /*  Form the non interleaved data */                  
                    output0 [outCnt] = input [inCnt + 1] << 6 | 
                                    input [inCnt];  
                
                    /*  Form the interleaved data */  
                    tableIndex = inCnt / rate;
                    
                    dataIndex =  deInterleaveTbl [tableIndex] * rate;
                    
                    if ((deInterleaveTbl [tableIndex] % 2) == 0) {                                  
                        output1 [outCnt] = input [dataIndex + 3] << 12 | 
                                    input [inCnt];  
                    }
                    else {
                        output1 [outCnt] = input [dataIndex + 3] << 12 |
                                          input [dataIndex + 2] << 6 | 
                                          input [inCnt];  
                    }
                    
                    iter = 0;
                } /* end of else of if (0 == iter) */                             
                
                /* Fill the next Uint32 value */
                outCnt++;
            }
            break; 
        }/* TCP2_RATE_1_4 */

        case TCP2_RATE_1_3: {
            /* for code rate = 1/3 */
            /* Set of 3 symbols are processed at once */
            
             /* input (Uint8):
              * x0a0a0'x1a1a1'
              * 
              * output (Uint32)
              * non interleaved: 
              *   a0 x0       
              *   a1 x1
              *   
              * interleaved: 
              *   a0' x0       
              *   a1' x1
              */
        
            outCnt = 0;
            for (inCnt = 0; inCnt < frameLen * rate; inCnt += rate) {
                /*  Form the non interleaved data */                  
                output0 [outCnt] = input [inCnt + 1] << 6 | 
                                input [inCnt];  
            
                /*  Form the interleaved data */  
                tableIndex = inCnt / rate;
                
                dataIndex =  deInterleaveTbl [tableIndex] * rate;
                               
                output1 [outCnt] = input [dataIndex + 2] << 6 | 
                                input [inCnt];  
                                
                /* Fill the next Uint32 value */
                outCnt++;
            }
            break; 
        }/* TCP2_RATE_1_3 */
        
        case TCP2_RATE_1_2: {
            /* for code rate = 1/2 */
            /* Set of 2 symbols are processed at once */
            
             /* input (Uint8):
              * x0a0x1a1'x2a2x3a3'
              * 
              * output (Uint32)
              * non interleaved: 
              *  a0 x0       (even)
              *  0  x1        (odd)
              *   
              * interleaved: 
              *  0  x0       
              *  a1' x1
              */
        
            outCnt = 0;

             /* Used to handle the  difference in the input data symbols for 
              * 2 consecutive set of 2 symbols
              */
            iter = 0;  
            
            for (inCnt = 0; inCnt < frameLen * rate; inCnt += rate) {
                if (0 == iter) {
                    /*  Form the non interleaved data */                  
                    output0 [outCnt] = input [inCnt + 1] << 6 | 
                                    input [inCnt];  
            
                    /*  Form the interleaved data */  
                    tableIndex = inCnt / rate;
                    dataIndex =  deInterleaveTbl [tableIndex] * rate;
                    
                    if ((deInterleaveTbl [tableIndex] % 2) == 0) {                                  
                        output1 [outCnt] = input [inCnt];  
                    }
                    else {
                        output1 [outCnt] = input [dataIndex + 1] << 6 | 
                                          input [inCnt];  
                    }
                    
                    iter = 1;
                } /* end of if (0 == iter) */   
                else {
                
                    /*  Form the non interleaved data */                  
                    output0 [outCnt] = input [inCnt];  
                
                    /*  Form the interleaved data */  
                    tableIndex = inCnt / rate;
                    dataIndex =  deInterleaveTbl [tableIndex] * rate;
                    
                    if ((deInterleaveTbl [tableIndex] % 2) == 0) {                                  
                        output1 [outCnt] = input [inCnt];  
                    }
                    else {
                        output1 [outCnt] = input [dataIndex + 1] << 6 | 
                                          input [inCnt];  
                    }
                    
                    iter = 0;
                } /* end of else of if (0 == iter) */                             
                
                /* Fill the next Uint32 value */
                outCnt++;
            }
            break; 
        }/* TCP2_RATE_1_2 */
        
        case TCP2_RATE_3_4: {
            /* for code rate = 3/4 */
             /* input (Uint8):
              * x0a0x1x2x3a3'x4x5
              * 
              * output (Uint32)
              * non interleaved: 
              *  a0 x0       (even)
              *  0  x1        (odd)
              *  0  x2
              *   
              * interleaved: 
              *  0   x0       
              *  0   x1
              *  0   x2
              *  a3' x3
              */
             
            /* Set of 4 symbols are processed at once to get 3 output data */
            outCnt = 0;
            
             /* Used to handle the  difference in the input data symbols for 
              * 2 consecutive set of 4 symbols
              */
            iter = 0;  
            
            /* to calculate the symbols added for rate 3/4 */
            
            for (inCnt = 0; inCnt < frameLen; inCnt += 1) {
                 /* Shift the data and convert to the 32 bit TCP input 
                  * data format 
                  */        
                  if (((inCnt % 2) == 0) && ((inCnt % 3) == 0))  {
                    /*  Form the non interleaved data - 3 */                  
                    output0 [outCnt] = (
                                (input [inCnt + numPar + 1] << 6) |                                
                                (input [inCnt + numPar] << 0)                                 
                                );
                    }
                    else {
                      output0 [outCnt ] = input [inCnt  + numPar];                                
                    }
                    
                    /*  Form the interleaved data */  
                    dataIndex =  deInterleaveTbl [inCnt] + numPar;
                    
                    if (((deInterleaveTbl [inCnt] % 2) != 0) && 
                        ((deInterleaveTbl [inCnt] % 3) == 0)) {                                  
                        output1 [outCnt] = input [dataIndex + 1] << 6 | 
                                          input [inCnt + numPar];  
                    }
                    else {
                        output1 [outCnt] = input [inCnt + numPar];  
                    }
                    
                     /* adjust for the parity data, required as the inCnt is 
                      * incremented by 1 and not rate 
                      */
                    if ((inCnt % 3) == 0) {
                        numPar++; /* offset to get the data index */
                    }
                    
                    outCnt += 1;
            } /* end of for */

            break;
        }/* TCP2_RATE_3_4 */

        default:
            break;  

    }/* end of switch */
    
    /* Free the memory allocated for de interleave table */
    free (deInterleaveTbl);

    return;
} /* end TCP2_demuxInput() */


/** ============================================================================
 *   @n@b TCP2_depunctInputs
 *
 *   @b Description
 *   @n This function scales and sorts input data into a code rate 1/5 format.
 *
 *   @b Arguments
     @verbatim
            frameLen            Input data length in bytes
            
            inputData           Input data
            
            rate                Input data code rate

            scalingFact         Scaling factor

            depunctData         Depunctured data
            
      @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  The depunctData will contain the data depunctured to rate 1/5. 
 *
 *   @b Modifies
 *   @n None   
 *
 *   @b Example
 *   @verbatim

            TCP2_depunctInputs (length, inputData, rate

                      scalingFact, depunctData);

     @endverbatim
 * ===========================================================================
 */
void TCP2_depunctInputs (
    Uint32              frameLen,
    TCP2_UserData*       inputData,
    TCP2_Rate            rate,
    Uint32              scalingFact,
    TCP2_InputData*      depunctData       
)
{
	Uint32  inCnt;
	Uint32  outCnt;
   	Uint32  cnt;
    Uint32  modLen;
    Uint16  iter;
    
    switch (rate) {
        case TCP2_RATE_1_5: {
            /* for code rate = 1/5 */
            /* Set of 5 symbols are processed at once */
            
             /* input (Uint8):
              * x0a0b0a0'b0'x1a1b1a1'b1'
              * 
              * output (Uint32)
              * b0' a0' b0 a0 x0       
              * b1' a1' b1 a1 x1
              */
        
            outCnt = 0;
            for (inCnt = 0; inCnt < frameLen * rate; inCnt += rate) {
                /* Shift the data and co

⌨️ 快捷键说明

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