dct64_i386.cpp
上传用户:lusi_8715
上传日期:2007-01-08
资源大小:199k
文件大小:11k
源码类别:

流媒体/Mpeg4/MP4

开发平台:

Visual C++

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