1  /********************************************************************** <BR>


2  This file is part of Crack dot Com's free source code release of


3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for


4  information about compiling & licensing issues visit this URL</a>


5  <PRE> If that doesn't help, contact Jonathan Clark at


6  golgotha_source@usa.net (Subject should have "GOLG" in it)


7  ***********************************************************************/


8 


9 


10  /*


11  * Discrete Cosine Tansform (DCT) for subband synthesis


12  *


13  * funrollloops (for gcc) will remove the loops for better performance


14  * using loops in the sourcecode enhances readabillity


15  */


16 


17  /*


18  * TODO: write an optimized version for the downsampling modes


19  * (in these modes the bands 1631 (2:1) or 831 (4:1) are zero


20  */


21 


22  #include "loaders/mp3/mpg123.hh"


23 


24  void dct64(real *out0,real *out1,real *samples)


25  {


26  real bufs[64];


27 


28  {


29  register int i,j;


30  register real *b1,*b2,*bs,*costab;


31 


32  b1 = samples;


33  bs = bufs;


34  costab = pnts[0]+16;


35  b2 = b1 + 32;


36 


37  for(i=15;i>=0;i)


38  *bs++ = (*b1++ + *b2);


39  for(i=15;i>=0;i)


40  *bs++ = (*b2  *b1++) * *costab;


41 


42  b1 = bufs;


43  costab = pnts[1]+8;


44  b2 = b1 + 16;


45 


46  {


47  for(i=7;i>=0;i)


48  *bs++ = (*b1++ + *b2);


49  for(i=7;i>=0;i)


50  *bs++ = (*b2  *b1++) * *costab;


51  b2 += 32;


52  costab += 8;


53  for(i=7;i>=0;i)


54  *bs++ = (*b1++ + *b2);


55  for(i=7;i>=0;i)


56  *bs++ = (*b1++  *b2) * *costab;


57  b2 += 32;


58  }


59 


60  bs = bufs;


61  costab = pnts[2];


62  b2 = b1 + 8;


63 


64  for(j=2;j;j)


65  {


66  for(i=3;i>=0;i)


67  *bs++ = (*b1++ + *b2);


68  for(i=3;i>=0;i)


69  *bs++ = (*b2  *b1++) * costab[i];


70  b2 += 16;


71  for(i=3;i>=0;i)


72  *bs++ = (*b1++ + *b2);


73  for(i=3;i>=0;i)


74  *bs++ = (*b1++  *b2) * costab[i];


75  b2 += 16;


76  }


77 


78  b1 = bufs;


79  costab = pnts[3];


80  b2 = b1 + 4;


81 


82  for(j=4;j;j)


83  {


84  *bs++ = (*b1++ + *b2);


85  *bs++ = (*b1++ + *b2);


86  *bs++ = (*b2  *b1++) * costab[1];


87  *bs++ = (*b2  *b1++) * costab[0];


88  b2 += 8;


89  *bs++ = (*b1++ + *b2);


90  *bs++ = (*b1++ + *b2);


91  *bs++ = (*b1++  *b2) * costab[1];


92  *bs++ = (*b1++  *b2) * costab[0];


93  b2 += 8;


94  }


95  bs = bufs;


96  costab = pnts[4];


97 


98  for(j=8;j;j)


99  {


100  real v0,v1;


101  v0=*b1++; v1 = *b1++;


102  *bs++ = (v0 + v1);


103  *bs++ = (v0  v1) * (*costab);


104  v0=*b1++; v1 = *b1++;


105  *bs++ = (v0 + v1);


106  *bs++ = (v1  v0) * (*costab);


107  }


108 


109  }


110 


111 


112  {


113  register real *b1;


114  register int i;


115 


116  for(b1=bufs,i=8;i;i,b1+=4)


117  b1[2] += b1[3];


118 


119  for(b1=bufs,i=4;i;i,b1+=8)


120  {


121  b1[4] += b1[6];


122  b1[6] += b1[5];


123  b1[5] += b1[7];


124  }


125 


126  for(b1=bufs,i=2;i;i,b1+=16)


127  {


128  b1[8] += b1[12];


129  b1[12] += b1[10];


130  b1[10] += b1[14];


131  b1[14] += b1[9];


132  b1[9] += b1[13];


133  b1[13] += b1[11];


134  b1[11] += b1[15];


135  }


136  }


137 


138 


139  out0[0x10*16] = bufs[0];


140  out0[0x10*15] = bufs[16+0] + bufs[16+8];


141  out0[0x10*14] = bufs[8];


142  out0[0x10*13] = bufs[16+8] + bufs[16+4];


143  out0[0x10*12] = bufs[4];


144  out0[0x10*11] = bufs[16+4] + bufs[16+12];


145  out0[0x10*10] = bufs[12];


146  out0[0x10* 9] = bufs[16+12] + bufs[16+2];


147  out0[0x10* 8] = bufs[2];


148  out0[0x10* 7] = bufs[16+2] + bufs[16+10];


149  out0[0x10* 6] = bufs[10];


150  out0[0x10* 5] = bufs[16+10] + bufs[16+6];


151  out0[0x10* 4] = bufs[6];


152  out0[0x10* 3] = bufs[16+6] + bufs[16+14];


153  out0[0x10* 2] = bufs[14];


154  out0[0x10* 1] = bufs[16+14] + bufs[16+1];


155  out0[0x10* 0] = bufs[1];


156 


157  out1[0x10* 0] = bufs[1];


158  out1[0x10* 1] = bufs[16+1] + bufs[16+9];


159  out1[0x10* 2] = bufs[9];


160  out1[0x10* 3] = bufs[16+9] + bufs[16+5];


161  out1[0x10* 4] = bufs[5];


162  out1[0x10* 5] = bufs[16+5] + bufs[16+13];


163  out1[0x10* 6] = bufs[13];


164  out1[0x10* 7] = bufs[16+13] + bufs[16+3];


165  out1[0x10* 8] = bufs[3];


166  out1[0x10* 9] = bufs[16+3] + bufs[16+11];


167  out1[0x10*10] = bufs[11];


168  out1[0x10*11] = bufs[16+11] + bufs[16+7];


169  out1[0x10*12] = bufs[7];


170  out1[0x10*13] = bufs[16+7] + bufs[16+15];


171  out1[0x10*14] = bufs[15];


172  out1[0x10*15] = bufs[16+15];


173 


174  }


175 


176 

