## AAC IMDCT algorithms

#####
Reply #2 –

Here's described how you can decompose the (i)MDCT into a set of butterflies and a DCT4:

http://www.hydrogenaudio.org/forums/index....showtopic=20449

(the "mdct core transform" I was referring to is actually a type-4 DCT)

A Matlab implemetation for a fast type-4 DCT is following: The length of x *should* be a power of two and *must* be even.

function [ y ] = fastdct4( x )

% make x a real-valued row vector

x = real(x(:))';

% N real values -> N/2 complex values

z = (x(1:2:length(x)) + i*x(length(x):-2:1));

% pre twiddling

z = z .* exp((0.5:2:length(x))./length(x).*(-pi/2).*i);

% FFT

z = fft(z);

% post twiddling

z = z .* exp( (0:(length(z)-1)).*(-pi/length(x)).*i );

% extracting DCT4 coeffs and scaling ...

scale = sqrt(2/length(x));

y = zeros(1,length(x));

y(1:2:length(y)) = real(z) .* scale;

y(2:2:length(y)) = -imag(z(length(z):-1:1)) .* scale;

return;

Seb

edit: i just fixed a "sign bug" for odd coefficients