No subject
Sun Jun 6 23:52:00 PDT 2010
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 t=
he 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_P=
I/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 b=
e missing from the vorbis specification. From reading the source code of st=
b_vorbis (http://nothings.org/stb_vorbis/) I've a good idea of what it migh=
t be, but cannot find the formula anywhere in the official specification (t=
he one on http://xiph.org/vorbis/doc/Vorbis_I_spec.html ). I also understan=
d that the formula stated in the eusipco_corrected.ps paper is incorrect (t=
he 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>&nb=
sp; float *x =3D (float *) malloc(sizeof(*x) * n2);<br> m=
emcpy(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] * (floa=
t) cos(M_PI / 2 / n * (2 * i + 1 + n/2.0)*(2*j+1));<br> &n=
bsp; // 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> &nbs=
p; // these are equivalent, except the formula from the paper i=
nverts the multiplier!<br> =
// however, what actually works is NO MULTIPLIER!?!<br> &n=
bsp; //acc +=3D 64 * 2.0f / n2 * x[j] * (float) cos=
(M_PI/n2 * (i + 0.5 + n2/2)*(j + 0.5));<br> &n=
bsp; 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>&=
nbsp; }<br> free(x);<br>}<br><br>Thanks<br>Liam Wilson<sp=
an 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"cm=
tt-12"></span></a></td></tr></table>
--0-226214673-1312203902=:12407--
More information about the Vorbis-dev
mailing list