1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| sig = quantificationf(sig_in,6)*(2^6);
% Ici l'échantillon n'est pas vraiment codé sur 6bits mais il prend des valeurs qui peuvent l'être
% on code notre signal
symbols = (-32:31); % Distinct data symbols appearing in sig
p = zeros(1,length(symbols); % Probability of each data symbol
for i=1:length(symbols)
p(i)=length(find(sig==symbols(i)));
end
dict = huffmandict(symbols,p); % Create the dictionary.
hcode = huffmanenco(sig,dict); % Encode the data.
function sig_out=quantificationf(sig_in,nbit_out)
if sig_in >= 0
sig_out=round(sig_in*(2^(nbit_out-1)-1)); 0à31
else
sig_out=round(sig_in*(2^(nbit_out-1))); -32à-1
end |
Partager