📄 jdcdec.m
字号:
% Take a test vector
function x=jdcdec(y)
%clear;clc
%y=[jdcenc(-2) jdcenc(0) jdcenc(0) jdcenc(0) jdcenc(-124)];
% table specified
table=[2 0 0 0 0 0 0 0 0 0 %这里的关于直流的编码的表格中没有组号选项,,主要是因为,这里的组号和行数有特定的关系,行数kkt-1=组号
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];
N=length(y);
[p,dm1]=size(table);
x=[];
x1=[];
i=1; d=2;tmp=ones(p,1);
while i<=N,
% match y(i) to that of the d-th bit in the table
tmp=tmp.*[table(:,d)==y(i)]; % tmp is a vector of 0 and 1 with 1 indicate a match,
if sum(tmp)==1, % narrow down to one symbol, find it
d=2; % reset pointer to columns of table.
kkt=0;
for kk=1:length(tmp)
if(tmp(kk)==1),kkt=kk;end
end %这里通过循环找到匹配的码字的行的数值,也就是所对应行坐标kkt
cat=kkt-1; %本表中组号的数值和行坐标的值之间相差1,由航坐标-1就可以得到组号
tmp=ones(p,1);
if cat==11,i=i+1;end % Because the comparison ends in last but one column,but still a 0 is left
x1=y(i+1:i+cat);%这里的x就是DC差值所对应的幅度值
% Check Range
if(cat ~=0) %如果组号不为0,则求出该值
x2=bin2int(x1);
if(x2>=2^(cat-1) & x2<2^cat) %这个if……else块的作用是用来处理符号问题
x2=x2;
else
x1=ones(1,cat)-x1;
x2=-1*bin2int(x1);
end
else
x2=0; %如果组号为0,则幅度为0
end
% Update decoded vector
x=[x x2]; %x对应的是输出的解码的码流
i=i+cat;
else
d=d+1;
end
i=i+1;
end
x=filter(1,[1 -1],x); % Inverse of DPCM
% 看一个例子就可以理解IDPCM x=[10,1,2,3,4] x=filter(1,[1 -1],x) x =10,11,13,16,20
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -