examples/SFExamples/oggvorbiscodec/src/tremor/window.c

00001 /********************************************************************
00002  *                                                                  *
00003  * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE.   *
00004  *                                                                  *
00005  * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
00006  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
00007  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
00008  *                                                                  *
00009  * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002    *
00010  * BY THE Xiph.Org FOUNDATION http://www.xiph.org/                  *
00011  *                                                                  *
00012  ********************************************************************
00013 
00014  function: window functions
00015 
00016  ********************************************************************/
00017 
00018 #include <stdlib.h>
00019 #include <math.h>
00020 #include "os.h"
00021 #include "misc.h"
00022 #include "window.h"
00023 #include "window_lookup.h"
00024 
00025 const void *_vorbis_window(int type, int left){
00026 
00027   switch(type){
00028   case 0:
00029 
00030     switch(left){
00031     case 32:
00032       return vwin64;
00033     case 64:
00034       return vwin128;
00035     case 128:
00036       return vwin256;
00037     case 256:
00038       return vwin512;
00039     case 512:
00040       return vwin1024;
00041     case 1024:
00042       return vwin2048;
00043     case 2048:
00044       return vwin4096;
00045     case 4096:
00046       return vwin8192;
00047     default:
00048       return(0);
00049     }
00050    
00051   default:
00052     return(0);
00053   }
00054 }
00055 
00056 void _vorbis_apply_window(ogg_int32_t *d,const void *window_p[2],
00057                           long *blocksizes,
00058                           int lW,int W,int nW){
00059   
00060   LOOKUP_T *window[2];
00061   long n=blocksizes[W];
00062   long ln=blocksizes[lW];
00063   long rn=blocksizes[nW];
00064 
00065   long leftbegin=n/4-ln/4;
00066   long leftend=leftbegin+ln/2;
00067 
00068   long rightbegin=n/2+n/4-rn/4;
00069   long rightend=rightbegin+rn/2;
00070   
00071   int i,p;
00072 
00073   window[0]=(const ogg_int32_t*)window_p[0];
00074   window[1]=(const ogg_int32_t*)window_p[1];
00075   
00076   for(i=0;i<leftbegin;i++)
00077     d[i]=0;
00078 
00079   for(p=0;i<leftend;i++,p++)
00080     d[i]=MULT31(d[i],window[lW][p]);
00081 
00082   for(i=rightbegin,p=rn/2-1;i<rightend;i++,p--)
00083     d[i]=MULT31(d[i],window[nW][p]);
00084 
00085   for(;i<n;i++)
00086     d[i]=0;
00087 }

Generated by  doxygen 1.6.2