1 /********************************************************************
3 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
5 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
9 * by the XIPHOPHORUS Company http://www.xiph.org/ *
11 ********************************************************************
13 function: window functions
14 last mod: $Id: window.c,v 1.18 2002/10/16 02:43:48 xiphmont Exp $
16 ********************************************************************/
23 float *_vorbis_window(int type, int left){
24 float *ret=_ogg_calloc(left,sizeof(*ret));
29 /* The 'vorbis window' (window 0) is sin(sin(x)*sin(x)*pi*.5) */
33 float x=(i+.5f)/left*M_PI/2.;
49 void _vorbis_apply_window(float *d,float *window[2],long *blocksizes,
56 long ln=blocksizes[lW];
57 long rn=blocksizes[nW];
59 long leftbegin=n/4-ln/4;
60 long leftend=leftbegin+ln/2;
62 long rightbegin=n/2+n/4-rn/4;
63 long rightend=rightbegin+rn/2;
67 for(i=0;i<leftbegin;i++)
70 for(p=0;i<leftend;i++,p++)
73 for(i=rightbegin,p=rn/2-1;i<rightend;i++,p--)