Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /******************************************************************** |
michael@0 | 2 | * * |
michael@0 | 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * |
michael@0 | 4 | * * |
michael@0 | 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * |
michael@0 | 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * |
michael@0 | 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * |
michael@0 | 8 | * * |
michael@0 | 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * |
michael@0 | 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * |
michael@0 | 11 | * * |
michael@0 | 12 | ******************************************************************** |
michael@0 | 13 | |
michael@0 | 14 | function: window functions |
michael@0 | 15 | |
michael@0 | 16 | ********************************************************************/ |
michael@0 | 17 | |
michael@0 | 18 | #include <stdlib.h> |
michael@0 | 19 | #include <math.h> |
michael@0 | 20 | #include "misc.h" |
michael@0 | 21 | #include "window.h" |
michael@0 | 22 | #include "window_lookup.h" |
michael@0 | 23 | |
michael@0 | 24 | const void *_vorbis_window(int type, int left){ |
michael@0 | 25 | |
michael@0 | 26 | switch(type){ |
michael@0 | 27 | case 0: |
michael@0 | 28 | |
michael@0 | 29 | switch(left){ |
michael@0 | 30 | case 32: |
michael@0 | 31 | return vwin64; |
michael@0 | 32 | case 64: |
michael@0 | 33 | return vwin128; |
michael@0 | 34 | case 128: |
michael@0 | 35 | return vwin256; |
michael@0 | 36 | case 256: |
michael@0 | 37 | return vwin512; |
michael@0 | 38 | case 512: |
michael@0 | 39 | return vwin1024; |
michael@0 | 40 | case 1024: |
michael@0 | 41 | return vwin2048; |
michael@0 | 42 | case 2048: |
michael@0 | 43 | return vwin4096; |
michael@0 | 44 | case 4096: |
michael@0 | 45 | return vwin8192; |
michael@0 | 46 | default: |
michael@0 | 47 | return(0); |
michael@0 | 48 | } |
michael@0 | 49 | break; |
michael@0 | 50 | default: |
michael@0 | 51 | return(0); |
michael@0 | 52 | } |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | void _vorbis_apply_window(ogg_int32_t *d,const void *window_p[2], |
michael@0 | 56 | long *blocksizes, |
michael@0 | 57 | int lW,int W,int nW){ |
michael@0 | 58 | |
michael@0 | 59 | LOOKUP_T *window[2]={window_p[0],window_p[1]}; |
michael@0 | 60 | long n=blocksizes[W]; |
michael@0 | 61 | long ln=blocksizes[lW]; |
michael@0 | 62 | long rn=blocksizes[nW]; |
michael@0 | 63 | |
michael@0 | 64 | long leftbegin=n/4-ln/4; |
michael@0 | 65 | long leftend=leftbegin+ln/2; |
michael@0 | 66 | |
michael@0 | 67 | long rightbegin=n/2+n/4-rn/4; |
michael@0 | 68 | long rightend=rightbegin+rn/2; |
michael@0 | 69 | |
michael@0 | 70 | int i,p; |
michael@0 | 71 | |
michael@0 | 72 | for(i=0;i<leftbegin;i++) |
michael@0 | 73 | d[i]=0; |
michael@0 | 74 | |
michael@0 | 75 | for(p=0;i<leftend;i++,p++) |
michael@0 | 76 | d[i]=MULT31(d[i],window[lW][p]); |
michael@0 | 77 | |
michael@0 | 78 | for(i=rightbegin,p=rn/2-1;i<rightend;i++,p--) |
michael@0 | 79 | d[i]=MULT31(d[i],window[nW][p]); |
michael@0 | 80 | |
michael@0 | 81 | for(;i<n;i++) |
michael@0 | 82 | d[i]=0; |
michael@0 | 83 | } |