⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sim_system.cpp

📁 DPCM编码的联合信源信道译码
💻 CPP
字号:
/*
**********************************************************************************
  	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 (&ltime1);
		

		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 (&ltime2);
		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();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -