%function [bitstream, quality]=compressSeq(seq_name, frames, opt)
% seq_name- directory where sequence as f-%d.png are stored
% frames - [1 2 3 4], or [1 3 5], etc, index to the frame numbers in the seq
% opt - options, eg. opt.pel = 0.5;
% bitstream - array of 0/1s
% psnr - n x 1, PSNR
function [bitstream]=compressSeq(seq_name, frames)
f_list = dir(seq_name);
for k=1:length(frames)
%load seq
F{k} = imread(f_list(k).name);
end % for k
% initialize bitstream
bitstream =[]; bit_cnt =0;
% encode first frame as INTRA
[bs, nbits]=getINTRA(F{1}, QP);
bitstream(1:nbits) = bs; bit_cnt=nbits;
% reconstructed from INTRA
G{1}=decodeINTRA(bs, nbits, QP);
% code the rest as INTER
for k=2:length(frames)
[bs, nbits]=getINTER(G(k-1), F(k), QP);
G(k) = decodeINTER(G(k-1), bs, nbits, QP);
% update bitstream
bitstream(bit_cnt+1:bit_cnt+nbits) = bs;
End
% PSNR
for k=1:length(frames)
Quality(k) = psnr(F{k}, G{k});
end
|