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

📄 adc_4_decompression_m6.m

📁 audio compression matlab code
💻 M
字号:
clc; clear; clf;
% decompression of the differential coding 
warning off;

load data_input.mat

% load Hufman table..
load HuffmanTable.mat % S y
N = length(S);

% search the minimum length code
xx = cellfun('length', y); 
lmin = min(xx);
lmax = max(xx);

% load de compressed file ..
load data_output % code

% decompress
dec(1) = bin2dec(code(1:8));
cod = code(9:length(code));
end_decode = 0;  
v = [];
q = 0;
k = lmin;
j_start = 1; 
j_stop = j_start + k - 1;
index = [j_start: j_stop];
while (~end_decode) ,
    v = cod(index);           % read first bits..
    got = 0;
    for q = 1:length(y),   
        vv = y(q); 
        vv = f_cell2char(vv);
        if (length(v) == length(vv)),   % search the code "v" in Huffman table "y"
            if (v == vv),
               got = 1;
               dec = [dec S(q)];
               j_start = j_stop + 1;
               j_stop =  j_start + lmin - 1;
               index = [j_start: j_stop];
               if (j_stop > length(cod)) | (j_start >=length(cod)), 
               disp('finished'); 
               end_decode = 1;
               end;
               break;
            end;
        end; 
    end;  
   if got == 0,     % add one more bit   
       j_stop =  j_stop + 1;
       index = [j_start: j_stop];
       if (j_stop - j_start) > lmax, disp('error 1'); break; end;
         if (j_stop > length(cod)) , 
           disp('finished'); 
           end_decode = 1;
       end; 
   end; 
end;

dec = double(dec);
% decompression 
nd = length(dec);
anew = zeros(1,nd);
anew(1) = dec(1);
for i = 2:nd,
   anew(i) = dec(i) + anew(i-1);
end;

anew_1 = double(anew) ./ 128;  % rescale to [-1,1];
anew_2 = anew_1 .* mx;   % rescale to initial range;
anew = anew_2;

clf;
I = double(I);
I = I(1:length(anew));

subplot(211), plot(I); hold on; plot(anew,'r');
subplot(212), plot(double(I) - double(anew));
MSE = sum((I-anew).^2) / nd
disp('Finnished..');

⌨️ 快捷键说明

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