📄 func_spiht_dec.m
字号:
function M = func_SPIHT_Dec(in,size_)
%
% 3D SPIHT decoder
%
% input: in : input bitstream
%
% output: ? : the reconstructed video sequence in the wavelet domain.
%
% This code is based on the implementation of the 2D-SPIHT by Jing Tian. It
% extends the code in order to handle video sequences (3D-SPIHT). Small changes have
% been also made to the 2D-SPIHT code.
%
%----------- Iniatialization -----------------%
M = zeros(size_(1),size_(2),size_(3),size_(4));
n_max = in(1,2);
%??level = in(1,3);
ctr = 4;
%----------- Initialize LIP, LSP, LIS ----------------
temp = [];
% bandsize1 = round (2.^(log2(size(M, 1)) - level + 1));
% bandsize2 = round (2.^(log2(size(M, 2)) - level + 1));
bandsize1 = 2;
bandsize2 = 2;
temp1 = 1 : bandsize1;
for i = 1 : bandsize2
temp = [temp; temp1];
end
LIP(:, 1) = temp(:);
temp = [];
temp1 = 1 : bandsize2;
for i = 1 : bandsize1
temp = [temp; temp1];
end
temp = temp';
LIP(:, 2) = temp(:);
len = size(LIP,1);
LIP(:,3) = ones(len,1);
LIS = LIP;
pstart = 1;
pend = bandsize2 / 2;
for i = 1 : bandsize1 / 2
LIS(pstart : pend, :) = [];
pdel = pend - pstart + 1;
pstart = pstart + bandsize2 - pdel;
pend = pend + bandsize2 - pdel;
end
len2 = size(LIS,1);
tLIP=LIP;
tLIS=LIS;
for i=1:size(M,3)-1
LIP=[LIP;tLIP];
LIP(i*len+1:(i+1)*len,3) = (i+1)*ones(len,1);
end
%添加z-dimension
len2 = size(LIS,1);
zLIP=LIP;
zLIS=LIS;
for i=1:size(M,3)-1
LIP=[LIP;zLIP];
LIP(i*len+1:(i+1)*len,3) = (i+1)*ones(len,1);
end
for i=1:size(M,3)/2-1
LIS=[LIS;zLIS];
LIS(i*len2+1:(i+1)*len2,3) = (i+1)*ones(len2,1);
end
LIS(:, 4) = zeros(size(M,3)/2*len2, 1);
%添加t-dimension
len3 = size(LIS,1);
tLIP = LIP;
tLIS = LIS;
for i = 1:size(M,4)-1
LIP = [LIP;tLIP];
LIP(i*len3+1 : (i+1)*len3,4) = (i+1)*ones(len3,1);
end
for i = 1:size(M,4)-1
LIP = [LIP;tLIP];
LIP(i*len3+1 : (i+1)*len3,4) = (i+1)*ones(len3,1);
end
%???????LIS(:, 4) = zeros(size(M,3)/2*len2, 1);
LSP = [];
n = n_max;
LIS(:, 4) = zeros(size(M,3)/2*len2, 1);
LSP = [];
%----------- Decoding ----------------
n = n_max;
while (ctr <= size(in,2))
%Sorting Pass
LIPtemp = LIP;temp = 0;
for i = 1:size(LIPtemp,1)
temp = temp+1;
if ctr > size(in,2)
return
end
if in(1,ctr) == 1
ctr = ctr + 1;
if in(1,ctr) > 0
M(LIPtemp(i,1),LIPtemp(i,2),LIPtemp(i,3),LIPtemp(i,4)) = 2^n + 2^(n-1);
else
M(LIPtemp(i,1),LIPtemp(i,2),LIPtemp(i,3),LIPtemp(i,4)) = -2^n - 2^(n-1);
end
LSP = [LSP; LIPtemp(i,:)];
LIP(temp,:) = []; temp = temp - 1;
end
ctr = ctr + 1;
end
LIStemp = LIS; temp = 0; i = 1;
while ( i <= size(LIStemp,1))
temp = temp + 1;
if ctr > size(in,2)
return
end
if LIStemp(i,5) == 0
if in(1,ctr) == 1
ctr = ctr + 1;
x = LIStemp(i,1); y = LIStemp(i,2);
z = LIStemp(i,3); t = LIStemp(i,4);
if ctr > size(in,2)
return
end
if in(1,ctr) == 1
LSP = [LSP; 2*x-1 2*y-1 2*z-1 2*t-1];
ctr = ctr + 1;
if in(1,ctr) == 1
M(2*x-1,2*y-1,2*z-1,2*t-1) = 2^n + 2^(n-1);
else
M(2*x-1,2*y-1,2*z-1,2*t-1) = -2^n - 2^(n-1);
end
ctr = ctr + 1;
else
LIP = [LIP; 2*x-1 2*y-1 2*z-1 2*t-1];
ctr = ctr + 1;
end
if ctr > size(in,2)
return
end
if in(1,ctr) == 1
ctr = ctr + 1;
LSP = [LSP; 2*x-1 2*y 2*z-1 2*t-1];
if in(1,ctr) == 1;
M(2*x-1,2*y,2*z-1,2*t-1) = 2^n + 2^(n-1);
else
M(2*x-1,2*y,2*z-1,2*t-1) = -2^n - 2^(n-1);
end
ctr = ctr + 1;
else
LIP = [LIP; 2*x-1 2*y 2*z-1 2*t-1];
ctr = ctr + 1;
end
if ctr > size(in,2)
return
end
if in(1,ctr) == 1
ctr = ctr + 1;
LSP = [LSP; 2*x 2*y-1 2*z-1 2*t-1];
if in(1,ctr) == 1
M(2*x,2*y-1,2*z-1,2*t-1) = 2^n + 2^(n-1);
else
M(2*x,2*y-1,2*z-1,2*t-1) = -2^n - 2^(n-1);
end
ctr = ctr + 1;
else
LIP = [LIP; 2*x 2*y-1 2*z-1 2*t-1];
ctr = ctr + 1;
end
if ctr > size(in,2)
return
end
if in(1,ctr) == 1
ctr = ctr + 1;
LSP = [LSP; 2*x 2*y 2*z-1 2*t-1];
if in(1,ctr) == 1
M(2*x,2*y,2*z-1,2*t-1) = 2^n + 2^(n-1);
else
M(2*x,2*y,2*z-1,2*t-1) = -2^n - 2^(n-1);
end
ctr = ctr + 1;
else
LIP = [LIP; 2*x 2*y 2*z-1 2*t-1];
ctr = ctr + 1;
end
if ctr > size(in,2)
return
end
if in(1,ctr) == 1
LSP = [LSP; 2*x-1 2*y-1 2*z 2*t-1];
ctr = ctr + 1;
if in(1,ctr) == 1
M(2*x-1,2*y-1,2*z,2*t-1) = 2^n + 2^(n-1);
else
M(2*x-1,2*y-1,2*z,2*t-1) = -2^n - 2^(n-1);
end
ctr = ctr + 1;
else
LIP = [LIP; 2*x-1 2*y-1 2*z 2*t-1];
ctr = ctr + 1;
end
if ctr > size(in,2)
return
end
if in(1,ctr) == 1
ctr = ctr + 1;
LSP = [LSP; 2*x-1 2*y 2*z 2*t-1];
if in(1,ctr) == 1;
M(2*x-1,2*y,2*z,2*t-1) = 2^n + 2^(n-1);
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -