Help - Search - Members - Calendar
Full Version: Question about MDCT pre/post rotation
Hydrogenaudio Forums > Hydrogenaudio Forum > Scientific/R&D Discussion
Mike Giacomelli
Going over the ffmpeg MDCT code, I noticed that the phase of each sin and cos term has a constant added to it.

QUOTE


/**
* init MDCT or IMDCT computation.
*/
int ff_mdct_init(MDCTContext *s, int nbits, int inverse)
{
int n, n4, i;
float alpha;

memset(s, 0, sizeof(*s));
n = 1 << nbits;
s->nbits = nbits;
s->n = n;
n4 = n >> 2;
s->tcos = av_malloc(n4 * sizeof(FFTSample));
if (!s->tcos)
goto fail;
s->tsin = av_malloc(n4 * sizeof(FFTSample));
if (!s->tsin)
goto fail;

for(i=0;i<n4;i++) {
alpha = 2 * M_PI * (i + 1 / 8.0) / n;
s->tcos[i] = -cos(alpha);
s->tsin[i] = -sin(alpha);
}



http://svn.mplayerhq.hu/ffmpeg/trunk/libav...t.c?view=markup

The bolded line is what I don't understand. Why is the constant 0.125 added to each phase term ? It seems to advance the phase by 2*pi divided by 8 times the block size, but i have no idea why.
Mike Giacomelli
I looked into this a little more, and FAAD also uses the 1/8 phase constant it for it's MDCT computation. I've tried decoding a file with the constant removed and I couldn't hear a difference (though the values changed in the last 3 or so bits).

Anyone know why its there?
Mike Giacomelli
Maybe that question was too specific. Could someone provide me with a good reference on the MDCT so I can determine the answer myself?
Woodinville
QUOTE(Mike Giacomelli @ Jul 10 2007, 07:56) *

Maybe that question was too specific. Could someone provide me with a good reference on the MDCT so I can determine the answer myself?


Malvar's book on Transforms.
jido
QUOTE(Mike Giacomelli @ Jul 9 2007, 06:25) *

I looked into this a little more, and FAAD also uses the 1/8 phase constant it for it's MDCT computation. I've tried decoding a file with the constant removed and I couldn't hear a difference (though the values changed in the last 3 or so bits).

Anyone know why its there?

Just a guess, but do you get an error for some input data with the constant removed? Like division by zero or such...
mc calculust
QUOTE(Mike Giacomelli @ Jul 8 2007, 17:52) *

Going over the ffmpeg MDCT code, I noticed that the phase of each sin and cos term has a constant added to it.

QUOTE


/**
* init MDCT or IMDCT computation.
*/
int ff_mdct_init(MDCTContext *s, int nbits, int inverse)
{
int n, n4, i;
float alpha;

memset(s, 0, sizeof(*s));
n = 1 << nbits;
s->nbits = nbits;
s->n = n;
n4 = n >> 2;
s->tcos = av_malloc(n4 * sizeof(FFTSample));
if (!s->tcos)
goto fail;
s->tsin = av_malloc(n4 * sizeof(FFTSample));
if (!s->tsin)
goto fail;

for(i=0;i<n4;i++) {
alpha = 2 * M_PI * (i + 1 / 8.0) / n;
s->tcos[i] = -cos(alpha);
s->tsin[i] = -sin(alpha);
}



http://svn.mplayerhq.hu/ffmpeg/trunk/libav...t.c?view=markup

The bolded line is what I don't understand. Why is the constant 0.125 added to each phase term ? It seems to advance the phase by 2*pi divided by 8 times the block size, but i have no idea why.


The answer to this is probably really detailed mathematically. I would guess that it is the phase term used for Time Domain Aliasing Cancellation. The derivation of the fast MDCT can get really complicated, so it's hard to say!
Garf
There is a derivation in:

P. Duhamel, Y. Mahieux, and J. Petit, “A Fast Algorithm For
The Implementation Of Filterbanks Based On “Time Domain Aliasing
Cancellation””, Proceedings of the IEEE International Conference on
Acoustics, Speech, and Signal Processing, pp. 2209–2212, May 1991.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.