Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help me solve some MATLAB errors when doing video coding

Status
Not open for further replies.

showntimoon

Junior Member level 3
Joined
Aug 27, 2006
Messages
28
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
1,478
hi guys ...
I got this error message while making a function that perform the video coding (mpeg)

??? Error using ==> zeros
Out of memory. Type HELP MEMORY for your options.

Error in ==> huffmanenco at 70
enco = zeros(1, length(sig)*maxSize);

Error in ==> vid_encode at 107
V = huffmanenco(V,dict); % encoding


the matlab suggests some solutions which are :
1- use clear
2- use pack
3- decrease no of variables
4- increase the size of virtual memory in windows

I used them all but nothing happened and the problem still existed
what I should do to solve the problem ,you think ????
 

MATLAB error message

Maybe you must change your arithmetic, the size of variable 'sig' and 'maxSize' is too large.

if you post your program, maybe we can get more information for help.

Ryan
 

Re: MATLAB error message

the huffmanenco is a built-in function but her is the code

function [V dict] =vid_encode(M)
V=[];
% scaling matrix
S = [ 1 1 2 2 4 4 8 8 ; 1 1 2 2 4 4 8 8;2 2 2 2 4 4 8 8;2 2 2 2 4 4 8 8; 4 4 4 4 4 4 8 8 ; 4 4 4 4 4 4 8 8 ; 8 8 8 8 8 8 8 8 ; 8 8 8 8 8 8 8 8 ];

for x=1:length(M)
M(x).cdata = double(M(x).cdata);

% adjust the frame dimensions to be divided by 16 (downsampling then
% block preparation)
t =size(M(x).cdata);
a = mod (t(1),16);
b = 16-a;
a2= mod (t(2),16);
b2 = 16-a2;
M(x).cdata = [M(x).cdata zeros(t(1),b2,3)];
M(x).cdata = [M(x).cdata;zeros(b,t(2)+b2,3)];

R = M(x).cdata:),:,1);
G = M(x).cdata:),:,2);
B = M(x).cdata:),:,3);

%color space conversion
Y = 0.299*R + 0.587*G + 0.114*B;
CB = -0.1687*R - 0.3312*G + 0.5000*B;
CR = 0.5000*R - 0.4183*G - 0.0816*B;

[o p]=size(CB); %[#rows #columns]

if mod(x,10)~=1 % P-frame -->subtract from the previous frame
M(x).cdata=M(x).cdata-M(x-1).cdata;
end

%operations on Y
Y3 = [];
for i=1:8:eek:
for j=1:8:p
A=Y(i:i+7,j:j+7);
A=dct2(A);
A= A./S; % scaling
A= round(A); % quantization
A=reshape(A,1,64); % reshape 1x64
Y3=[Y3 A];
end
end

%downsampling of CB
down2 =[];
for j=1:2:eek:
down =[];
for i=1:2:p
cb=mean2(CB(j:j+1,i:i+1));% CB(rows,columns)
down=[down cb];
end
down2=[down2;down];
end

%operations on CB
CB3 = [];
for i=1:8:eek:/2
for j=1:8:p/2
A=down2(i:i+7,j:j+7);
A=dct2(A);
A= A./S; %scaling
A= round(A); % quantization
A=reshape(A,1,64); % reshape 1x16
CB3= [CB3 A];
end
end

%downsampling of CR
down2 =[];
for i =1:2:eek:
down =[];
for j =1:2:p
cr=mean2(CR(i:i+1,j:j+1));
down=[down cr];
end
down2=[down2;down];
end

%operations on CR
CR3 = [];
for i=1:8:eek:/2
for j=1:8:p/2
A=down2(i:i+7,j:j+7);
A=dct2(A);
A= A./S; %scaling
A= round(A); % quantization
A=reshape(A,1,64); % reshape 1x16
CR3= [CR3 A];
end
end
V=[V Y3 CB3 CR3];
end

% to free memory
cwd = pwd;
cd('D:\');
pack
cd(cwd)

% variable length coding (VLC)
list = unique(V); %get list of symbols
prop=[];
for i=1:length(list) % calculate propabilities
j= find(V==list(i));
prop(i)= length(j);
end
prop=prop./length(V);
[dict,avglength]= huffmandict(list,prop); % generate dictionary
V = huffmanenco(V,dict); % encoding
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top