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.16 2002/01/22 11:59:00 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)*2pi) */
33 float x=(i+.5f)/left*M_PI/2.;
49 void _vorbis_apply_window(float *d,float *window[2],long *blocksizes,
53 long ln=blocksizes[lW];
54 long rn=blocksizes[nW];
56 long leftbegin=n/4-ln/4;
57 long leftend=leftbegin+ln/2;
59 long rightbegin=n/2+n/4-rn/4;
60 long rightend=rightbegin+rn/2;
64 for(i=0;i<leftbegin;i++)
67 for(p=0;i<leftend;i++,p++)
70 for(i=rightbegin,p=rn/2-1;i<rightend;i++,p--)