dct64.c
上传用户:yisoukefu
上传日期:2020-08-09
资源大小:39506k
文件大小:10k
源码类别:

其他游戏

开发平台:

Visual C++

  1. /*
  2.  * Modified for use with MPlayer, for details see the changelog at
  3.  * http://svn.mplayerhq.hu/mplayer/trunk/
  4.  * $Id: dct64.c 18786 2006-06-22 13:34:00Z diego $
  5.  */
  6. /*
  7.  * Discrete Cosine Tansform (DCT) for subband synthesis
  8.  * optimized for machines with no auto-increment.
  9.  * The performance is highly compiler dependend. Maybe
  10.  * the dct64.c version for 'normal' processor may be faster
  11.  * even for Intel processors.
  12.  */
  13. static void dct64_1(real *out0,real *out1,real *b1,real *b2,real *samples)
  14. {
  15.  {
  16.   register real *costab = mp3lib_pnts[0];
  17.   b1[0x00] = samples[0x00] + samples[0x1F];
  18.   b1[0x1F] = (samples[0x00] - samples[0x1F]) * costab[0x0];
  19.   b1[0x01] = samples[0x01] + samples[0x1E];
  20.   b1[0x1E] = (samples[0x01] - samples[0x1E]) * costab[0x1];
  21.   b1[0x02] = samples[0x02] + samples[0x1D];
  22.   b1[0x1D] = (samples[0x02] - samples[0x1D]) * costab[0x2];
  23.   b1[0x03] = samples[0x03] + samples[0x1C];
  24.   b1[0x1C] = (samples[0x03] - samples[0x1C]) * costab[0x3];
  25.   b1[0x04] = samples[0x04] + samples[0x1B];
  26.   b1[0x1B] = (samples[0x04] - samples[0x1B]) * costab[0x4];
  27.   b1[0x05] = samples[0x05] + samples[0x1A];
  28.   b1[0x1A] = (samples[0x05] - samples[0x1A]) * costab[0x5];
  29.   b1[0x06] = samples[0x06] + samples[0x19];
  30.   b1[0x19] = (samples[0x06] - samples[0x19]) * costab[0x6];
  31.   b1[0x07] = samples[0x07] + samples[0x18];
  32.   b1[0x18] = (samples[0x07] - samples[0x18]) * costab[0x7];
  33.   b1[0x08] = samples[0x08] + samples[0x17];
  34.   b1[0x17] = (samples[0x08] - samples[0x17]) * costab[0x8];
  35.   b1[0x09] = samples[0x09] + samples[0x16];
  36.   b1[0x16] = (samples[0x09] - samples[0x16]) * costab[0x9];
  37.   b1[0x0A] = samples[0x0A] + samples[0x15];
  38.   b1[0x15] = (samples[0x0A] - samples[0x15]) * costab[0xA];
  39.   b1[0x0B] = samples[0x0B] + samples[0x14];
  40.   b1[0x14] = (samples[0x0B] - samples[0x14]) * costab[0xB];
  41.   b1[0x0C] = samples[0x0C] + samples[0x13];
  42.   b1[0x13] = (samples[0x0C] - samples[0x13]) * costab[0xC];
  43.   b1[0x0D] = samples[0x0D] + samples[0x12];
  44.   b1[0x12] = (samples[0x0D] - samples[0x12]) * costab[0xD];
  45.   b1[0x0E] = samples[0x0E] + samples[0x11];
  46.   b1[0x11] = (samples[0x0E] - samples[0x11]) * costab[0xE];
  47.   b1[0x0F] = samples[0x0F] + samples[0x10];
  48.   b1[0x10] = (samples[0x0F] - samples[0x10]) * costab[0xF];
  49.  }
  50.  {
  51.   register real *costab = mp3lib_pnts[1];
  52.   b2[0x00] = b1[0x00] + b1[0x0F];
  53.   b2[0x0F] = (b1[0x00] - b1[0x0F]) * costab[0];
  54.   b2[0x01] = b1[0x01] + b1[0x0E];
  55.   b2[0x0E] = (b1[0x01] - b1[0x0E]) * costab[1];
  56.   b2[0x02] = b1[0x02] + b1[0x0D];
  57.   b2[0x0D] = (b1[0x02] - b1[0x0D]) * costab[2];
  58.   b2[0x03] = b1[0x03] + b1[0x0C];
  59.   b2[0x0C] = (b1[0x03] - b1[0x0C]) * costab[3];
  60.   b2[0x04] = b1[0x04] + b1[0x0B];
  61.   b2[0x0B] = (b1[0x04] - b1[0x0B]) * costab[4];
  62.   b2[0x05] = b1[0x05] + b1[0x0A];
  63.   b2[0x0A] = (b1[0x05] - b1[0x0A]) * costab[5];
  64.   b2[0x06] = b1[0x06] + b1[0x09];
  65.   b2[0x09] = (b1[0x06] - b1[0x09]) * costab[6];
  66.   b2[0x07] = b1[0x07] + b1[0x08];
  67.   b2[0x08] = (b1[0x07] - b1[0x08]) * costab[7];
  68.   b2[0x10] = b1[0x10] + b1[0x1F];
  69.   b2[0x1F] = (b1[0x1F] - b1[0x10]) * costab[0];
  70.   b2[0x11] = b1[0x11] + b1[0x1E];
  71.   b2[0x1E] = (b1[0x1E] - b1[0x11]) * costab[1];
  72.   b2[0x12] = b1[0x12] + b1[0x1D];
  73.   b2[0x1D] = (b1[0x1D] - b1[0x12]) * costab[2];
  74.   b2[0x13] = b1[0x13] + b1[0x1C];
  75.   b2[0x1C] = (b1[0x1C] - b1[0x13]) * costab[3];
  76.   b2[0x14] = b1[0x14] + b1[0x1B];
  77.   b2[0x1B] = (b1[0x1B] - b1[0x14]) * costab[4];
  78.   b2[0x15] = b1[0x15] + b1[0x1A];
  79.   b2[0x1A] = (b1[0x1A] - b1[0x15]) * costab[5];
  80.   b2[0x16] = b1[0x16] + b1[0x19];
  81.   b2[0x19] = (b1[0x19] - b1[0x16]) * costab[6];
  82.   b2[0x17] = b1[0x17] + b1[0x18];
  83.   b2[0x18] = (b1[0x18] - b1[0x17]) * costab[7];
  84.  }
  85.  {
  86.   register real *costab = mp3lib_pnts[2];
  87.   b1[0x00] = b2[0x00] + b2[0x07];
  88.   b1[0x07] = (b2[0x00] - b2[0x07]) * costab[0];
  89.   b1[0x01] = b2[0x01] + b2[0x06];
  90.   b1[0x06] = (b2[0x01] - b2[0x06]) * costab[1];
  91.   b1[0x02] = b2[0x02] + b2[0x05];
  92.   b1[0x05] = (b2[0x02] - b2[0x05]) * costab[2];
  93.   b1[0x03] = b2[0x03] + b2[0x04];
  94.   b1[0x04] = (b2[0x03] - b2[0x04]) * costab[3];
  95.   b1[0x08] = b2[0x08] + b2[0x0F];
  96.   b1[0x0F] = (b2[0x0F] - b2[0x08]) * costab[0];
  97.   b1[0x09] = b2[0x09] + b2[0x0E];
  98.   b1[0x0E] = (b2[0x0E] - b2[0x09]) * costab[1];
  99.   b1[0x0A] = b2[0x0A] + b2[0x0D];
  100.   b1[0x0D] = (b2[0x0D] - b2[0x0A]) * costab[2];
  101.   b1[0x0B] = b2[0x0B] + b2[0x0C];
  102.   b1[0x0C] = (b2[0x0C] - b2[0x0B]) * costab[3];
  103.   b1[0x10] = b2[0x10] + b2[0x17];
  104.   b1[0x17] = (b2[0x10] - b2[0x17]) * costab[0];
  105.   b1[0x11] = b2[0x11] + b2[0x16];
  106.   b1[0x16] = (b2[0x11] - b2[0x16]) * costab[1];
  107.   b1[0x12] = b2[0x12] + b2[0x15];
  108.   b1[0x15] = (b2[0x12] - b2[0x15]) * costab[2];
  109.   b1[0x13] = b2[0x13] + b2[0x14];
  110.   b1[0x14] = (b2[0x13] - b2[0x14]) * costab[3];
  111.   b1[0x18] = b2[0x18] + b2[0x1F];
  112.   b1[0x1F] = (b2[0x1F] - b2[0x18]) * costab[0];
  113.   b1[0x19] = b2[0x19] + b2[0x1E];
  114.   b1[0x1E] = (b2[0x1E] - b2[0x19]) * costab[1];
  115.   b1[0x1A] = b2[0x1A] + b2[0x1D];
  116.   b1[0x1D] = (b2[0x1D] - b2[0x1A]) * costab[2];
  117.   b1[0x1B] = b2[0x1B] + b2[0x1C];
  118.   b1[0x1C] = (b2[0x1C] - b2[0x1B]) * costab[3];
  119.  }
  120.  {
  121.   register real const cos0 = mp3lib_pnts[3][0];
  122.   register real const cos1 = mp3lib_pnts[3][1];
  123.   b2[0x00] = b1[0x00] + b1[0x03];
  124.   b2[0x03] = (b1[0x00] - b1[0x03]) * cos0;
  125.   b2[0x01] = b1[0x01] + b1[0x02];
  126.   b2[0x02] = (b1[0x01] - b1[0x02]) * cos1;
  127.   b2[0x04] = b1[0x04] + b1[0x07];
  128.   b2[0x07] = (b1[0x07] - b1[0x04]) * cos0;
  129.   b2[0x05] = b1[0x05] + b1[0x06];
  130.   b2[0x06] = (b1[0x06] - b1[0x05]) * cos1;
  131.   b2[0x08] = b1[0x08] + b1[0x0B];
  132.   b2[0x0B] = (b1[0x08] - b1[0x0B]) * cos0;
  133.   b2[0x09] = b1[0x09] + b1[0x0A];
  134.   b2[0x0A] = (b1[0x09] - b1[0x0A]) * cos1;
  135.   b2[0x0C] = b1[0x0C] + b1[0x0F];
  136.   b2[0x0F] = (b1[0x0F] - b1[0x0C]) * cos0;
  137.   b2[0x0D] = b1[0x0D] + b1[0x0E];
  138.   b2[0x0E] = (b1[0x0E] - b1[0x0D]) * cos1;
  139.   b2[0x10] = b1[0x10] + b1[0x13];
  140.   b2[0x13] = (b1[0x10] - b1[0x13]) * cos0;
  141.   b2[0x11] = b1[0x11] + b1[0x12];
  142.   b2[0x12] = (b1[0x11] - b1[0x12]) * cos1;
  143.   b2[0x14] = b1[0x14] + b1[0x17];
  144.   b2[0x17] = (b1[0x17] - b1[0x14]) * cos0;
  145.   b2[0x15] = b1[0x15] + b1[0x16];
  146.   b2[0x16] = (b1[0x16] - b1[0x15]) * cos1;
  147.   b2[0x18] = b1[0x18] + b1[0x1B];
  148.   b2[0x1B] = (b1[0x18] - b1[0x1B]) * cos0;
  149.   b2[0x19] = b1[0x19] + b1[0x1A];
  150.   b2[0x1A] = (b1[0x19] - b1[0x1A]) * cos1;
  151.   b2[0x1C] = b1[0x1C] + b1[0x1F];
  152.   b2[0x1F] = (b1[0x1F] - b1[0x1C]) * cos0;
  153.   b2[0x1D] = b1[0x1D] + b1[0x1E];
  154.   b2[0x1E] = (b1[0x1E] - b1[0x1D]) * cos1;
  155.  }
  156.  {
  157.   register real const cos0 = mp3lib_pnts[4][0];
  158.   b1[0x00] = b2[0x00] + b2[0x01];
  159.   b1[0x01] = (b2[0x00] - b2[0x01]) * cos0;
  160.   b1[0x02] = b2[0x02] + b2[0x03];
  161.   b1[0x03] = (b2[0x03] - b2[0x02]) * cos0;
  162.   b1[0x02] += b1[0x03];
  163.   b1[0x04] = b2[0x04] + b2[0x05];
  164.   b1[0x05] = (b2[0x04] - b2[0x05]) * cos0;
  165.   b1[0x06] = b2[0x06] + b2[0x07];
  166.   b1[0x07] = (b2[0x07] - b2[0x06]) * cos0;
  167.   b1[0x06] += b1[0x07];
  168.   b1[0x04] += b1[0x06];
  169.   b1[0x06] += b1[0x05];
  170.   b1[0x05] += b1[0x07];
  171.   b1[0x08] = b2[0x08] + b2[0x09];
  172.   b1[0x09] = (b2[0x08] - b2[0x09]) * cos0;
  173.   b1[0x0A] = b2[0x0A] + b2[0x0B];
  174.   b1[0x0B] = (b2[0x0B] - b2[0x0A]) * cos0;
  175.   b1[0x0A] += b1[0x0B];
  176.   b1[0x0C] = b2[0x0C] + b2[0x0D];
  177.   b1[0x0D] = (b2[0x0C] - b2[0x0D]) * cos0;
  178.   b1[0x0E] = b2[0x0E] + b2[0x0F];
  179.   b1[0x0F] = (b2[0x0F] - b2[0x0E]) * cos0;
  180.   b1[0x0E] += b1[0x0F];
  181.   b1[0x0C] += b1[0x0E];
  182.   b1[0x0E] += b1[0x0D];
  183.   b1[0x0D] += b1[0x0F];
  184.   b1[0x10] = b2[0x10] + b2[0x11];
  185.   b1[0x11] = (b2[0x10] - b2[0x11]) * cos0;
  186.   b1[0x12] = b2[0x12] + b2[0x13];
  187.   b1[0x13] = (b2[0x13] - b2[0x12]) * cos0;
  188.   b1[0x12] += b1[0x13];
  189.   b1[0x14] = b2[0x14] + b2[0x15];
  190.   b1[0x15] = (b2[0x14] - b2[0x15]) * cos0;
  191.   b1[0x16] = b2[0x16] + b2[0x17];
  192.   b1[0x17] = (b2[0x17] - b2[0x16]) * cos0;
  193.   b1[0x16] += b1[0x17];
  194.   b1[0x14] += b1[0x16];
  195.   b1[0x16] += b1[0x15];
  196.   b1[0x15] += b1[0x17];
  197.   b1[0x18] = b2[0x18] + b2[0x19];
  198.   b1[0x19] = (b2[0x18] - b2[0x19]) * cos0;
  199.   b1[0x1A] = b2[0x1A] + b2[0x1B];
  200.   b1[0x1B] = (b2[0x1B] - b2[0x1A]) * cos0;
  201.   b1[0x1A] += b1[0x1B];
  202.   b1[0x1C] = b2[0x1C] + b2[0x1D];
  203.   b1[0x1D] = (b2[0x1C] - b2[0x1D]) * cos0;
  204.   b1[0x1E] = b2[0x1E] + b2[0x1F];
  205.   b1[0x1F] = (b2[0x1F] - b2[0x1E]) * cos0;
  206.   b1[0x1E] += b1[0x1F];
  207.   b1[0x1C] += b1[0x1E];
  208.   b1[0x1E] += b1[0x1D];
  209.   b1[0x1D] += b1[0x1F];
  210.  }
  211.  out0[0x10*16] = b1[0x00];
  212.  out0[0x10*12] = b1[0x04];
  213.  out0[0x10* 8] = b1[0x02];
  214.  out0[0x10* 4] = b1[0x06];
  215.  out0[0x10* 0] = b1[0x01];
  216.  out1[0x10* 0] = b1[0x01];
  217.  out1[0x10* 4] = b1[0x05];
  218.  out1[0x10* 8] = b1[0x03];
  219.  out1[0x10*12] = b1[0x07];
  220.  b1[0x08] += b1[0x0C];
  221.  out0[0x10*14] = b1[0x08];
  222.  b1[0x0C] += b1[0x0a];
  223.  out0[0x10*10] = b1[0x0C];
  224.  b1[0x0A] += b1[0x0E];
  225.  out0[0x10* 6] = b1[0x0A];
  226.  b1[0x0E] += b1[0x09];
  227.  out0[0x10* 2] = b1[0x0E];
  228.  b1[0x09] += b1[0x0D];
  229.  out1[0x10* 2] = b1[0x09];
  230.  b1[0x0D] += b1[0x0B];
  231.  out1[0x10* 6] = b1[0x0D];
  232.  b1[0x0B] += b1[0x0F];
  233.  out1[0x10*10] = b1[0x0B];
  234.  out1[0x10*14] = b1[0x0F];
  235.  b1[0x18] += b1[0x1C];
  236.  out0[0x10*15] = b1[0x10] + b1[0x18];
  237.  out0[0x10*13] = b1[0x18] + b1[0x14];
  238.  b1[0x1C] += b1[0x1a];
  239.  out0[0x10*11] = b1[0x14] + b1[0x1C];
  240.  out0[0x10* 9] = b1[0x1C] + b1[0x12];
  241.  b1[0x1A] += b1[0x1E];
  242.  out0[0x10* 7] = b1[0x12] + b1[0x1A];
  243.  out0[0x10* 5] = b1[0x1A] + b1[0x16];
  244.  b1[0x1E] += b1[0x19];
  245.  out0[0x10* 3] = b1[0x16] + b1[0x1E];
  246.  out0[0x10* 1] = b1[0x1E] + b1[0x11];
  247.  b1[0x19] += b1[0x1D];
  248.  out1[0x10* 1] = b1[0x11] + b1[0x19];
  249.  out1[0x10* 3] = b1[0x19] + b1[0x15];
  250.  b1[0x1D] += b1[0x1B];
  251.  out1[0x10* 5] = b1[0x15] + b1[0x1D];
  252.  out1[0x10* 7] = b1[0x1D] + b1[0x13];
  253.  b1[0x1B] += b1[0x1F];
  254.  out1[0x10* 9] = b1[0x13] + b1[0x1B];
  255.  out1[0x10*11] = b1[0x1B] + b1[0x17];
  256.  out1[0x10*13] = b1[0x17] + b1[0x1F];
  257.  out1[0x10*15] = b1[0x1F];
  258. }
  259. /*
  260.  * the call via dct64 is a trick to force GCC to use
  261.  * (new) registers for the b1,b2 pointer to the bufs[xx] field
  262.  */
  263. static void dct64(real *a,real *b,real *c)
  264. {
  265.   real bufs[0x40];
  266.   dct64_1(a,b,bufs,bufs+0x20,c);
  267. }
  268. void mp3lib_dct64(real *a,real *b,real *c)
  269. {
  270.   real bufs[0x40];
  271.   dct64_1(a,b,bufs,bufs+0x20,c);
  272. }