?? maindecode.m
字號:
%Arithmetic Coding Programme!
% This is the main program for decoding!
%Copy right of XUJIE 2008
%If you have any question,please contact me
% xujie1984@gmail.com
%*******************************************
%The input file is test.txt.
%The main programme for encoding is mainencode.m!
%The main programme for decoding is maindecode.m!
%To caculate the compression ratio,you can run compressionratio.m!
%**************************************************************************
clear all
clear global
global prob no_of_symbols in_bit_file
% ---------------------------------------------------------------------------------------
K=16;
no_of_symbols=256;
output=[];
%Initialize prob!
prob=ones(1,no_of_symbols);
fid=fopen('test.txt','r');
while(1~=0)
ch = fread(fid,1);
if(feof(fid)),break;end
i=ch;
prob(i)=prob(i)+1;
end
%Start decoding!
OpenInputBitFile('compressed.txt');
initialize_arithmetic_decoder;
fid=fopen('decompressed.txt','w');
while(1~=0)
symbol=decode_symbol(prob,no_of_symbols);
if(feof(in_bit_file.file)),break;end
ch=char(symbol);
output=[output ch];
end
for ii=1:length(output)
fprintf(fid,'%c',output(ii));
end
fclose(fid);
CloseInputBitFile;
disp('******************************');
disp('***DECOMPRESSING COMPLETE!****');
disp('******************************');
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -