/********************************************************************
* *
* THIS FILE IS PART OF THE OggSQUISH SOFTWARE CODEC SOURCE CODE. *
* *
********************************************************************
> From xiphmont@MIT.EDU Tue Jun 3 14:50:15 1997
> Subject: Re: fft.c
> Date: Tue, 03 Jun 1997 14:50:11 EDT
> From: Monty
>
> The include files are not really necessary; they define a few macros
> depending on the compiler in use (eg, STIN becomes one of "static" or
> "static inline") and the prototypes for the functions in fft.c. You
> should be able to compile and use the code without the headers with
> minimal modification. The C code behaves nearly identically to the
> fortran code; inspection of the code should clarify the differences
> (eg, the 'ifac' argument). Let me know if you need any other help
> with the code.
>
> Monty
file: fft.c
function: Fast discrete Fourier and cosine transforms and inverses
author: Monty
modifications by: Monty
last modification date: Jul 1 1996
********************************************************************/
/* These Fourier routines were originally based on the Fourier
routines of the same names from the NETLIB bihar and fftpack
fortran libraries developed by Paul N. Swarztrauber at the National
Center for Atmospheric Research in Boulder, CO USA. They have been
reimplemented in C and optimized in a few ways for OggSquish. */
/* As the original fortran libraries are public domain, the C Fourier
routines in this file are hereby released to the public domain as
well. The C routines here produce output exactly equivalent to the
original fortran routines. Of particular interest are the facts
that (like the original fortran), these routines can work on
arbitrary length vectors that need not be powers of two in
length. */
#include
#include "ogg.h"
#include "fft.h"
static void drfti1(int n, float *wa, int *ifac){
static int ntryh[4] = { 4,2,3,5 };
static float tpi = 6.28318530717958647692528676655900577;
float arg,argh,argld,fi;
int ntry=0,i,j=-1;
int k1, l1, l2, ib;
int ld, ii, ip, is, nq, nr;
int ido, ipm, nfm1;
int nl=n;
int nf=0;
L101:
j++;
if (j < 4)
ntry=ntryh[j];
else
ntry+=2;
L104:
nq=nl/ntry;
nr=nl-ntry*nq;
if (nr!=0) goto L101;
nf++;
ifac[nf+1]=ntry;
nl=nq;
if(ntry!=2)goto L107;
if(nf==1)goto L107;
for (i=1;i>1;
ipp2=ip;
idp2=ido;
nbd=(ido-1)>>1;
t0=l1*ido;
t10=ip*ido;
if(ido==1)goto L119;
for(ik=0;ikl1){
for(j=1;j>1;
np2=n;
kc=np2;
for(k=1;k>1;
ipp2=ip;
ipph=(ip+1)>>1;
if(idol1)goto L139;
is= -ido-1;
t1=0;
for(j=1;j>1;
np2=n;
for(i=2;i