typo fix
[mplayer/greg.git] / tremor / window.c
blob4d6e79e81d3f2f954ec1ba307252100004be7f2b
1 /********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
14 function: window functions
16 ********************************************************************/
18 #include <stdlib.h>
19 #include <math.h>
20 #include "os.h"
21 #include "misc.h"
22 #include "window.h"
23 #include "window_lookup.h"
25 const void *_vorbis_window(int type, int left){
27 switch(type){
28 case 0:
30 switch(left){
31 case 32:
32 return vwin64;
33 case 64:
34 return vwin128;
35 case 128:
36 return vwin256;
37 case 256:
38 return vwin512;
39 case 512:
40 return vwin1024;
41 case 1024:
42 return vwin2048;
43 case 2048:
44 return vwin4096;
45 case 4096:
46 return vwin8192;
47 default:
48 return(0);
50 break;
51 default:
52 return(0);
56 void _vorbis_apply_window(ogg_int32_t *d,const void *window_p[2],
57 long *blocksizes,
58 int lW,int W,int nW){
60 LOOKUP_T *window[2]={window_p[0],window_p[1]};
61 long n=blocksizes[W];
62 long ln=blocksizes[lW];
63 long rn=blocksizes[nW];
65 long leftbegin=n/4-ln/4;
66 long leftend=leftbegin+ln/2;
68 long rightbegin=n/2+n/4-rn/4;
69 long rightend=rightbegin+rn/2;
71 int i,p;
73 for(i=0;i<leftbegin;i++)
74 d[i]=0;
76 for(p=0;i<leftend;i++,p++)
77 d[i]=MULT31(d[i],window[lW][p]);
79 for(i=rightbegin,p=rn/2-1;i<rightend;i++,p--)
80 d[i]=MULT31(d[i],window[nW][p]);
82 for(;i<n;i++)
83 d[i]=0;