configure: simplify some checks
[mplayer/greg.git] / tremor / window.c
blobcc92f979acb223d6ecb37fdf715d7bce5a4386f8
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;