astyle --recursive --indent=spaces=2 --style=kr --indent-col1-comments --break-blocks --convert-tabs --max-code-length=200

This is done for better merging branch/LG_PRE_RELEASE_0.3 into trunk (same process is applied on this branch)

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7073 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
Lionel Gauthier
2015-04-09 09:29:12 +00:00
parent f0a8a0b3b5
commit 059a0a3fdc
2044 changed files with 1182666 additions and 1145123 deletions
+64 -41
View File
@@ -1,5 +1,5 @@
/*******************************************************************************
OpenAirInterface
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface is free software: you can redistribute it and/or modify
@@ -14,31 +14,31 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
along with OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
/* file: ccoding_byte_lte.c
purpose: Tail-biting convolutional code from 36-212, V8.6 2009-03. Includes CRC (8-UCI,16-DCI)and RNTI scrambling (DCI)
author: raymond.knopp@eurecom.fr
date: 21.10.2009
date: 21.10.2009
*/
#include "defs.h"
//#define DEBUG_CCODE 1
unsigned short glte[] = { 0133, 0171, 0165 }; // {A,B}
unsigned short glte_rev[] = { 0155, 0117, 0127 }; // {A,B}
unsigned short glte_rev[] = { 0155, 0117, 0127 }; // {A,B}
unsigned short gdab[] = { 0133, 0171, 0145 }; // {A,B}
unsigned short gdab_rev[] = { 0155, 0117, 0123 }; // {A,B}
unsigned short gdab_rev[] = { 0155, 0117, 0123 }; // {A,B}
unsigned char ccodelte_table[128]; // for transmitter
unsigned char ccodelte_table_rev[128]; // for receiver
@@ -55,11 +55,12 @@ unsigned char ccodelte_table_rev[128]; // for receiver
void
ccodelte_encode (unsigned int numbits,
unsigned char add_crc,
unsigned char *inPtr,
unsigned char *outPtr,
unsigned short rnti) {
ccodelte_encode (unsigned int numbits,
unsigned char add_crc,
unsigned char *inPtr,
unsigned char *outPtr,
unsigned short rnti)
{
unsigned int state;
unsigned char c, out, first_bit;
@@ -75,12 +76,12 @@ ccodelte_encode (unsigned int numbits,
/* The input bit is shifted in position 8 of the state.
Shiftbit will take values between 1 and 8 */
state = 0;
if (add_crc == 1) {
crc = crc8(inPtr,numbits);
first_bit = 2;
c = (unsigned char)(crc>>24);
}
else if (add_crc == 2) {
} else if (add_crc == 2) {
crc = crc16(inPtr,numbits);
#ifdef DEBUG_CCODE
printf("ccode_lte : crc %x\n",crc);
@@ -93,12 +94,12 @@ ccodelte_encode (unsigned int numbits,
first_bit = 2;
// c = (unsigned char)(crc>>24);
c = (unsigned char)((crc>>16)&0xff);
}
else {
} else {
next_last_byte = numbits>>3;
first_bit = (numbits-6)&7;
first_bit = (numbits-6)&7;
c = inPtr[next_last_byte-1];
}
#ifdef DEBUG_CCODE
printf("next_last_byte %x (numbits %d, %d)\n",c,numbits,next_last_byte);
#endif
@@ -116,18 +117,22 @@ ccodelte_encode (unsigned int numbits,
dummy+=3;
#endif
}
// get bits from next to last byte of input (not when crc is added)
if ((add_crc==0)&&((numbits&7)>0)) {
c = inPtr[next_last_byte];
// printf("last_byte %x\n",c);
// for (shiftbit = 0 ; shiftbit < (numbits&7) ; shiftbit++) {
for (shiftbit = (numbits&7)-1 ; shiftbit>=0 ; shiftbit--) {
state >>= 1;
if ((c&(1<<shiftbit)) != 0)
state |= 64;
state |= 64;
#ifdef DEBUG_CCODE
printf("shiftbit %d, %d: %d -> %d \n",shiftbit,state>>6,dummy,state);
dummy+=3;
printf("shiftbit %d, %d: %d -> %d \n",shiftbit,state>>6,dummy,state);
dummy+=3;
#endif
}
}
@@ -152,10 +157,11 @@ ccodelte_encode (unsigned int numbits,
// for (shiftbit = 0; (shiftbit<8) && (numbits>0);shiftbit++,numbits--) {
for (shiftbit = 7; (shiftbit>=0) && (numbits>0);shiftbit--,numbits--) {
for (shiftbit = 7; (shiftbit>=0) && (numbits>0); shiftbit--,numbits--) {
state >>= 1;
if ((c&(1<<shiftbit)) != 0){
state |= 64;
if ((c&(1<<shiftbit)) != 0) {
state |= 64;
}
out = ccodelte_table[state];
@@ -174,27 +180,29 @@ ccodelte_encode (unsigned int numbits,
}
// now code 8-bit CRC for UCI
if (add_crc == 1) {
if (add_crc == 1) {
c = (unsigned char)(crc>>24);
// for (shiftbit = 0; (shiftbit<8);shiftbit++) {
for (shiftbit = 7; (shiftbit>=0);shiftbit--) {
for (shiftbit = 7; (shiftbit>=0); shiftbit--) {
state >>= 1;
if ((c&(1<<shiftbit)) != 0){
state |= 64;
if ((c&(1<<shiftbit)) != 0) {
state |= 64;
}
out = ccodelte_table[state];
*outPtr++ = out & 1;
*outPtr++ = (out>>1)&1;
*outPtr++ = (out>>2)&1;
#ifdef DEBUG_CCODE
printf("crc bit %d input %d, outbit %d: %d -> %d (%d)\n",shiftbit,state>>6,dummy,state,out,ccodelte_table[state]);
dummy+=3;
#endif //DEBUG_CCODE
}
}
@@ -202,24 +210,26 @@ ccodelte_encode (unsigned int numbits,
if (add_crc == 2) {
c16 = (unsigned short)(crc>>16);
// for (shiftbit = 0; (shiftbit<16);shiftbit++) {
for (shiftbit = 15; (shiftbit>=0);shiftbit--) {
for (shiftbit = 15; (shiftbit>=0); shiftbit--) {
state >>= 1;
if ((c16&(1<<shiftbit)) != 0){
state |= 64;
if ((c16&(1<<shiftbit)) != 0) {
state |= 64;
}
out = ccodelte_table[state];
*outPtr++ = out & 1;
*outPtr++ = (out>>1)&1;
*outPtr++ = (out>>2)&1;
#ifdef DEBUG_CCODE
printf("crc bit %d input %d, outbit %d: %d -> %d (%d)\n",shiftbit,state>>6,dummy,state,out,ccodelte_table[state]);
dummy+=3;
#endif //DEBUG_CCODE
}
}
}
@@ -227,7 +237,7 @@ ccodelte_encode (unsigned int numbits,
/*************************************************************************
Functions to initialize the code tables
*************************************************************************/
@@ -242,12 +252,15 @@ void ccodelte_init(void)
for (i = 0; i < 128; i++) {
ccodelte_table[i] = 0;
/* Compute 3 output bits */
for (j = 0; j < 3; j++) {
sum = 0;
for (k = 0; k < 7; k++)
if ((i & glte[j]) & (1 << k))
sum++;
/* Write the sum modulo 2 in bit j */
ccodelte_table[i] |= (sum & 1) << j;
}
@@ -261,12 +274,15 @@ void ccodelte_init_inv(void)
for (i = 0; i < 128; i++) {
ccodelte_table_rev[i] = 0;
/* Compute R output bits */
for (j = 0; j < 3; j++) {
sum = 0;
for (k = 0; k < 7; k++)
if ((i & glte_rev[j]) & (1 << k))
sum++;
/* Write the sum modulo 2 in bit j */
ccodelte_table_rev[i] |= (sum & 1) << j;
}
@@ -279,12 +295,15 @@ void ccodedab_init(void)
for (i = 0; i < 128; i++) {
ccodelte_table[i] = 0;
/* Compute 3 output bits */
for (j = 0; j < 3; j++) {
sum = 0;
for (k = 0; k < 7; k++)
if ((i & gdab[j]) & (1 << k))
sum++;
/* Write the sum modulo 2 in bit j */
ccodelte_table[i] |= (sum & 1) << j;
}
@@ -298,12 +317,15 @@ void ccodedab_init_inv(void)
for (i = 0; i < 128; i++) {
ccodelte_table_rev[i] = 0;
/* Compute R output bits */
for (j = 0; j < 3; j++) {
sum = 0;
for (k = 0; k < 7; k++)
if ((i & gdab_rev[j]) & (1 << k))
sum++;
/* Write the sum modulo 2 in bit j */
ccodelte_table_rev[i] |= (sum & 1) << j;
}
@@ -313,7 +335,7 @@ void ccodedab_init_inv(void)
/*****************************************************************/
/**
Test program
Test program
******************************************************************/
@@ -331,11 +353,12 @@ main()
ccodelte_init();
inPtr = test;
outPtr = output;
ccodelte_encode(21, inPtr, outPtr);
for (i = 0; i < 21*3; i++) printf("%x ", output[i]);
printf("\n");