?? descramble.cpp
字號:
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
int *descramble(int *string_descramble)
{
// int *p_descramble = (int *)malloc(768*sizeof(int));
static int string_afterdescramble[768];
// int mask[42]={1,1,0,0,0,1,1,0,0,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,1};
int mask[42]={1,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1,0,0,0,1,1};
int lcode_generator[42]={1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int longcode[768*32];
int a=0,b=0;
int i=0;
int j=0;
for(i=0;i<=768*32-1;i++)
{
a=0;
for(j=0;j<=41;j++) //生成長碼
{
a=a ^ (mask[j]&lcode_generator[j]);
}
longcode[i]=a;
b=lcode_generator[41]; //寄存器移位
for(j=41;j>=1;j--)
{
lcode_generator[j]=lcode_generator[j-1];
}
lcode_generator[0]=b;
for(j=0;j<=41;j++)
{
if(j==1||j==2||j==3||j==5||j==6||j==7||j==10||j==16||j==17||j==18||j==19||j==21||j==22||j==25||j==26||j==27||j==31||j==33||j==35) //多項式所包含項
{
lcode_generator[j]=lcode_generator[j]^b;
}
//多項式不包含項
}
}
j=0;
for(i=0;i<=768*32-1;i++)
{
if(i%32==0) //分頻
{
string_afterdescramble[j] =*(string_descramble+j)^longcode[i]; //模2相加輸出以實現解擾
j++;
}
}
return (string_afterdescramble);
}
void main()
{
int string[768]={1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0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