X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=lib%2Fsmallft.c;h=6d528af423dcd8eb205eaccb74c94a7fbfb051b3;hb=018ca26dece618457dd13585cad52941193c4a25;hp=cd423758227d3320cb659ab9bfc3af32e5209911;hpb=dda671b88d0b4a5c156c55baa58940c944b2148f;p=platform%2Fupstream%2Flibvorbis.git diff --git a/lib/smallft.c b/lib/smallft.c index cd42375..6d528af 100644 --- a/lib/smallft.c +++ b/lib/smallft.c @@ -1,8 +1,20 @@ -/****************************************************************** - * CopyPolicy: GNU Public License 2 applies - * Copyright (C) 1998 Monty xiphmont@mit.edu, monty@xiph.org - * - * FFT implementation from OggSquish, minus cosine transforms, +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * + * by the Xiph.Org Foundation http://www.xiph.org/ * + * * + ******************************************************************** + + function: *unnormalized* fft transform + + ********************************************************************/ + +/* FFT implementation from OggSquish, minus cosine transforms, * minus all but radix 2/4 case. In Vorbis we only need this * cut-down version. * @@ -13,18 +25,19 @@ * packing following R_0, I_n, R_1, I_1, R_2, I_2 ... R_n-1, I_n-1, * it follows R_0, R_1, I_1, R_2, I_2 ... R_n-1, I_n-1, I_n like the * FORTRAN version - * - ******************************************************************/ + */ #include #include #include #include "smallft.h" +#include "os.h" +#include "misc.h" -static void drfti1(int n, double *wa, int *ifac){ +static void drfti1(int n, float *wa, int *ifac){ static int ntryh[4] = { 4,2,3,5 }; - static double tpi = 6.28318530717958647692528676655900577; - double arg,argh,argld,fi; + static float tpi = 6.28318530717958648f; + float arg,argh,argld,fi; int ntry=0,i,j=-1; int k1, l1, l2, ib; int ld, ii, ip, is, nq, nr; @@ -77,13 +90,13 @@ static void drfti1(int n, double *wa, int *ifac){ for (j=0;j>1; @@ -391,8 +404,8 @@ L119: } } - ar1=1.; - ai1=0.; + ar1=1.f; + ai1=0.f; t1=0; t2=ipp2*idl1; t3=(ip-1)*idl1; @@ -556,7 +569,7 @@ L119: } } -static void drftf1(int n,double *c,double *ch,double *wa,int *ifac){ +static void drftf1(int n,float *c,float *ch,float *wa,int *ifac){ int i,k1,l1,l2; int na,kh,nf; int ip,iw,ido,idl1,ix2,ix3; @@ -617,12 +630,12 @@ static void drftf1(int n,double *c,double *ch,double *wa,int *ifac){ for(i=0;i>1; ipp2=ip; ipph=(ip+1)>>1; if(idon==1)return; drftf1(l->n,data,l->trigcache,l->trigcache+l->n,l->splitcache); } -void drft_backward(drft_lookup *l,double *data){ +void drft_backward(drft_lookup *l,float *data){ if (l->n==1)return; drftb1(l->n,data,l->trigcache,l->trigcache+l->n,l->splitcache); } void drft_init(drft_lookup *l,int n){ l->n=n; - l->trigcache=calloc(3*n,sizeof(double)); - l->splitcache=calloc(32,sizeof(int)); + l->trigcache=_ogg_calloc(3*n,sizeof(*l->trigcache)); + l->splitcache=_ogg_calloc(32,sizeof(*l->splitcache)); fdrffti(n, l->trigcache, l->splitcache); } void drft_clear(drft_lookup *l){ if(l){ - if(l->trigcache)free(l->trigcache); - if(l->splitcache)free(l->splitcache); - memset(l,0,sizeof(drft_lookup)); + if(l->trigcache)_ogg_free(l->trigcache); + if(l->splitcache)_ogg_free(l->splitcache); + memset(l,0,sizeof(*l)); } }