📄 jdcenc_ek.m
字号:
function b=jdcenc_ek(x)
%直流分量的huffman编码
if x ==0,
%b=[0 1 0];
b=[0 0];
return % done
else
c = floor(log2(abs(x)))+1;
end
% Hoffman table
tbl=[3 0 1 0 0 0 0 0 0 0
3 0 1 1 0 0 0 0 0 0
3 1 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0 0
3 1 0 1 0 0 0 0 0 0
5 1 1 0 0 0 0 0 0 0
4 1 1 1 0 0 0 0 0 0
5 1 1 1 1 0 0 0 0 0
6 1 1 1 1 1 0 0 0 0
7 1 1 1 1 1 1 0 0 0
8 1 1 1 1 1 1 1 0 0
9 1 1 1 1 1 1 1 1 0];
tab=[2 0 0 0 0 0 0 0 0 0
3 0 1 0 0 0 0 0 0 0
3 0 1 1 0 0 0 0 0 0
3 1 0 0 0 0 0 0 0 0
3 1 0 1 0 0 0 0 0 0
3 1 1 0 0 0 0 0 0 0
4 1 1 1 0 0 0 0 0 0
5 1 1 1 1 0 0 0 0 0
6 1 1 1 1 1 0 0 0 0
7 1 1 1 1 1 1 0 0 0
8 1 1 1 1 1 1 1 0 0
9 1 1 1 1 1 1 1 1 0];
tbl=tab;
% This is changed by Ravi Lakkundi
b=tbl(c+1,2:tbl(c+1,1)+1);
tmp=int2bin(x,c);
% tmp is 1 by c+1 vector containing sign-mag
% representation of x, first bit is sign bit.
if tmp(1)==0, % if x > 0
b=[b tmp(2:c+1)];
elseif tmp(1)==1, % if x < 0
b=[b ones(1,c)-tmp(2:c+1)];
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -