URL
https://opencores.org/ocsvn/mdct/mdct/trunk
Subversion Repositories mdct
[/] [mdct/] [trunk/] [MATLAB/] [dctm.m] - Rev 28
Go to most recent revision | Compare with Previous | Blame | View Log
Q = [ 16,11,10,16,24,40,51,61; 12,12,14,19,26,58,60,55; 14,13,16,24,40,57,69,56; 14,17,22,29,51,87,80,62; 18,22,37,56,68,109,103,77; 24,35,55,64,81,104,113,92; 49,64,78,87,103,121,120,101; 72,92,95,98,112,100,103,99 ]; N = 8; K = 8; x = [ 139,144,149,153,155,155,155,155; 144,151,153,156,159,156,156,156; 150,155,160,163,158,156,156,156; 159,161,162,160,160,159,159,159; 159,160,161,162,162,155,155,155; 161,161,161,161,160,157,157,157; 162,162,161,163,162,157,157,157; 162,162,161,161,163,158,158,158; ]; xn=x-128; X = [ zeros(1,N);zeros(1,N);zeros(1,N);zeros(1,N);zeros(1,N);zeros(1,N);zeros(1,N);zeros(1,N)]; Xq=X; xi=X; % 2D dct for v = 0:N-1 if v == 0 Cv = 1/sqrt(2); else Cv = 1; end for u = 0:N-1 if u == 0 Cu = 1/sqrt(2); else Cu = 1; end for j = 0:N-1, for i = 0:N-1 X(u+1,v+1) = X(u+1,v+1) + (2/N)*Cu*Cv*xn(i+1,j+1)*cos( ((2*i+1)*u*pi)/(2*N))*cos( ((2*j+1)*v*pi)/(2*N)); end end end end X; % idct for i = 0:N-1 for j = 0:N-1 for u = 0:N-1 if u == 0 Cu = 1/sqrt(2); else Cu = 1; end for v = 0:N-1 if v == 0 Cv = 1/sqrt(2); else Cv = 1; end xi(i+1,j+1) = xi(i+1,j+1) + (2/N)*Cu*Cv*X(u+1,v+1)*cos( ((2*i+1)*u*pi)/(2*N))*cos( ((2*j+1)*v*pi)/(2*N)); end end end end xi+128 % quantization for i = 0:N-1 for j = 0:N-1 Xq(i+1,j+1) = round( X(i+1, j+1)/Q(i+1,j+1)); end end Xq;
Go to most recent revision | Compare with Previous | Blame | View Log