[Ffmpeg-devel] ac3 encoder

Justin Ruggles jruggle
Wed Apr 20 04:00:57 CEST 2005


Benjamin Larsson wrote:

> Hi,
>
> Justin Ruggles wrote:
>
>> I've made an attempt at block switching, but can't figure out how to 
>> get the short-block mdct to work with fft, so right now it's 
>> extremely slow doing it the O(n^2) way.
>
> Contact me in private or post some example code to the list and I 
> might be able to help with the mdct code.
>
Hello,
Thanks for offering to help.  What I'm running into is that the mdct in 
the AC3 specification adds some additional stuff at the end that makes 
it different from a standard mdct for 256-sample windows.  My math 
skills only got me so far.  The best I could figure, instead of doing a 
1/4 rotation, you do no rotation for the 1st 256 samples and a 1/2 
rotation for the 2nd 256.  I kinda got lost in how (if at all) it 
affects the FFT and post-rotation.  The equation in the AC3 spec will 
probably make it a bit clearer.  I'll try to write it out in text as 
best I can.

where N=512 for long transform and N=256 for short transform.  Let x[n] 
represent the windowed input time sequence.  The output frequency 
sequence, X[k] is defined by:

X[k] = -2/N * SUM(n=0 to N-1){ x[n] * 
cos(2pi/4N(2n+1)(2k+1)+pi/4(2k+1)(1+alpha) }
for 0 <= k < N/2
where alpha = 0 for long transform, -1 for 1st short transform, +1 for 
2nd short transform

So, for the long transform, the equation is just a regular mdct, but 
when you change the last value to 0 or 2, you get something a little 
different, and I can't work out how to convert that to using FFT.  I 
might just be missing something simple, but I'm stumped.  I would 
greatly appreciate any help I can get.

Thanks,
Justin





More information about the ffmpeg-devel mailing list