?? sim_system.cpp
字號(hào):
/*
**********************************************************************************
FILENAME: ldpc.c
version 0.1
(C) Pan Yu, 2004
Declaration:
All right is deserved by author
Anyone use this source codes and remove author's name is prohibited
Without agreement,noboby can copy this codes to others.
Fucntion Description:
An LDPC code simulator based on SPA algorithm
*********************************************************************************
ChangeLog:
2004-07-10 : start
**********************************************************************************
*/
#include "sim_system.h"
#include "UVLC.h"
#include "init_UVLC.h"
#include "sim_config.h"
#include "sys\timeb.h"
#include "codec_function.h"
#define DBG 0
void main(){
FILE * fi,*fp;
int j,k;
int count;
int tot_time=0;
// int flag;
count = 0;
time_t ltime1;
time_t ltime2;
#ifdef WIN32
struct _timeb tstruct1;
struct _timeb tstruct2;
#else
struct timeb tstruct1;
struct timeb tstruct2;
#endif
int tmp_time;
Init_system();
Init_UVLC();
sys_spt.fp_result = fopen(RESULT_FILE,"a+");
// for (sys_spt.EbNo=sys_spt.EbNo_start; sys_spt.EbNo<sys_spt.EbNo_end; sys_spt.EbNo+=0.2)
{
printf("file was open! BSC_P = %1.3f Iter_Num= %2d Threshold= %1.4f\n",BSC_P,NUM_ITER,THRESHOLD);
fprintf(sys_spt.fp_result,"\nBSC_P = %1.3f Iter_Num= %2d Threshold= %1.4f\n",BSC_P,NUM_ITER,THRESHOLD);
//----------------------clear
sys_UVLC.sum_symbol_error=0;
sys_spt.hard_error = 0;
sys_spt.bit_error = 0;
sys_spt.block_error = 0;
sys_spt.undetected_bit_error = 0;
sys_spt.undetected_block_error = 0;
sys_spt.max_iterations = 0;
sys_spt.min_iterations = sys_spt.iter_times;
sys_spt.aver_iterations= 0;
for (int i=0;i<sys_spt.iter_times;i++)
{
sys_spt.error_iter[i]=0;
}
// UVLCGen1();
// UVLCGen2();
// FLCGen1();
FLCGen2();
fi=fopen("dh1.bin","rb"); // read the original img file
fp=fopen(DPCM_IMG_FILE,"wb");
#ifdef WIN32
_ftime (&tstruct1);
#else
_ftime (&tstruct1);
#endif
time (<ime1);
for(i=0;i<256;i++)
{
sys_UVLC.bpl[i]=0;
for(k=0,j=0;j<256;j++)
{
k= UVLCEncoder(fi,k,i,j);
}
// SourceGen(i); //generate the source bits
printf("\n %3d",sys_UVLC.bpl[i]);
count+=sys_UVLC.bpl[i];
// printf("\n %3d",k);
// LdpcEncoder();
Modulation(i);
PassChannel(i);
// Init_LdpcIteration();
// LdpcIteration(i);
UVLCDecoder(fp,i);
UpdateBit();
//Ldpc_Ber_Cal(i);
// flag = 1; //Method1: flag==1;SSCD
// UVLCDecoderOut(fp,i);
BerCalc(i);
}
#ifdef WIN32
_ftime (&tstruct2);
#else
_ftime (&tstruct2);
#endif
time (<ime2);
tmp_time=(ltime2*1000+tstruct2.millitm)-(ltime1*1000+tstruct1.millitm);
tot_time=tot_time+tmp_time;
fclose(fi);
fclose(fp);
printf("count=%5d the total sum of error symbols=%5d\n",count,sys_UVLC.sum_symbol_error);
fprintf(sys_spt.fp_result,"harderror =%5d biterror =%5d symbol error=%5d\n",sys_spt.hard_error,sys_spt.bit_error,sys_UVLC.sum_symbol_error);
// NCEDecoder();
DPCMDecoder();
}
printf("\nTotal Decoding time is: %.3f sec\n",tot_time*0.001);
fprintf(sys_spt.fp_result,"\nTotal Decoding time is: %.3f sec\n",tot_time*0.001);
fclose(sys_spt.fp_result);
Term_UVLC();
Term_system();
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -