#include "permute.h" #include "turbodecoder.h" unsigned short table_p[52] = {7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257}; unsigned char table_v[52] = {3,2,2,3,2,5,2,3,2,6,3,5,2,2,2,2,7,5,3,2,3,5,2,5,2,6,3,3,2,3,2,2,6,5,2,5,2,2,2,19,5,2,3,2,3,2,6,3,7,7,6,3}; unsigned char v; unsigned short p; unsigned short s[MAX_COLS],q[MAX_ROWS],r[MAX_ROWS],T[MAX_ROWS]; unsigned short U[MAX_COLS*MAX_ROWS]; Tper PER[MAX_LONG_CB],DESPER[MAX_LONG_CB]; int M_Rows,M_Cols,M_long; int ComputePermutation(struct permute_t *permute, int Long_CodeBlock) { //int M_Rows,M_Cols,M_long; int i,j; int res,prim,aux; int kp,k; Tper *per,*desper; permute->PER=PER; permute->DESPER=DESPER; M_long=Long_CodeBlock; /*Determinar R*/ if( (40 <= M_long)&&(M_long <= 159) ) M_Rows = 5; else if( ( (160 <= M_long)&&(M_long <=200) ) || ((481 <= M_long) && (M_long <=530))) M_Rows = 10; else M_Rows = 20; /*Determinar p i v*/ if( (481 <= M_long)&&(M_long <= 530) ) { p = 53; v = 2; M_Cols = p; } else { i=0; do { p = table_p[i]; v = table_v[i]; i++; } while(M_long > (M_Rows*(p+1)) ); } /*Determinar C*/ if( (M_long) <= (M_Rows)*((p)-1) ) M_Cols = (p) - 1; else if(( (M_Rows)*(p-1) < M_long)&&(M_long <= (M_Rows)*(p) )) M_Cols = p; else if( (M_Rows)*(p) < M_long) M_Cols = (p) + 1; // calculem q q[0]=1; prim=6; for (i=1;i=40) { T[0]=4;T[1]=3;T[2]=2;T[3]=1;T[4]=0; } else if ((M_long<=200 && M_long>=160) || (M_long<=530 && M_long>=481)) { T[0]=9;T[1]=8;T[2]=7;T[3]=6;T[4]=5;T[5]=4;T[6]=3;T[7]=2;T[8]=1;T[9]=0; } else if ((M_long<=2480 && M_long>=2281) || (M_long<=3210 && M_long>=3161)) { T[0]=19;T[1]=9;T[2]=14;T[3]=4;T[4]=0;T[5]=2;T[6]=5;T[7]=7;T[8]=12;T[9]=18;T[10]=16;T[11]=13;T[12]=17;T[13]=15;T[14]=3;T[15]=1;T[16]=6;T[17]=11;T[18]=8;T[19]=10; } else { T[0]=19;T[1]=9;T[2]=14;T[3]=4;T[4]=0;T[5]=2;T[6]=5;T[7]=7;T[8]=12;T[9]=18;T[10]=10;T[11]=8;T[12]=13;T[13]=17;T[14]=3;T[15]=1;T[16]=16;T[17]=6;T[18]=15;T[19]=11; } // calculem r for (i=0;iPER[0]; desper=&permute->DESPER[0]; k=0; for (j=0;j