📄 code_hdb3.c
字号:
/* ANSI C Source Code
* Code_HDB3.c
* Leon 5.11.2008
*/
#include "HDB3.h"
// 判1还是0
// 1 是0
// 1.1 零的长度小于3
// 1.1.1 是第一个0并且V_frist_z_define=1(小段里面的第一个零)
// frist_z_pos=num;frist_z_pole=-uni_pole;V_frist_z_define=0;
// code=0;z_num++
// 1.2 零的长度是3
// 1.2.1 如果V不等于+-1,则V=-pole;//这是初始
// code=-V;
// V=-V;
// V_frist_z_define=1;
// z_num=0;
// 1.2.2 如果V_num是偶数
// in[frist_z_pos]=frist_z_pole;pole=V;
// if(code!=0) uni_pole;
// in[num]=code;
// 2 是1
// 2.1 code=-pole;
// pole=code;
// uni_pole=code;
// in[num]=code;
void Code_HDB(int *in,int *out,struct Code_control *state)
{
int num=0;
int code;
state->z_num=0; //开始时0的个数为0
while(in[num]!=2)
{
if(in[num]==0)
{
if(state->z_num<3)
{
if((state->z_num==0)&&(state->V_frist_z_define==1))
{
state->frist_z_pos=num;
state->frist_z_pole=-state->uni_pole;
state->V_frist_z_define=0;
}
code=0;
state->z_num++;
}
else
{
if((state->V!=1)&&(state->V!=-1)) state->V=-state->pole; //初始V
code=-state->V;
state->V*=-1;
state->V_frist_z_define=1;
state->z_num=0;
if(((state->V_num)%2==0)&&(state->V_num>=0)) {out[state->frist_z_pos]=state->frist_z_pole;state->pole=state->V;}
state->V_num=0;
}
if(code!=0) state->uni_pole=code;
out[num]=code;
}
else
{
code=-state->pole;
state->pole*=-1;
state->uni_pole=code;
state->z_num=0;
state->V_num++;
out[num]=code;
}
num++;
}
out[num]=2;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -