void inverse_mdct_slow(float *buffer, int n)
{
=A0=A0 int i,j;
=A0=A0 int n2 =3D n >> 1;
=A0=A0 float *x =3D (float *) malloc(sizeof(*x) * n2);
=A0=A0 memcpy(x, buffer, sizeof(*x) * n2);
=A0=A0 for (i=3D0; i < n; ++i) {
=A0=A0=A0=A0=A0 float acc =3D 0;
=A0=A0=A0=A0=A0 for (j=3D0; j < n2; ++j)
=A0=A0=A0=A0=A0=A0=A0=A0 // formula from paper:
=A0=A0=A0=A0=A0=A0=A0=A0 //acc +=3D n/4.0f * x[j] * (float) cos(M_PI / 2 / n *
(2 * i + 1 + n/2.0)*(2*j+1));
=A0=A0=A0=A0=A0=A0=A0=A0 // formula from wikipedia
=A0=A0=A0=A0=A0=A0=A0=A0 //acc +=3D 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i
+ 0.5 + n2/2)*(j + 0.5));
=A0=A0=A0=A0=A0=A0=A0=A0 // these are equivalent, except the formula from the
paper inverts the multiplier!
=A0=A0=A0=A0=A0=A0=A0=A0 // however, what actually works is NO MULTIPLIER!?!
=A0=A0=A0=A0=A0=A0=A0=A0 //acc +=3D 64 * 2.0f / n2 * x[j] * (float) cos(M_PI/n2
* (i + 0.5 + n2/2)*(j + 0.5));
=A0=A0=A0=A0=A0=A0=A0=A0 acc +=3D x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 +
n/2.0)*(2*j+1));
=A0=A0=A0=A0=A0 buffer[i] =3D acc;
=A0=A0 }
=A0=A0 free(x);
}
Thanks
Liam Wilson
--0-226214673-1312203902=:12407
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
<table cellspacing=3D"0" cellpadding=3D"0"
border=3D"0" ><tr><td valign=3D"top"
style=3D"font: inherit;">Hi<br><br>The inverse MDCT
formula seems to be missing from the vorbis specification. From reading the
source code of stb_vorbis (http://nothings.org/stb_vorbis/) I've a good idea
of what it might be, but cannot find the formula anywhere in the official
specification (the one on http://xiph.org/vorbis/doc/Vorbis_I_spec.html ). I
also understand that the formula stated in the eusipco_corrected.ps paper is
incorrect (the link from the specification to the paper is also
dead).<br><br>From the stb_vorbis.c source:<br><br>void
inverse_mdct_slow(float *buffer, int n)<br>{<br>
int i,j;<br> int n2 =3D n >>
1;<br> float *x =3D (float *) malloc(sizeof(*x) *
n2);<br> memcpy(x, buffer, sizeof(*x) *
n2);<br> for (i=3D0; i < n; ++i)
{<br> float acc =3D
0;<br> for (j=3D0; j
< n2;
++j)<br>
// formula from
paper:<br>
//acc +=3D n/4.0f * x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 +
n/2.0)*(2*j+1));<br>
// formula from
wikipedia<br>
//acc +=3D 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j +
0.5));<br>
// these are equivalent, except the formula from the paper inverts the
multiplier!<br>
// however, what actually works is NO
MULTIPLIER!?!<br>
//acc +=3D 64 * 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j +
0.5));<br>
acc +=3D x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 +
n/2.0)*(2*j+1));<br>
buffer[i] =3D acc;<br> }<br>
free(x);<br>}<br><br>Thanks<br>Liam Wilson<span
style=3D"text-decoration: underline;"></span><a
href=3D"http://www.iocon.com/resource/docs/ps/eusipco_corrected.ps"
class=3D"url"><span
class=3D"cmtt-12"></span></a></td></tr></table>
--0-226214673-1312203902=:12407--