FS#8961 - Anti-Aliased Fonts.
[kugel-rb/myfork.git] / apps / codecs / libtremor / window.c
blob7b4888693910dcc8351d5ec3da2a9b0fc3d57c28
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 "config-tremor.h"
19 #include <string.h>
20 #include <math.h>
21 #include "os.h"
22 #include "misc.h"
23 #include "window.h"
24 #include "window_lookup.h"
26 const void *_vorbis_window(int type, int left){
28 switch(type){
29 case 0:
31 switch(left){
32 case 32:
33 return vwin64;
34 case 64:
35 return vwin128;
36 case 128:
37 return vwin256;
38 case 256:
39 return vwin512;
40 case 512:
41 return vwin1024;
42 case 1024:
43 return vwin2048;
44 case 2048:
45 return vwin4096;
46 case 4096:
47 return vwin8192;
48 default:
49 return(0);
51 break;
52 default:
53 return(0);
57 void _vorbis_apply_window(ogg_int32_t *d,const void *window_p[2],
58 long *blocksizes,
59 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 /* Following memset is not required - we are careful to only overlap/add the
72 regions that geniunely overlap in the window region, and the portions
73 outside that region are not added (so don't need to be zerod). see block.c
74 memset((void *)&d[0], 0, sizeof(ogg_int32_t)*leftbegin); */
76 vect_mult_fw(&d[leftbegin], &window[lW][0], leftend-leftbegin);
77 vect_mult_bw(&d[rightbegin], &window[nW][rn/2-1], rightend-rightbegin);
79 /* Again - memset not needed
80 memset((void *)&d[rightend], 0, sizeof(ogg_int32_t)*(n-rightend)); */