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

📄 maindecode.m

📁 压缩包中的内容用matlab语言对算术码进行描述
💻 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 + -