sublay2.cpp
上传用户:hxb_1234
上传日期:2010-03-30
资源大小:8328k
文件大小:50k
源码类别:

VC书籍

开发平台:

Visual C++

  1. /* sublay2.cpp
  2.    Layer II subband object implementation, now with MPEG-2 LSF support */
  3. /*
  4.  *  @(#) subband_layer_2.cc 1.8, last edit: 6/15/94 16:51:50
  5.  *  @(#) Copyright (C) 1993, 1994 Tobias Bading (bading@cs.tu-berlin.de)
  6.  *  @(#) Berlin University of Technology
  7.  *
  8.  *  This program is free software; you can redistribute it and/or modify
  9.  *  it under the terms of the GNU General Public License as published by
  10.  *  the Free Software Foundation; either version 2 of the License, or
  11.  *  (at your option) any later version.
  12.  *
  13.  *  This program is distributed in the hope that it will be useful,
  14.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  *  GNU General Public License for more details.
  17.  *
  18.  *  You should have received a copy of the GNU General Public License
  19.  *  along with this program; if not, write to the Free Software
  20.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22. /*
  23.  *  Changes from version 1.1 to 1.2:
  24.  *    - calculation of the 3 samples contained in one groupcode is now done
  25.  *      through lookup tables, no more integer modulo or division required.
  26.  *      table_*_quantizationsteps[] arrays replaced by
  27.  *      table_*_groupingtables[] arrays
  28.  *    - scalefactors itself instead of scalefactor indices are stored in
  29.  *      SubbandLayer2... objects
  30.  *    - check for small values in [-1.0E-7, 1.0E-7] removed, because the
  31.  *      test itself was slower than some SynthesisFilter::input_sample() calls
  32.  *    - check for illegal scalefactor index 63 removed
  33.  */
  34. #include "sublay2.h"
  35. #include "scalfact.h"
  36. #ifdef __WIN32__
  37. #pragma warning (disable: 4305 4244)
  38. #endif
  39. static const real grouping_5bits[27 * 3] =
  40. // this table contains 3 requantized samples for each legal codeword
  41. // when grouped in 5 bits, i.e. 3 quantizationsteps per sample
  42. {
  43.   -2.0f/3.0f, -2.0f/3.0f, -2.0f/3.0f,
  44.  0.0f, -2.0f/3.0f, -2.0f/3.0f,
  45. 2.0f/3.0f, -2.0f/3.0f, -2.0f/3.0f,
  46.   -2.0f/3.0f,      0.0f, -2.0f/3.0f,
  47.  0.0f,      0.0f, -2.0f/3.0f,
  48. 2.0f/3.0f,      0.0f, -2.0f/3.0f,
  49.   -2.0f/3.0f,  2.0f/3.0f, -2.0f/3.0f,
  50.  0.0f,  2.0f/3.0f, -2.0f/3.0f,
  51. 2.0f/3.0f,  2.0f/3.0f, -2.0f/3.0f,
  52.   -2.0f/3.0f, -2.0f/3.0f,      0.0f,
  53.  0.0f, -2.0f/3.0f,      0.0f,
  54. 2.0f/3.0f, -2.0f/3.0f,      0.0f,
  55.   -2.0f/3.0f,      0.0f,      0.0f,
  56.  0.0f,      0.0f,      0.0f,
  57. 2.0f/3.0f,      0.0f,      0.0f,
  58.   -2.0f/3.0f,  2.0f/3.0f,      0.0f,
  59.  0.0f,  2.0f/3.0f,      0.0f,
  60. 2.0f/3.0f,  2.0f/3.0f,      0.0f,
  61.   -2.0f/3.0f, -2.0f/3.0f,  2.0f/3.0f,
  62.        0.0f, -2.0f/3.0f,  2.0f/3.0f,
  63. 2.0f/3.0f, -2.0f/3.0f,  2.0f/3.0f,
  64.   -2.0f/3.0f,      0.0f,  2.0f/3.0f,
  65.        0.0f,      0.0f,  2.0f/3.0f,
  66.    2.0f/3.0f,      0.0f,  2.0f/3.0f,
  67.   -2.0f/3.0f,  2.0f/3.0f,  2.0f/3.0f,
  68.  0.0f,  2.0f/3.0f,  2.0f/3.0f,
  69.    2.0f/3.0f,  2.0f/3.0f,  2.0f/3.0f
  70. };
  71. static const real grouping_7bits[125 * 3] =
  72. // this table contains 3 requantized samples for each legal codeword
  73. // when grouped in 7 bits, i.e. 5 quantizationsteps per sample
  74. {
  75.   -0.8f, -0.8f, -0.8f,   -0.4f, -0.8f, -0.8f,    0.0f, -0.8f, -0.8f,    0.4f, -0.8f, -0.8f,    0.8f, -0.8f, -0.8f,
  76.   -0.8f, -0.4f, -0.8f,   -0.4f, -0.4f, -0.8f,    0.0f, -0.4f, -0.8f,    0.4f, -0.4f, -0.8f,    0.8f, -0.4f, -0.8f,
  77.   -0.8f,  0.0f, -0.8f,   -0.4f,  0.0f, -0.8f,    0.0f,  0.0f, -0.8f,    0.4f,  0.0f, -0.8f,    0.8f,  0.0f, -0.8f,
  78.   -0.8f,  0.4f, -0.8f,   -0.4f,  0.4f, -0.8f,    0.0f,  0.4f, -0.8f,    0.4f,  0.4f, -0.8f,    0.8f,  0.4f, -0.8f,
  79.   -0.8f,  0.8f, -0.8f,   -0.4f,  0.8f, -0.8f,    0.0f,  0.8f, -0.8f,    0.4f,  0.8f, -0.8f,    0.8f,  0.8f, -0.8f,
  80.   -0.8f, -0.8f, -0.4f,   -0.4f, -0.8f, -0.4f,    0.0f, -0.8f, -0.4f,    0.4f, -0.8f, -0.4f,    0.8f, -0.8f, -0.4f,
  81.   -0.8f, -0.4f, -0.4f,   -0.4f, -0.4f, -0.4f,    0.0f, -0.4f, -0.4f,    0.4f, -0.4f, -0.4f,    0.8f, -0.4f, -0.4f,
  82.   -0.8f,  0.0f, -0.4f,   -0.4f,  0.0f, -0.4f,    0.0f,  0.0f, -0.4f,    0.4f,  0.0f, -0.4f,    0.8f,  0.0f, -0.4f,
  83.   -0.8f,  0.4f, -0.4f,   -0.4f,  0.4f, -0.4f,    0.0f,  0.4f, -0.4f,    0.4f,  0.4f, -0.4f,    0.8f,  0.4f, -0.4f,
  84.   -0.8f,  0.8f, -0.4f,   -0.4f,  0.8f, -0.4f,    0.0f,  0.8f, -0.4f,    0.4f,  0.8f, -0.4f,    0.8f,  0.8f, -0.4f,
  85.   -0.8f, -0.8f,  0.0f,   -0.4f, -0.8f,  0.0f,    0.0f, -0.8f,  0.0f,    0.4f, -0.8f,  0.0f,    0.8f, -0.8f,  0.0f,
  86.   -0.8f, -0.4f,  0.0f,   -0.4f, -0.4f,  0.0f,    0.0f, -0.4f,  0.0f,    0.4f, -0.4f,  0.0f,    0.8f, -0.4f,  0.0f,
  87.   -0.8f,  0.0f,  0.0f,   -0.4f,  0.0f,  0.0f,    0.0f,  0.0f,  0.0f,    0.4f,  0.0f,  0.0f,    0.8f,  0.0f,  0.0f,
  88.   -0.8f,  0.4f,  0.0f,   -0.4f,  0.4f,  0.0f,    0.0f,  0.4f,  0.0f,    0.4f,  0.4f,  0.0f,    0.8f,  0.4f,  0.0f,
  89.   -0.8f,  0.8f,  0.0f,   -0.4f,  0.8f,  0.0f,    0.0f,  0.8f,  0.0f,    0.4f,  0.8f,  0.0f,    0.8f,  0.8f,  0.0f,
  90.   -0.8f, -0.8f,  0.4f,   -0.4f, -0.8f,  0.4f,    0.0f, -0.8f,  0.4f,    0.4f, -0.8f,  0.4f,    0.8f, -0.8f,  0.4f,
  91.   -0.8f, -0.4f,  0.4f,   -0.4f, -0.4f,  0.4f,    0.0f, -0.4f,  0.4f,    0.4f, -0.4f,  0.4f,    0.8f, -0.4f,  0.4f,
  92.   -0.8f,  0.0f,  0.4f,   -0.4f,  0.0f,  0.4f,    0.0f,  0.0f,  0.4f,    0.4f,  0.0f,  0.4f,    0.8f,  0.0f,  0.4f,
  93.   -0.8f,  0.4f,  0.4f,   -0.4f,  0.4f,  0.4f,    0.0f,  0.4f,  0.4f,    0.4f,  0.4f,  0.4f,    0.8f,  0.4f,  0.4f,
  94.   -0.8f,  0.8f,  0.4f,   -0.4f,  0.8f,  0.4f,    0.0f,  0.8f,  0.4f,    0.4f,  0.8f,  0.4f,    0.8f,  0.8f,  0.4f,
  95.   -0.8f, -0.8f,  0.8f,   -0.4f, -0.8f,  0.8f,    0.0f, -0.8f,  0.8f,    0.4f, -0.8f,  0.8f,    0.8f, -0.8f,  0.8f,
  96.   -0.8f, -0.4f,  0.8f,   -0.4f, -0.4f,  0.8f,    0.0f, -0.4f,  0.8f,    0.4f, -0.4f,  0.8f,    0.8f, -0.4f,  0.8f,
  97.   -0.8f,  0.0f,  0.8f,   -0.4f,  0.0f,  0.8f,    0.0f,  0.0f,  0.8f,    0.4f,  0.0f,  0.8f,    0.8f,  0.0f,  0.8f,
  98.   -0.8f,  0.4f,  0.8f,   -0.4f,  0.4f,  0.8f,    0.0f,  0.4f,  0.8f,    0.4f,  0.4f,  0.8f,    0.8f,  0.4f,  0.8f,
  99.   -0.8f,  0.8f,  0.8f,   -0.4f,  0.8f,  0.8f,    0.0f,  0.8f,  0.8f,    0.4f,  0.8f,  0.8f,    0.8f,  0.8f,  0.8f
  100. };
  101. static const real grouping_10bits[729 * 3] =
  102. // this table contains 3 requantized samples for each legal codeword
  103. // when grouped in 10 bits, i.e. 9 quantizationsteps per sample
  104. {
  105.   -8.0f/9.0f, -8.0f/9.0f, -8.0f/9.0f,   -6.0f/9.0f, -8.0f/9.0f, -8.0f/9.0f,   -4.0f/9.0f, -8.0f/9.0f, -8.0f/9.0f,
  106.   -2.0f/9.0f, -8.0f/9.0f, -8.0f/9.0f,        0.0f, -8.0f/9.0f, -8.0f/9.0f,    2.0f/9.0f, -8.0f/9.0f, -8.0f/9.0f,
  107. 4.0f/9.0f, -8.0f/9.0f, -8.0f/9.0f,    6.0f/9.0f, -8.0f/9.0f, -8.0f/9.0f,    8.0f/9.0f, -8.0f/9.0f, -8.0f/9.0f,
  108.   -8.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f,   -6.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f,   -4.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f,
  109.   -2.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f,        0.0f, -6.0f/9.0f, -8.0f/9.0f,    2.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f,
  110. 4.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f,    6.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f,    8.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f,
  111.   -8.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f,   -6.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f,   -4.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f,
  112.   -2.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f,        0.0f, -4.0f/9.0f, -8.0f/9.0f,    2.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f,
  113. 4.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f,    6.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f,    8.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f,
  114.   -8.0f/9.0f, -2.0f/9.0f, -8.0f/9.0f,   -6.0f/9.0f, -2.0f/9.0f, -8.0f/9.0f,   -4.0f/9.0f, -2.0f/9.0f, -8.0f/9.0f,
  115.   -2.0f/9.0f, -2.0f/9.0f, -8.0f/9.0f,        0.0f, -2.0f/9.0f, -8.0f/9.0f,    2.0f/9.0f, -2.0f/9.0f, -8.0f/9.0f,
  116. 4.0f/9.0f, -2.0f/9.0f, -8.0f/9.0f,    6.0f/9.0f, -2.0f/9.0f, -8.0f/9.0f,    8.0f/9.0f, -2.0f/9.0f, -8.0f/9.0f,
  117.   -8.0f/9.0f,      0.0f, -8.0f/9.0f,   -6.0f/9.0f,      0.0f, -8.0f/9.0f,   -4.0f/9.0f,      0.0f, -8.0f/9.0f,
  118.   -2.0f/9.0f,      0.0f, -8.0f/9.0f,        0.0f,      0.0f, -8.0f/9.0f,    2.0f/9.0f,      0.0f, -8.0f/9.0f,
  119. 4.0f/9.0f,      0.0f, -8.0f/9.0f,    6.0f/9.0f,      0.0f, -8.0f/9.0f,    8.0f/9.0f,      0.0f, -8.0f/9.0f,
  120.   -8.0f/9.0f,  2.0f/9.0f, -8.0f/9.0f,   -6.0f/9.0f,  2.0f/9.0f, -8.0f/9.0f,   -4.0f/9.0f,  2.0f/9.0f, -8.0f/9.0f,
  121.   -2.0f/9.0f,  2.0f/9.0f, -8.0f/9.0f,        0.0f,  2.0f/9.0f, -8.0f/9.0f,    2.0f/9.0f,  2.0f/9.0f, -8.0f/9.0f,
  122. 4.0f/9.0f,  2.0f/9.0f, -8.0f/9.0f,    6.0f/9.0f,  2.0f/9.0f, -8.0f/9.0f,    8.0f/9.0f,  2.0f/9.0f, -8.0f/9.0f,
  123.   -8.0f/9.0f,  4.0f/9.0f, -8.0f/9.0f,   -6.0f/9.0f,  4.0f/9.0f, -8.0f/9.0f,   -4.0f/9.0f,  4.0f/9.0f, -8.0f/9.0f,
  124.   -2.0f/9.0f,  4.0f/9.0f, -8.0f/9.0f,        0.0f,  4.0f/9.0f, -8.0f/9.0f,    2.0f/9.0f,  4.0f/9.0f, -8.0f/9.0f,
  125. 4.0f/9.0f,  4.0f/9.0f, -8.0f/9.0f,    6.0f/9.0f,  4.0f/9.0f, -8.0f/9.0f,    8.0f/9.0f,  4.0f/9.0f, -8.0f/9.0f,
  126.   -8.0f/9.0f,  6.0f/9.0f, -8.0f/9.0f,   -6.0f/9.0f,  6.0f/9.0f, -8.0f/9.0f,   -4.0f/9.0f,  6.0f/9.0f, -8.0f/9.0f,
  127.   -2.0f/9.0f,  6.0f/9.0f, -8.0f/9.0f,        0.0f,  6.0f/9.0f, -8.0f/9.0f,    2.0f/9.0f,  6.0f/9.0f, -8.0f/9.0f,
  128. 4.0f/9.0f,  6.0f/9.0f, -8.0f/9.0f,    6.0f/9.0f,  6.0f/9.0f, -8.0f/9.0f,    8.0f/9.0f,  6.0f/9.0f, -8.0f/9.0f,
  129.   -8.0f/9.0f,  8.0f/9.0f, -8.0f/9.0f,   -6.0f/9.0f,  8.0f/9.0f, -8.0f/9.0f,   -4.0f/9.0f,  8.0f/9.0f, -8.0f/9.0f,
  130.   -2.0f/9.0f,  8.0f/9.0f, -8.0f/9.0f,        0.0f,  8.0f/9.0f, -8.0f/9.0f,    2.0f/9.0f,  8.0f/9.0f, -8.0f/9.0f,
  131. 4.0f/9.0f,  8.0f/9.0f, -8.0f/9.0f,    6.0f/9.0f,  8.0f/9.0f, -8.0f/9.0f,    8.0f/9.0f,  8.0f/9.0f, -8.0f/9.0f,
  132.   -8.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f,   -6.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f,   -4.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f,
  133.   -2.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f,        0.0f, -8.0f/9.0f, -6.0f/9.0f,    2.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f,
  134. 4.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f,    6.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f,    8.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f,
  135.   -8.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f,   -6.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f,   -4.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f,
  136.   -2.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f,        0.0f, -6.0f/9.0f, -6.0f/9.0f,    2.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f,
  137. 4.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f,    6.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f,    8.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f,
  138.   -8.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f,   -6.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f,   -4.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f,
  139.   -2.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f,        0.0f, -4.0f/9.0f, -6.0f/9.0f,    2.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f,
  140. 4.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f,    6.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f,    8.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f,
  141.   -8.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f,   -6.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f,   -4.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f,
  142.   -2.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f,        0.0f, -2.0f/9.0f, -6.0f/9.0f,    2.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f,
  143. 4.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f,    6.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f,    8.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f,
  144.   -8.0f/9.0f,      0.0f, -6.0f/9.0f,   -6.0f/9.0f,      0.0f, -6.0f/9.0f,   -4.0f/9.0f,      0.0f, -6.0f/9.0f,
  145.   -2.0f/9.0f,      0.0f, -6.0f/9.0f,        0.0f,      0.0f, -6.0f/9.0f,    2.0f/9.0f,      0.0f, -6.0f/9.0f,
  146. 4.0f/9.0f,      0.0f, -6.0f/9.0f,    6.0f/9.0f,      0.0f, -6.0f/9.0f,    8.0f/9.0f,      0.0f, -6.0f/9.0f,
  147.   -8.0f/9.0f,  2.0f/9.0f, -6.0f/9.0f,   -6.0f/9.0f,  2.0f/9.0f, -6.0f/9.0f,   -4.0f/9.0f,  2.0f/9.0f, -6.0f/9.0f,
  148.   -2.0f/9.0f,  2.0f/9.0f, -6.0f/9.0f,        0.0f,  2.0f/9.0f, -6.0f/9.0f,    2.0f/9.0f,  2.0f/9.0f, -6.0f/9.0f,
  149. 4.0f/9.0f,  2.0f/9.0f, -6.0f/9.0f,    6.0f/9.0f,  2.0f/9.0f, -6.0f/9.0f,    8.0f/9.0f,  2.0f/9.0f, -6.0f/9.0f,
  150.   -8.0f/9.0f,  4.0f/9.0f, -6.0f/9.0f,   -6.0f/9.0f,  4.0f/9.0f, -6.0f/9.0f,   -4.0f/9.0f,  4.0f/9.0f, -6.0f/9.0f,
  151.   -2.0f/9.0f,  4.0f/9.0f, -6.0f/9.0f,        0.0f,  4.0f/9.0f, -6.0f/9.0f,    2.0f/9.0f,  4.0f/9.0f, -6.0f/9.0f,
  152. 4.0f/9.0f,  4.0f/9.0f, -6.0f/9.0f,    6.0f/9.0f,  4.0f/9.0f, -6.0f/9.0f,    8.0f/9.0f,  4.0f/9.0f, -6.0f/9.0f,
  153.   -8.0f/9.0f,  6.0f/9.0f, -6.0f/9.0f,   -6.0f/9.0f,  6.0f/9.0f, -6.0f/9.0f,   -4.0f/9.0f,  6.0f/9.0f, -6.0f/9.0f,
  154.   -2.0f/9.0f,  6.0f/9.0f, -6.0f/9.0f,        0.0f,  6.0f/9.0f, -6.0f/9.0f,    2.0f/9.0f,  6.0f/9.0f, -6.0f/9.0f,
  155. 4.0f/9.0f,  6.0f/9.0f, -6.0f/9.0f,    6.0f/9.0f,  6.0f/9.0f, -6.0f/9.0f,    8.0f/9.0f,  6.0f/9.0f, -6.0f/9.0f,
  156.   -8.0f/9.0f,  8.0f/9.0f, -6.0f/9.0f,   -6.0f/9.0f,  8.0f/9.0f, -6.0f/9.0f,   -4.0f/9.0f,  8.0f/9.0f, -6.0f/9.0f,
  157.   -2.0f/9.0f,  8.0f/9.0f, -6.0f/9.0f,        0.0f,  8.0f/9.0f, -6.0f/9.0f,    2.0f/9.0f,  8.0f/9.0f, -6.0f/9.0f,
  158. 4.0f/9.0f,  8.0f/9.0f, -6.0f/9.0f,    6.0f/9.0f,  8.0f/9.0f, -6.0f/9.0f,    8.0f/9.0f,  8.0f/9.0f, -6.0f/9.0f,
  159.   -8.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f,   -6.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f,   -4.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f,
  160.   -2.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f,        0.0f, -8.0f/9.0f, -4.0f/9.0f,    2.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f,
  161. 4.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f,    6.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f,    8.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f,
  162.   -8.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f,   -6.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f,   -4.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f,
  163.   -2.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f,        0.0f, -6.0f/9.0f, -4.0f/9.0f,    2.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f,
  164. 4.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f,    6.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f,    8.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f,
  165.   -8.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f,   -6.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f,   -4.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f,
  166.   -2.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f,        0.0f, -4.0f/9.0f, -4.0f/9.0f,    2.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f,
  167. 4.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f,    6.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f,    8.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f,
  168.   -8.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f,   -6.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f,   -4.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f,
  169.   -2.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f,        0.0f, -2.0f/9.0f, -4.0f/9.0f,    2.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f,
  170. 4.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f,    6.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f,    8.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f,
  171.   -8.0f/9.0f,      0.0f, -4.0f/9.0f,   -6.0f/9.0f,      0.0f, -4.0f/9.0f,   -4.0f/9.0f,      0.0f, -4.0f/9.0f,
  172.   -2.0f/9.0f,      0.0f, -4.0f/9.0f,        0.0f,      0.0f, -4.0f/9.0f,    2.0f/9.0f,      0.0f, -4.0f/9.0f,
  173. 4.0f/9.0f,      0.0f, -4.0f/9.0f,    6.0f/9.0f,      0.0f, -4.0f/9.0f,    8.0f/9.0f,      0.0f, -4.0f/9.0f,
  174.   -8.0f/9.0f,  2.0f/9.0f, -4.0f/9.0f,   -6.0f/9.0f,  2.0f/9.0f, -4.0f/9.0f,   -4.0f/9.0f,  2.0f/9.0f, -4.0f/9.0f,
  175.   -2.0f/9.0f,  2.0f/9.0f, -4.0f/9.0f,        0.0f,  2.0f/9.0f, -4.0f/9.0f,    2.0f/9.0f,  2.0f/9.0f, -4.0f/9.0f,
  176. 4.0f/9.0f,  2.0f/9.0f, -4.0f/9.0f,    6.0f/9.0f,  2.0f/9.0f, -4.0f/9.0f,    8.0f/9.0f,  2.0f/9.0f, -4.0f/9.0f,
  177.   -8.0f/9.0f,  4.0f/9.0f, -4.0f/9.0f,   -6.0f/9.0f,  4.0f/9.0f, -4.0f/9.0f,   -4.0f/9.0f,  4.0f/9.0f, -4.0f/9.0f,
  178.   -2.0f/9.0f,  4.0f/9.0f, -4.0f/9.0f,        0.0f,  4.0f/9.0f, -4.0f/9.0f,    2.0f/9.0f,  4.0f/9.0f, -4.0f/9.0f,
  179. 4.0f/9.0f,  4.0f/9.0f, -4.0f/9.0f,    6.0f/9.0f,  4.0f/9.0f, -4.0f/9.0f,    8.0f/9.0f,  4.0f/9.0f, -4.0f/9.0f,
  180.   -8.0f/9.0f,  6.0f/9.0f, -4.0f/9.0f,   -6.0f/9.0f,  6.0f/9.0f, -4.0f/9.0f,   -4.0f/9.0f,  6.0f/9.0f, -4.0f/9.0f,
  181.   -2.0f/9.0f,  6.0f/9.0f, -4.0f/9.0f,        0.0f,  6.0f/9.0f, -4.0f/9.0f,    2.0f/9.0f,  6.0f/9.0f, -4.0f/9.0f,
  182. 4.0f/9.0f,  6.0f/9.0f, -4.0f/9.0f,    6.0f/9.0f,  6.0f/9.0f, -4.0f/9.0f,    8.0f/9.0f,  6.0f/9.0f, -4.0f/9.0f,
  183.   -8.0f/9.0f,  8.0f/9.0f, -4.0f/9.0f,   -6.0f/9.0f,  8.0f/9.0f, -4.0f/9.0f,   -4.0f/9.0f,  8.0f/9.0f, -4.0f/9.0f,
  184.   -2.0f/9.0f,  8.0f/9.0f, -4.0f/9.0f,        0.0f,  8.0f/9.0f, -4.0f/9.0f,    2.0f/9.0f,  8.0f/9.0f, -4.0f/9.0f,
  185. 4.0f/9.0f,  8.0f/9.0f, -4.0f/9.0f,    6.0f/9.0f,  8.0f/9.0f, -4.0f/9.0f,    8.0f/9.0f,  8.0f/9.0f, -4.0f/9.0f,
  186.   -8.0f/9.0f, -8.0f/9.0f, -2.0f/9.0f,   -6.0f/9.0f, -8.0f/9.0f, -2.0f/9.0f,   -4.0f/9.0f, -8.0f/9.0f, -2.0f/9.0f,
  187.   -2.0f/9.0f, -8.0f/9.0f, -2.0f/9.0f,        0.0f, -8.0f/9.0f, -2.0f/9.0f,    2.0f/9.0f, -8.0f/9.0f, -2.0f/9.0f,
  188. 4.0f/9.0f, -8.0f/9.0f, -2.0f/9.0f,    6.0f/9.0f, -8.0f/9.0f, -2.0f/9.0f,    8.0f/9.0f, -8.0f/9.0f, -2.0f/9.0f,
  189.   -8.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f,   -6.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f,   -4.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f,
  190.   -2.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f,        0.0f, -6.0f/9.0f, -2.0f/9.0f,    2.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f,
  191. 4.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f,    6.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f,    8.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f,
  192.   -8.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f,   -6.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f,   -4.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f,
  193.   -2.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f,        0.0f, -4.0f/9.0f, -2.0f/9.0f,    2.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f,
  194. 4.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f,    6.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f,    8.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f,
  195.   -8.0f/9.0f, -2.0f/9.0f, -2.0f/9.0f,   -6.0f/9.0f, -2.0f/9.0f, -2.0f/9.0f,   -4.0f/9.0f, -2.0f/9.0f, -2.0f/9.0f,
  196.   -2.0f/9.0f, -2.0f/9.0f, -2.0f/9.0f,        0.0f, -2.0f/9.0f, -2.0f/9.0f,    2.0f/9.0f, -2.0f/9.0f, -2.0f/9.0f,
  197. 4.0f/9.0f, -2.0f/9.0f, -2.0f/9.0f,    6.0f/9.0f, -2.0f/9.0f, -2.0f/9.0f,    8.0f/9.0f, -2.0f/9.0f, -2.0f/9.0f,
  198.   -8.0f/9.0f,      0.0f, -2.0f/9.0f,   -6.0f/9.0f,      0.0f, -2.0f/9.0f,   -4.0f/9.0f,      0.0f, -2.0f/9.0f,
  199.   -2.0f/9.0f,      0.0f, -2.0f/9.0f,        0.0f,      0.0f, -2.0f/9.0f,    2.0f/9.0f,      0.0f, -2.0f/9.0f,
  200. 4.0f/9.0f,      0.0f, -2.0f/9.0f,    6.0f/9.0f,      0.0f, -2.0f/9.0f,    8.0f/9.0f,      0.0f, -2.0f/9.0f,
  201.   -8.0f/9.0f,  2.0f/9.0f, -2.0f/9.0f,   -6.0f/9.0f,  2.0f/9.0f, -2.0f/9.0f,   -4.0f/9.0f,  2.0f/9.0f, -2.0f/9.0f,
  202.   -2.0f/9.0f,  2.0f/9.0f, -2.0f/9.0f,        0.0f,  2.0f/9.0f, -2.0f/9.0f,    2.0f/9.0f,  2.0f/9.0f, -2.0f/9.0f,
  203. 4.0f/9.0f,  2.0f/9.0f, -2.0f/9.0f,    6.0f/9.0f,  2.0f/9.0f, -2.0f/9.0f,    8.0f/9.0f,  2.0f/9.0f, -2.0f/9.0f,
  204.   -8.0f/9.0f,  4.0f/9.0f, -2.0f/9.0f,   -6.0f/9.0f,  4.0f/9.0f, -2.0f/9.0f,   -4.0f/9.0f,  4.0f/9.0f, -2.0f/9.0f,
  205.   -2.0f/9.0f,  4.0f/9.0f, -2.0f/9.0f,        0.0f,  4.0f/9.0f, -2.0f/9.0f,    2.0f/9.0f,  4.0f/9.0f, -2.0f/9.0f,
  206. 4.0f/9.0f,  4.0f/9.0f, -2.0f/9.0f,    6.0f/9.0f,  4.0f/9.0f, -2.0f/9.0f,    8.0f/9.0f,  4.0f/9.0f, -2.0f/9.0f,
  207.   -8.0f/9.0f,  6.0f/9.0f, -2.0f/9.0f,   -6.0f/9.0f,  6.0f/9.0f, -2.0f/9.0f,   -4.0f/9.0f,  6.0f/9.0f, -2.0f/9.0f,
  208.   -2.0f/9.0f,  6.0f/9.0f, -2.0f/9.0f,        0.0f,  6.0f/9.0f, -2.0f/9.0f,    2.0f/9.0f,  6.0f/9.0f, -2.0f/9.0f,
  209. 4.0f/9.0f,  6.0f/9.0f, -2.0f/9.0f,    6.0f/9.0f,  6.0f/9.0f, -2.0f/9.0f,    8.0f/9.0f,  6.0f/9.0f, -2.0f/9.0f,
  210.   -8.0f/9.0f,  8.0f/9.0f, -2.0f/9.0f,   -6.0f/9.0f,  8.0f/9.0f, -2.0f/9.0f,   -4.0f/9.0f,  8.0f/9.0f, -2.0f/9.0f,
  211.   -2.0f/9.0f,  8.0f/9.0f, -2.0f/9.0f,        0.0f,  8.0f/9.0f, -2.0f/9.0f,    2.0f/9.0f,  8.0f/9.0f, -2.0f/9.0f,
  212. 4.0f/9.0f,  8.0f/9.0f, -2.0f/9.0f,    6.0f/9.0f,  8.0f/9.0f, -2.0f/9.0f,    8.0f/9.0f,  8.0f/9.0f, -2.0f/9.0f,
  213.   -8.0f/9.0f, -8.0f/9.0f,      0.0f,   -6.0f/9.0f, -8.0f/9.0f,      0.0f,   -4.0f/9.0f, -8.0f/9.0f,      0.0f,
  214.   -2.0f/9.0f, -8.0f/9.0f,      0.0f,        0.0f, -8.0f/9.0f,      0.0f,    2.0f/9.0f, -8.0f/9.0f,      0.0f,
  215. 4.0f/9.0f, -8.0f/9.0f,      0.0f,    6.0f/9.0f, -8.0f/9.0f,      0.0f,    8.0f/9.0f, -8.0f/9.0f,      0.0f,
  216.   -8.0f/9.0f, -6.0f/9.0f,      0.0f,   -6.0f/9.0f, -6.0f/9.0f,      0.0f,   -4.0f/9.0f, -6.0f/9.0f,      0.0f,
  217.   -2.0f/9.0f, -6.0f/9.0f,      0.0f,        0.0f, -6.0f/9.0f,      0.0f,    2.0f/9.0f, -6.0f/9.0f,      0.0f,
  218. 4.0f/9.0f, -6.0f/9.0f,      0.0f,    6.0f/9.0f, -6.0f/9.0f,      0.0f,    8.0f/9.0f, -6.0f/9.0f,      0.0f,
  219.   -8.0f/9.0f, -4.0f/9.0f,      0.0f,   -6.0f/9.0f, -4.0f/9.0f,      0.0f,   -4.0f/9.0f, -4.0f/9.0f,      0.0f,
  220.   -2.0f/9.0f, -4.0f/9.0f,      0.0f,        0.0f, -4.0f/9.0f,      0.0f,    2.0f/9.0f, -4.0f/9.0f,      0.0f,
  221. 4.0f/9.0f, -4.0f/9.0f,      0.0f,    6.0f/9.0f, -4.0f/9.0f,      0.0f,    8.0f/9.0f, -4.0f/9.0f,      0.0f,
  222.   -8.0f/9.0f, -2.0f/9.0f,      0.0f,   -6.0f/9.0f, -2.0f/9.0f,      0.0f,   -4.0f/9.0f, -2.0f/9.0f,      0.0f,
  223.   -2.0f/9.0f, -2.0f/9.0f,      0.0f,        0.0f, -2.0f/9.0f,      0.0f,    2.0f/9.0f, -2.0f/9.0f,      0.0f,
  224. 4.0f/9.0f, -2.0f/9.0f,      0.0f,    6.0f/9.0f, -2.0f/9.0f,      0.0f,    8.0f/9.0f, -2.0f/9.0f,      0.0f,
  225.   -8.0f/9.0f,      0.0f,      0.0f,   -6.0f/9.0f,      0.0f,      0.0f,   -4.0f/9.0f,      0.0f,      0.0f,
  226.   -2.0f/9.0f,      0.0f,      0.0f,        0.0f,      0.0f,      0.0f,    2.0f/9.0f,      0.0f,      0.0f,
  227. 4.0f/9.0f,      0.0f,      0.0f,    6.0f/9.0f,      0.0f,      0.0f,    8.0f/9.0f,      0.0f,      0.0f,
  228.   -8.0f/9.0f,  2.0f/9.0f,      0.0f,   -6.0f/9.0f,  2.0f/9.0f,      0.0f,   -4.0f/9.0f,  2.0f/9.0f,      0.0f,
  229.   -2.0f/9.0f,  2.0f/9.0f,      0.0f,        0.0f,  2.0f/9.0f,      0.0f,    2.0f/9.0f,  2.0f/9.0f,      0.0f,
  230. 4.0f/9.0f,  2.0f/9.0f,      0.0f,    6.0f/9.0f,  2.0f/9.0f,      0.0f,    8.0f/9.0f,  2.0f/9.0f,      0.0f,
  231.   -8.0f/9.0f,  4.0f/9.0f,      0.0f,   -6.0f/9.0f,  4.0f/9.0f,      0.0f,   -4.0f/9.0f,  4.0f/9.0f,      0.0f,
  232.   -2.0f/9.0f,  4.0f/9.0f,      0.0f,        0.0f,  4.0f/9.0f,      0.0f,    2.0f/9.0f,  4.0f/9.0f,      0.0f,
  233. 4.0f/9.0f,  4.0f/9.0f,      0.0f,    6.0f/9.0f,  4.0f/9.0f,      0.0f,    8.0f/9.0f,  4.0f/9.0f,      0.0f,
  234.   -8.0f/9.0f,  6.0f/9.0f,      0.0f,   -6.0f/9.0f,  6.0f/9.0f,      0.0f,   -4.0f/9.0f,  6.0f/9.0f,      0.0f,
  235.   -2.0f/9.0f,  6.0f/9.0f,      0.0f,        0.0f,  6.0f/9.0f,      0.0f,    2.0f/9.0f,  6.0f/9.0f,      0.0f,
  236. 4.0f/9.0f,  6.0f/9.0f,      0.0f,    6.0f/9.0f,  6.0f/9.0f,      0.0f,    8.0f/9.0f,  6.0f/9.0f,      0.0f,
  237.   -8.0f/9.0f,  8.0f/9.0f,      0.0f,   -6.0f/9.0f,  8.0f/9.0f,      0.0f,   -4.0f/9.0f,  8.0f/9.0f,      0.0f,
  238.   -2.0f/9.0f,  8.0f/9.0f,      0.0f,        0.0f,  8.0f/9.0f,      0.0f,    2.0f/9.0f,  8.0f/9.0f,      0.0f,
  239.    4.0f/9.0f,  8.0f/9.0f,      0.0f,    6.0f/9.0f,  8.0f/9.0f,      0.0f,    8.0f/9.0f,  8.0f/9.0f,      0.0f,
  240.   -8.0f/9.0f, -8.0f/9.0f,  2.0f/9.0f,   -6.0f/9.0f, -8.0f/9.0f,  2.0f/9.0f,   -4.0f/9.0f, -8.0f/9.0f,  2.0f/9.0f,
  241.   -2.0f/9.0f, -8.0f/9.0f,  2.0f/9.0f,        0.0f, -8.0f/9.0f,  2.0f/9.0f,    2.0f/9.0f, -8.0f/9.0f,  2.0f/9.0f,
  242. 4.0f/9.0f, -8.0f/9.0f,  2.0f/9.0f,    6.0f/9.0f, -8.0f/9.0f,  2.0f/9.0f,    8.0f/9.0f, -8.0f/9.0f,  2.0f/9.0f,
  243.   -8.0f/9.0f, -6.0f/9.0f,  2.0f/9.0f,   -6.0f/9.0f, -6.0f/9.0f,  2.0f/9.0f,   -4.0f/9.0f, -6.0f/9.0f,  2.0f/9.0f,
  244.   -2.0f/9.0f, -6.0f/9.0f,  2.0f/9.0f,        0.0f, -6.0f/9.0f,  2.0f/9.0f,    2.0f/9.0f, -6.0f/9.0f,  2.0f/9.0f,
  245. 4.0f/9.0f, -6.0f/9.0f,  2.0f/9.0f,    6.0f/9.0f, -6.0f/9.0f,  2.0f/9.0f,    8.0f/9.0f, -6.0f/9.0f,  2.0f/9.0f,
  246.   -8.0f/9.0f, -4.0f/9.0f,  2.0f/9.0f,   -6.0f/9.0f, -4.0f/9.0f,  2.0f/9.0f,   -4.0f/9.0f, -4.0f/9.0f,  2.0f/9.0f,
  247.   -2.0f/9.0f, -4.0f/9.0f,  2.0f/9.0f,        0.0f, -4.0f/9.0f,  2.0f/9.0f,    2.0f/9.0f, -4.0f/9.0f,  2.0f/9.0f,
  248.    4.0f/9.0f, -4.0f/9.0f,  2.0f/9.0f,    6.0f/9.0f, -4.0f/9.0f,  2.0f/9.0f,    8.0f/9.0f, -4.0f/9.0f,  2.0f/9.0f,
  249.   -8.0f/9.0f, -2.0f/9.0f,  2.0f/9.0f,   -6.0f/9.0f, -2.0f/9.0f,  2.0f/9.0f,   -4.0f/9.0f, -2.0f/9.0f,  2.0f/9.0f,
  250.   -2.0f/9.0f, -2.0f/9.0f,  2.0f/9.0f,        0.0f, -2.0f/9.0f,  2.0f/9.0f,    2.0f/9.0f, -2.0f/9.0f,  2.0f/9.0f,
  251.    4.0f/9.0f, -2.0f/9.0f,  2.0f/9.0f,    6.0f/9.0f, -2.0f/9.0f,  2.0f/9.0f,    8.0f/9.0f, -2.0f/9.0f,  2.0f/9.0f,
  252.   -8.0f/9.0f,      0.0f,  2.0f/9.0f,   -6.0f/9.0f,      0.0f,  2.0f/9.0f,   -4.0f/9.0f,      0.0f,  2.0f/9.0f,
  253.   -2.0f/9.0f,      0.0f,  2.0f/9.0f,        0.0f,      0.0f,  2.0f/9.0f,    2.0f/9.0f,      0.0f,  2.0f/9.0f,
  254.    4.0f/9.0f,      0.0f,  2.0f/9.0f,    6.0f/9.0f,      0.0f,  2.0f/9.0f,    8.0f/9.0f,      0.0f,  2.0f/9.0f,
  255.   -8.0f/9.0f,  2.0f/9.0f,  2.0f/9.0f,   -6.0f/9.0f,  2.0f/9.0f,  2.0f/9.0f,   -4.0f/9.0f,  2.0f/9.0f,  2.0f/9.0f,
  256.   -2.0f/9.0f,  2.0f/9.0f,  2.0f/9.0f,        0.0f,  2.0f/9.0f,  2.0f/9.0f,    2.0f/9.0f,  2.0f/9.0f,  2.0f/9.0f,
  257.    4.0f/9.0f,  2.0f/9.0f,  2.0f/9.0f,    6.0f/9.0f,  2.0f/9.0f,  2.0f/9.0f,    8.0f/9.0f,  2.0f/9.0f,  2.0f/9.0f,
  258.   -8.0f/9.0f,  4.0f/9.0f,  2.0f/9.0f,   -6.0f/9.0f,  4.0f/9.0f,  2.0f/9.0f,   -4.0f/9.0f,  4.0f/9.0f,  2.0f/9.0f,
  259.   -2.0f/9.0f,  4.0f/9.0f,  2.0f/9.0f,        0.0f,  4.0f/9.0f,  2.0f/9.0f,    2.0f/9.0f,  4.0f/9.0f,  2.0f/9.0f,
  260. 4.0f/9.0f,  4.0f/9.0f,  2.0f/9.0f,    6.0f/9.0f,  4.0f/9.0f,  2.0f/9.0f,    8.0f/9.0f,  4.0f/9.0f,  2.0f/9.0f,
  261.   -8.0f/9.0f,  6.0f/9.0f,  2.0f/9.0f,   -6.0f/9.0f,  6.0f/9.0f,  2.0f/9.0f,   -4.0f/9.0f,  6.0f/9.0f,  2.0f/9.0f,
  262.   -2.0f/9.0f,  6.0f/9.0f,  2.0f/9.0f,        0.0f,  6.0f/9.0f,  2.0f/9.0f,    2.0f/9.0f,  6.0f/9.0f,  2.0f/9.0f,
  263.    4.0f/9.0f,  6.0f/9.0f,  2.0f/9.0f,    6.0f/9.0f,  6.0f/9.0f,  2.0f/9.0f,    8.0f/9.0f,  6.0f/9.0f,  2.0f/9.0f,
  264.   -8.0f/9.0f,  8.0f/9.0f,  2.0f/9.0f,   -6.0f/9.0f,  8.0f/9.0f,  2.0f/9.0f,   -4.0f/9.0f,  8.0f/9.0f,  2.0f/9.0f,
  265.   -2.0f/9.0f,  8.0f/9.0f,  2.0f/9.0f,        0.0f,  8.0f/9.0f,  2.0f/9.0f,    2.0f/9.0f,  8.0f/9.0f,  2.0f/9.0f,
  266.    4.0f/9.0f,  8.0f/9.0f,  2.0f/9.0f,    6.0f/9.0f,  8.0f/9.0f,  2.0f/9.0f,    8.0f/9.0f,  8.0f/9.0f,  2.0f/9.0f,
  267.   -8.0f/9.0f, -8.0f/9.0f,  4.0f/9.0f,   -6.0f/9.0f, -8.0f/9.0f,  4.0f/9.0f,   -4.0f/9.0f, -8.0f/9.0f,  4.0f/9.0f,
  268.   -2.0f/9.0f, -8.0f/9.0f,  4.0f/9.0f,        0.0f, -8.0f/9.0f,  4.0f/9.0f,    2.0f/9.0f, -8.0f/9.0f,  4.0f/9.0f,
  269. 4.0f/9.0f, -8.0f/9.0f,  4.0f/9.0f,    6.0f/9.0f, -8.0f/9.0f,  4.0f/9.0f,    8.0f/9.0f, -8.0f/9.0f,  4.0f/9.0f,
  270.   -8.0f/9.0f, -6.0f/9.0f,  4.0f/9.0f,   -6.0f/9.0f, -6.0f/9.0f,  4.0f/9.0f,   -4.0f/9.0f, -6.0f/9.0f,  4.0f/9.0f,
  271.   -2.0f/9.0f, -6.0f/9.0f,  4.0f/9.0f,        0.0f, -6.0f/9.0f,  4.0f/9.0f,    2.0f/9.0f, -6.0f/9.0f,  4.0f/9.0f,
  272.    4.0f/9.0f, -6.0f/9.0f,  4.0f/9.0f,    6.0f/9.0f, -6.0f/9.0f,  4.0f/9.0f,    8.0f/9.0f, -6.0f/9.0f,  4.0f/9.0f,
  273.   -8.0f/9.0f, -4.0f/9.0f,  4.0f/9.0f,   -6.0f/9.0f, -4.0f/9.0f,  4.0f/9.0f,   -4.0f/9.0f, -4.0f/9.0f,  4.0f/9.0f,
  274.   -2.0f/9.0f, -4.0f/9.0f,  4.0f/9.0f,        0.0f, -4.0f/9.0f,  4.0f/9.0f,    2.0f/9.0f, -4.0f/9.0f,  4.0f/9.0f,
  275.    4.0f/9.0f, -4.0f/9.0f,  4.0f/9.0f,    6.0f/9.0f, -4.0f/9.0f,  4.0f/9.0f,    8.0f/9.0f, -4.0f/9.0f,  4.0f/9.0f,
  276.   -8.0f/9.0f, -2.0f/9.0f,  4.0f/9.0f,   -6.0f/9.0f, -2.0f/9.0f,  4.0f/9.0f,   -4.0f/9.0f, -2.0f/9.0f,  4.0f/9.0f,
  277.   -2.0f/9.0f, -2.0f/9.0f,  4.0f/9.0f,        0.0f, -2.0f/9.0f,  4.0f/9.0f,    2.0f/9.0f, -2.0f/9.0f,  4.0f/9.0f,
  278. 4.0f/9.0f, -2.0f/9.0f,  4.0f/9.0f,    6.0f/9.0f, -2.0f/9.0f,  4.0f/9.0f,    8.0f/9.0f, -2.0f/9.0f,  4.0f/9.0f,
  279.   -8.0f/9.0f,      0.0f,  4.0f/9.0f,   -6.0f/9.0f,      0.0f,  4.0f/9.0f,   -4.0f/9.0f,      0.0f,  4.0f/9.0f,
  280.   -2.0f/9.0f,      0.0f,  4.0f/9.0f,        0.0f,      0.0f,  4.0f/9.0f,    2.0f/9.0f,      0.0f,  4.0f/9.0f,
  281.    4.0f/9.0f,      0.0f,  4.0f/9.0f,    6.0f/9.0f,      0.0f,  4.0f/9.0f,    8.0f/9.0f,      0.0f,  4.0f/9.0f,
  282.   -8.0f/9.0f,  2.0f/9.0f,  4.0f/9.0f,   -6.0f/9.0f,  2.0f/9.0f,  4.0f/9.0f,   -4.0f/9.0f,  2.0f/9.0f,  4.0f/9.0f,
  283.   -2.0f/9.0f,  2.0f/9.0f,  4.0f/9.0f,        0.0f,  2.0f/9.0f,  4.0f/9.0f,    2.0f/9.0f,  2.0f/9.0f,  4.0f/9.0f,
  284.    4.0f/9.0f,  2.0f/9.0f,  4.0f/9.0f,    6.0f/9.0f,  2.0f/9.0f,  4.0f/9.0f,    8.0f/9.0f,  2.0f/9.0f,  4.0f/9.0f,
  285.   -8.0f/9.0f,  4.0f/9.0f,  4.0f/9.0f,   -6.0f/9.0f,  4.0f/9.0f,  4.0f/9.0f,   -4.0f/9.0f,  4.0f/9.0f,  4.0f/9.0f,
  286.   -2.0f/9.0f,  4.0f/9.0f,  4.0f/9.0f,        0.0f,  4.0f/9.0f,  4.0f/9.0f,    2.0f/9.0f,  4.0f/9.0f,  4.0f/9.0f,
  287.    4.0f/9.0f,  4.0f/9.0f,  4.0f/9.0f,    6.0f/9.0f,  4.0f/9.0f,  4.0f/9.0f,    8.0f/9.0f,  4.0f/9.0f,  4.0f/9.0f,
  288.   -8.0f/9.0f,  6.0f/9.0f,  4.0f/9.0f,   -6.0f/9.0f,  6.0f/9.0f,  4.0f/9.0f,   -4.0f/9.0f,  6.0f/9.0f,  4.0f/9.0f,
  289.   -2.0f/9.0f,  6.0f/9.0f,  4.0f/9.0f,        0.0f,  6.0f/9.0f,  4.0f/9.0f,    2.0f/9.0f,  6.0f/9.0f,  4.0f/9.0f,
  290. 4.0f/9.0f,  6.0f/9.0f,  4.0f/9.0f,    6.0f/9.0f,  6.0f/9.0f,  4.0f/9.0f,    8.0f/9.0f,  6.0f/9.0f,  4.0f/9.0f,
  291.   -8.0f/9.0f,  8.0f/9.0f,  4.0f/9.0f,   -6.0f/9.0f,  8.0f/9.0f,  4.0f/9.0f,   -4.0f/9.0f,  8.0f/9.0f,  4.0f/9.0f,
  292.   -2.0f/9.0f,  8.0f/9.0f,  4.0f/9.0f,        0.0f,  8.0f/9.0f,  4.0f/9.0f,    2.0f/9.0f,  8.0f/9.0f,  4.0f/9.0f,
  293. 4.0f/9.0f,  8.0f/9.0f,  4.0f/9.0f,    6.0f/9.0f,  8.0f/9.0f,  4.0f/9.0f,    8.0f/9.0f,  8.0f/9.0f,  4.0f/9.0f,
  294.   -8.0f/9.0f, -8.0f/9.0f,  6.0f/9.0f,   -6.0f/9.0f, -8.0f/9.0f,  6.0f/9.0f,   -4.0f/9.0f, -8.0f/9.0f,  6.0f/9.0f,
  295.   -2.0f/9.0f, -8.0f/9.0f,  6.0f/9.0f,        0.0f, -8.0f/9.0f,  6.0f/9.0f,    2.0f/9.0f, -8.0f/9.0f,  6.0f/9.0f,
  296.    4.0f/9.0f, -8.0f/9.0f,  6.0f/9.0f,    6.0f/9.0f, -8.0f/9.0f,  6.0f/9.0f,    8.0f/9.0f, -8.0f/9.0f,  6.0f/9.0f,
  297.   -8.0f/9.0f, -6.0f/9.0f,  6.0f/9.0f,   -6.0f/9.0f, -6.0f/9.0f,  6.0f/9.0f,   -4.0f/9.0f, -6.0f/9.0f,  6.0f/9.0f,
  298.   -2.0f/9.0f, -6.0f/9.0f,  6.0f/9.0f,        0.0f, -6.0f/9.0f,  6.0f/9.0f,    2.0f/9.0f, -6.0f/9.0f,  6.0f/9.0f,
  299.    4.0f/9.0f, -6.0f/9.0f,  6.0f/9.0f,    6.0f/9.0f, -6.0f/9.0f,  6.0f/9.0f,    8.0f/9.0f, -6.0f/9.0f,  6.0f/9.0f,
  300.   -8.0f/9.0f, -4.0f/9.0f,  6.0f/9.0f,   -6.0f/9.0f, -4.0f/9.0f,  6.0f/9.0f,   -4.0f/9.0f, -4.0f/9.0f,  6.0f/9.0f,
  301.   -2.0f/9.0f, -4.0f/9.0f,  6.0f/9.0f,        0.0f, -4.0f/9.0f,  6.0f/9.0f,    2.0f/9.0f, -4.0f/9.0f,  6.0f/9.0f,
  302. 4.0f/9.0f, -4.0f/9.0f,  6.0f/9.0f,    6.0f/9.0f, -4.0f/9.0f,  6.0f/9.0f,    8.0f/9.0f, -4.0f/9.0f,  6.0f/9.0f,
  303.   -8.0f/9.0f, -2.0f/9.0f,  6.0f/9.0f,   -6.0f/9.0f, -2.0f/9.0f,  6.0f/9.0f,   -4.0f/9.0f, -2.0f/9.0f,  6.0f/9.0f,
  304.   -2.0f/9.0f, -2.0f/9.0f,  6.0f/9.0f,        0.0f, -2.0f/9.0f,  6.0f/9.0f,    2.0f/9.0f, -2.0f/9.0f,  6.0f/9.0f,
  305.    4.0f/9.0f, -2.0f/9.0f,  6.0f/9.0f,    6.0f/9.0f, -2.0f/9.0f,  6.0f/9.0f,    8.0f/9.0f, -2.0f/9.0f,  6.0f/9.0f,
  306.   -8.0f/9.0f,      0.0f,  6.0f/9.0f,   -6.0f/9.0f,      0.0f,  6.0f/9.0f,   -4.0f/9.0f,      0.0f,  6.0f/9.0f,
  307.   -2.0f/9.0f,      0.0f,  6.0f/9.0f,        0.0f,      0.0f,  6.0f/9.0f,    2.0f/9.0f,      0.0f,  6.0f/9.0f,
  308. 4.0f/9.0f,      0.0f,  6.0f/9.0f,    6.0f/9.0f,      0.0f,  6.0f/9.0f,    8.0f/9.0f,      0.0f,  6.0f/9.0f,
  309.   -8.0f/9.0f,  2.0f/9.0f,  6.0f/9.0f,   -6.0f/9.0f,  2.0f/9.0f,  6.0f/9.0f,   -4.0f/9.0f,  2.0f/9.0f,  6.0f/9.0f,
  310.   -2.0f/9.0f,  2.0f/9.0f,  6.0f/9.0f,        0.0f,  2.0f/9.0f,  6.0f/9.0f,    2.0f/9.0f,  2.0f/9.0f,  6.0f/9.0f,
  311. 4.0f/9.0f,  2.0f/9.0f,  6.0f/9.0f,    6.0f/9.0f,  2.0f/9.0f,  6.0f/9.0f,    8.0f/9.0f,  2.0f/9.0f,  6.0f/9.0f,
  312.   -8.0f/9.0f,  4.0f/9.0f,  6.0f/9.0f,   -6.0f/9.0f,  4.0f/9.0f,  6.0f/9.0f,   -4.0f/9.0f,  4.0f/9.0f,  6.0f/9.0f,
  313.   -2.0f/9.0f,  4.0f/9.0f,  6.0f/9.0f,        0.0f,  4.0f/9.0f,  6.0f/9.0f,    2.0f/9.0f,  4.0f/9.0f,  6.0f/9.0f,
  314. 4.0f/9.0f,  4.0f/9.0f,  6.0f/9.0f,    6.0f/9.0f,  4.0f/9.0f,  6.0f/9.0f,    8.0f/9.0f,  4.0f/9.0f,  6.0f/9.0f,
  315.   -8.0f/9.0f,  6.0f/9.0f,  6.0f/9.0f,   -6.0f/9.0f,  6.0f/9.0f,  6.0f/9.0f,   -4.0f/9.0f,  6.0f/9.0f,  6.0f/9.0f,
  316.   -2.0f/9.0f,  6.0f/9.0f,  6.0f/9.0f,        0.0f,  6.0f/9.0f,  6.0f/9.0f,    2.0f/9.0f,  6.0f/9.0f,  6.0f/9.0f,
  317. 4.0f/9.0f,  6.0f/9.0f,  6.0f/9.0f,    6.0f/9.0f,  6.0f/9.0f,  6.0f/9.0f,    8.0f/9.0f,  6.0f/9.0f,  6.0f/9.0f,
  318.   -8.0f/9.0f,  8.0f/9.0f,  6.0f/9.0f,   -6.0f/9.0f,  8.0f/9.0f,  6.0f/9.0f,   -4.0f/9.0f,  8.0f/9.0f,  6.0f/9.0f,
  319.   -2.0f/9.0f,  8.0f/9.0f,  6.0f/9.0f,        0.0f,  8.0f/9.0f,  6.0f/9.0f,    2.0f/9.0f,  8.0f/9.0f,  6.0f/9.0f,
  320. 4.0f/9.0f,  8.0f/9.0f,  6.0f/9.0f,    6.0f/9.0f,  8.0f/9.0f,  6.0f/9.0f,    8.0f/9.0f,  8.0f/9.0f,  6.0f/9.0f,
  321.   -8.0f/9.0f, -8.0f/9.0f,  8.0f/9.0f,   -6.0f/9.0f, -8.0f/9.0f,  8.0f/9.0f,   -4.0f/9.0f, -8.0f/9.0f,  8.0f/9.0f,
  322.   -2.0f/9.0f, -8.0f/9.0f,  8.0f/9.0f,        0.0f, -8.0f/9.0f,  8.0f/9.0f,    2.0f/9.0f, -8.0f/9.0f,  8.0f/9.0f,
  323.    4.0f/9.0f, -8.0f/9.0f,  8.0f/9.0f,    6.0f/9.0f, -8.0f/9.0f,  8.0f/9.0f,    8.0f/9.0f, -8.0f/9.0f,  8.0f/9.0f,
  324.   -8.0f/9.0f, -6.0f/9.0f,  8.0f/9.0f,   -6.0f/9.0f, -6.0f/9.0f,  8.0f/9.0f,   -4.0f/9.0f, -6.0f/9.0f,  8.0f/9.0f,
  325.   -2.0f/9.0f, -6.0f/9.0f,  8.0f/9.0f,        0.0f, -6.0f/9.0f,  8.0f/9.0f,    2.0f/9.0f, -6.0f/9.0f,  8.0f/9.0f,
  326. 4.0f/9.0f, -6.0f/9.0f,  8.0f/9.0f,    6.0f/9.0f, -6.0f/9.0f,  8.0f/9.0f,    8.0f/9.0f, -6.0f/9.0f,  8.0f/9.0f,
  327.   -8.0f/9.0f, -4.0f/9.0f,  8.0f/9.0f,   -6.0f/9.0f, -4.0f/9.0f,  8.0f/9.0f,   -4.0f/9.0f, -4.0f/9.0f,  8.0f/9.0f,
  328.   -2.0f/9.0f, -4.0f/9.0f,  8.0f/9.0f,        0.0f, -4.0f/9.0f,  8.0f/9.0f,    2.0f/9.0f, -4.0f/9.0f,  8.0f/9.0f,
  329.    4.0f/9.0f, -4.0f/9.0f,  8.0f/9.0f,    6.0f/9.0f, -4.0f/9.0f,  8.0f/9.0f,    8.0f/9.0f, -4.0f/9.0f,  8.0f/9.0f,
  330.   -8.0f/9.0f, -2.0f/9.0f,  8.0f/9.0f,   -6.0f/9.0f, -2.0f/9.0f,  8.0f/9.0f,   -4.0f/9.0f, -2.0f/9.0f,  8.0f/9.0f,
  331.   -2.0f/9.0f, -2.0f/9.0f,  8.0f/9.0f,        0.0f, -2.0f/9.0f,  8.0f/9.0f,    2.0f/9.0f, -2.0f/9.0f,  8.0f/9.0f,
  332.    4.0f/9.0f, -2.0f/9.0f,  8.0f/9.0f,    6.0f/9.0f, -2.0f/9.0f,  8.0f/9.0f,    8.0f/9.0f, -2.0f/9.0f,  8.0f/9.0f,
  333.   -8.0f/9.0f,      0.0f,  8.0f/9.0f,   -6.0f/9.0f,      0.0f,  8.0f/9.0f,   -4.0f/9.0f,      0.0f,  8.0f/9.0f,
  334.   -2.0f/9.0f,      0.0f,  8.0f/9.0f,        0.0f,      0.0f,  8.0f/9.0f,    2.0f/9.0f,      0.0f,  8.0f/9.0f,
  335.    4.0f/9.0f,      0.0f,  8.0f/9.0f,    6.0f/9.0f,      0.0f,  8.0f/9.0f,    8.0f/9.0f,      0.0f,  8.0f/9.0f,
  336.   -8.0f/9.0f,  2.0f/9.0f,  8.0f/9.0f,   -6.0f/9.0f,  2.0f/9.0f,  8.0f/9.0f,   -4.0f/9.0f,  2.0f/9.0f,  8.0f/9.0f,
  337.   -2.0f/9.0f,  2.0f/9.0f,  8.0f/9.0f,        0.0f,  2.0f/9.0f,  8.0f/9.0f,    2.0f/9.0f,  2.0f/9.0f,  8.0f/9.0f,
  338. 4.0f/9.0f,  2.0f/9.0f,  8.0f/9.0f,    6.0f/9.0f,  2.0f/9.0f,  8.0f/9.0f,    8.0f/9.0f,  2.0f/9.0f,  8.0f/9.0f,
  339.   -8.0f/9.0f,  4.0f/9.0f,  8.0f/9.0f,   -6.0f/9.0f,  4.0f/9.0f,  8.0f/9.0f,   -4.0f/9.0f,  4.0f/9.0f,  8.0f/9.0f,
  340.   -2.0f/9.0f,  4.0f/9.0f,  8.0f/9.0f,        0.0f,  4.0f/9.0f,  8.0f/9.0f,    2.0f/9.0f,  4.0f/9.0f,  8.0f/9.0f,
  341. 4.0f/9.0f,  4.0f/9.0f,  8.0f/9.0f,    6.0f/9.0f,  4.0f/9.0f,  8.0f/9.0f,    8.0f/9.0f,  4.0f/9.0f,  8.0f/9.0f,
  342.   -8.0f/9.0f,  6.0f/9.0f,  8.0f/9.0f,   -6.0f/9.0f,  6.0f/9.0f,  8.0f/9.0f,   -4.0f/9.0f,  6.0f/9.0f,  8.0f/9.0f,
  343.   -2.0f/9.0f,  6.0f/9.0f,  8.0f/9.0f,        0.0f,  6.0f/9.0f,  8.0f/9.0f,    2.0f/9.0f,  6.0f/9.0f,  8.0f/9.0f,
  344.    4.0f/9.0f,  6.0f/9.0f,  8.0f/9.0f,    6.0f/9.0f,  6.0f/9.0f,  8.0f/9.0f,    8.0f/9.0f,  6.0f/9.0f,  8.0f/9.0f,
  345.   -8.0f/9.0f,  8.0f/9.0f,  8.0f/9.0f,   -6.0f/9.0f,  8.0f/9.0f,  8.0f/9.0f,   -4.0f/9.0f,  8.0f/9.0f,  8.0f/9.0f,
  346.   -2.0f/9.0f,  8.0f/9.0f,  8.0f/9.0f,        0.0f,  8.0f/9.0f,  8.0f/9.0f,    2.0f/9.0f,  8.0f/9.0f,  8.0f/9.0f,
  347.    4.0f/9.0f,  8.0f/9.0f,  8.0f/9.0f,    6.0f/9.0f,  8.0f/9.0f,  8.0f/9.0f,    8.0f/9.0f,  8.0f/9.0f,  8.0f/9.0f
  348. };
  349. // data taken from ISO/IEC DIS 11172, Annexes 3-B.2[abcd] and 3-B.4:
  350. // subbands 0-2 in tables 3-B.2a and 2b: (index is allocation)
  351. static const uint32 table_ab1_codelength[16] =
  352.   // bits per codeword
  353. { 0, 5, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
  354. static const real *table_ab1_groupingtables[16] =
  355.   // pointer to sample grouping table, or NULL-pointer if ungrouped
  356. { 0, grouping_5bits, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  357. static const real table_ab1_factor[16] =
  358.   // factor for requantization: (real)sample * factor - 1.0 gives requantized sample
  359. { 0.0f, 1.0f/2.0f, 1.0f/4.0f, 1.0f/8.0f, 1.0f/16.0f, 1.0f/32.0f, 1.0f/64.0f,
  360.   1.0f/128.0f, 1.0f/256.0f, 1.0f/512.0f, 1.0f/1024.0f, 1.0f/2048.0f,
  361.   1.0f/4096.0f, 1.0f/8192.0f, 1.0f/16384.0f, 1.0f/32768.0f };
  362. static const real table_ab1_c[16] =
  363.   // factor c for requantization from table 3-B.4
  364. { 0.0f,           1.33333333333f, 1.14285714286f, 1.06666666666f, 1.03225806452f,
  365.   1.01587301587f, 1.00787401575f, 1.00392156863f, 1.00195694716f, 1.00097751711f,
  366.   1.00048851979f, 1.00024420024f, 1.00012208522f, 1.00006103888f, 1.00003051851f,
  367.   1.00001525902f };
  368. static const real table_ab1_d[16] =
  369.   // addend d for requantization from table 3-B.4
  370. { 0.0f,           0.50000000000f, 0.25000000000f, 0.12500000000f, 0.06250000000f,
  371.   0.03125000000f, 0.01562500000f, 0.00781250000f, 0.00390625000f, 0.00195312500f,
  372.   0.00097656250f, 0.00048828125f, 0.00024414063f, 0.00012207031f, 0.00006103516f,
  373.   0.00003051758f };
  374. // subbands 3-... tables 3-B.2a and 2b:
  375. static const real *table_ab234_groupingtables[16] =
  376. { 0, grouping_5bits, grouping_7bits, 0, grouping_10bits, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  377. // subbands 3-10 in tables 3-B.2a and 2b:
  378. static const uint32 table_ab2_codelength[16] =
  379. { 0, 5, 7, 3, 10, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16 };
  380. static const real table_ab2_factor[16] =
  381. { 0.0f, 1.0f/2.0f, 1.0f/4.0f, 1.0f/4.0f, 1.0f/8.0f, 1.0f/8.0f, 1.0f/16.0f,
  382.   1.0f/32.0f, 1.0f/64.0f, 1.0f/128.0f, 1.0f/256.0f, 1.0f/512.0f,
  383.   1.0f/1024.0f, 1.0f/2048.0f, 1.0f/4096.0f, 1.0f/32768.0f };
  384. static const real table_ab2_c[16] =
  385. { 0.0f,           1.33333333333f, 1.60000000000f, 1.14285714286f, 1.77777777777f,
  386.   1.06666666666f, 1.03225806452f, 1.01587301587f, 1.00787401575f, 1.00392156863f,
  387.   1.00195694716f, 1.00097751711f, 1.00048851979f, 1.00024420024f, 1.00012208522f,
  388.   1.00001525902f };
  389. static const real table_ab2_d[16] =
  390. { 0.0f,           0.50000000000f, 0.50000000000f, 0.25000000000f, 0.50000000000f,
  391.   0.12500000000f, 0.06250000000f, 0.03125000000f, 0.01562500000f, 0.00781250000f,
  392.   0.00390625000f, 0.00195312500f, 0.00097656250f, 0.00048828125f, 0.00024414063f,
  393.   0.00003051758f };
  394. // subbands 11-22 in tables 3-B.2a and 2b:
  395. static const uint32 table_ab3_codelength[8] = { 0, 5, 7, 3, 10, 4, 5, 16 };
  396. static const real table_ab3_factor[8] =
  397. { 0.0f, 1.0f/2.0f, 1.0f/4.0f, 1.0f/4.0f, 1.0f/8.0f, 1.0f/8.0f, 1.0f/16.0f, 1.0f/32768.0f };
  398. static const real table_ab3_c[8] =
  399. { 0.0f,           1.33333333333f, 1.60000000000f, 1.14285714286f, 1.77777777777f,
  400.   1.06666666666f, 1.03225806452f, 1.00001525902f };
  401. static const real table_ab3_d[8] =
  402. { 0.0f,           0.50000000000f, 0.50000000000f, 0.25000000000f, 0.50000000000f,
  403.   0.12500000000f, 0.06250000000f, 0.00003051758f };
  404. // subbands 23-... in tables 3-B.2a and 2b:
  405. static const uint32 table_ab4_codelength[4] = { 0, 5, 7, 16 };
  406. static const real table_ab4_factor[8] = { 0.0f, 1.0f/2.0f, 1.0f/4.0f, 1.0f/32768.0f };
  407. static const real table_ab4_c[4] = { 0.0f, 1.33333333333f, 1.60000000000f, 1.00001525902f };
  408. static const real table_ab4_d[4] = { 0.0f, 0.50000000000f, 0.50000000000f, 0.00003051758f };
  409. // subbands in tables 3-B.2c and 2d:
  410. static const uint32 table_cd_codelength[16] =
  411. { 0, 5, 7, 10, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
  412. static const real *table_cd_groupingtables[16] =
  413. { 0, grouping_5bits, grouping_7bits, grouping_10bits, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  414. static const real table_cd_factor[16] =
  415. { 0.0f, 1.0f/2.0f, 1.0f/4.0f, 1.0f/8.0f, 1.0f/8.0f, 1.0f/16.0f, 1.0f/32.0f, 1.0f/64.0f,
  416.   1.0f/128.0f, 1.0f/256.0f, 1.0f/512.0f, 1.0f/1024.0f, 1.0f/2048.0f, 1.0f/4096.0f,
  417.   1.0f/8192.0f, 1.0f/16384.0f };
  418. static const real table_cd_c[16] =
  419. { 0.0f,           1.33333333333f, 1.60000000000f, 1.77777777777f, 1.06666666666f,
  420.   1.03225806452f, 1.01587301587f, 1.00787401575f, 1.00392156863f, 1.00195694716f,
  421.   1.00097751711f, 1.00048851979f, 1.00024420024f, 1.00012208522f, 1.00006103888f,
  422.   1.00003051851f };
  423. static const real table_cd_d[16] =
  424. { 0.0f,           0.50000000000f, 0.50000000000f, 0.50000000000f, 0.12500000000f,
  425.   0.06250000000f, 0.03125000000f, 0.01562500000f, 0.00781250000f, 0.00390625000f,
  426.   0.00195312500f, 0.00097656250f, 0.00048828125f, 0.00024414063f, 0.00012207031f,
  427.   0.00006103516f };
  428. /**********************/ // used for single channel mode
  429. /*** Standard Class ***/ // and in derived class for intensity
  430. /**********************/ // stereo mode
  431. SubbandLayer2::SubbandLayer2(uint32 subbandnumber)
  432. {
  433.   this->subbandnumber = subbandnumber;
  434.   groupnumber = samplenumber = 0;
  435. }
  436. uint32 SubbandLayer2::get_allocationlength(Header *header)
  437. {
  438.   if (header->version() == MPEG1) {
  439.   uint32 channel_bitrate = header->bitrate_index();
  440.   // calculate bitrate per channel:
  441.   if (header->mode() != single_channel)
  442.  if (channel_bitrate == 4)
  443. channel_bitrate = 1;
  444.  else
  445. channel_bitrate -= 4;
  446.   if (channel_bitrate == 1 || channel_bitrate == 2)
  447.  // table 3-B.2c or 3-B.2d
  448.  if (subbandnumber <= 1)
  449. return 4;
  450.  else
  451. return 3;
  452.   else
  453.  // tables 3-B.2a or 3-B.2b
  454.  if (subbandnumber <= 10)
  455. return 4;
  456.  else if (subbandnumber <= 22)
  457. return 3;
  458.  else
  459. return 2;
  460.   } else { // MPEG-2 LSF -- Jeff
  461.   // table B.1 of ISO/IEC 13818-3
  462.      if (subbandnumber <= 3)
  463.       return 4;
  464.      else if (subbandnumber <= 10)
  465.       return 3;
  466.      else
  467.       return 2;
  468.   }
  469. }
  470. void SubbandLayer2::prepare_sample_reading(Header *header, uint32 allocation,
  471.    const real **groupingtable,
  472.                                            real *factor, uint32 *codelength,
  473.                                            real *c, real *d)
  474. {
  475.   uint32 channel_bitrate = header->bitrate_index();
  476.   // calculate bitrate per channel:
  477.   if (header->mode() != single_channel)
  478.  if (channel_bitrate == 4)
  479. channel_bitrate = 1;
  480.  else
  481. channel_bitrate -= 4;
  482.   if (channel_bitrate == 1 || channel_bitrate == 2)
  483.   {
  484.  // table 3-B.2c or 3-B.2d
  485.  *groupingtable = table_cd_groupingtables[allocation];
  486.  *factor = table_cd_factor[allocation];
  487.  *codelength = table_cd_codelength[allocation];
  488.  *c = table_cd_c[allocation];
  489.  *d = table_cd_d[allocation];
  490.   }
  491.   else
  492.   {
  493.  // tables 3-B.2a or 3-B.2b
  494.  if (subbandnumber <= 2)
  495.  {
  496. *groupingtable = table_ab1_groupingtables[allocation];
  497. *factor = table_ab1_factor[allocation];
  498. *codelength = table_ab1_codelength[allocation];
  499.       *c = table_ab1_c[allocation];
  500.       *d = table_ab1_d[allocation];
  501.     }
  502.  else
  503.  {
  504.       *groupingtable = table_ab234_groupingtables[allocation];
  505. if (subbandnumber <= 10)
  506. {
  507. *factor = table_ab2_factor[allocation];
  508. *codelength = table_ab2_codelength[allocation];
  509. *c = table_ab2_c[allocation];
  510. *d = table_ab2_d[allocation];
  511.       }
  512.       else if (subbandnumber <= 22)
  513.       {
  514. *factor = table_ab3_factor[allocation];
  515. *codelength = table_ab3_codelength[allocation];
  516. *c = table_ab3_c[allocation];
  517. *d = table_ab3_d[allocation];
  518.       }
  519. else
  520.       {
  521. *factor = table_ab4_factor[allocation];
  522. *codelength = table_ab4_codelength[allocation];
  523. *c = table_ab4_c[allocation];
  524. *d = table_ab4_d[allocation];
  525.       }
  526.     }
  527.   }
  528. }
  529. void SubbandLayer2::read_allocation(Ibitstream *stream, Header *header, Crc16 *crc)
  530. {
  531.   register uint32 length = get_allocationlength(header);
  532.   allocation = stream->get_bits(length);
  533.   if (crc)
  534.     crc->add_bits(allocation, length);
  535. }
  536. void SubbandLayer2::read_scalefactor_selection(Ibitstream *stream, Crc16 *crc)
  537. {
  538.   if (allocation)
  539.   {
  540.     scfsi = stream->get_bits(2);
  541.     if (crc)
  542. crc->add_bits(scfsi, 2);
  543.   }
  544. }
  545. void SubbandLayer2::read_scalefactor(Ibitstream *stream, Header *header)
  546. {
  547.   if (allocation)
  548.   {
  549.     switch (scfsi)
  550.     {
  551.       case 0:
  552.       scalefactor1 = scalefactors[stream->get_bits(6)];
  553.    scalefactor2 = scalefactors[stream->get_bits(6)];
  554.    scalefactor3 = scalefactors[stream->get_bits(6)];
  555.    break;
  556. case 1:
  557.    scalefactor1 = scalefactor2 = scalefactors[stream->get_bits(6)];
  558.    scalefactor3 = scalefactors[stream->get_bits(6)];
  559.    break;
  560.       case 2:
  561.    scalefactor1 = scalefactor2 = scalefactor3 =
  562.            scalefactors[stream->get_bits(6)];
  563. break;
  564. case 3:
  565.    scalefactor1 = scalefactors[stream->get_bits(6)];
  566.    scalefactor2 = scalefactor3 = scalefactors[stream->get_bits(6)];
  567.    break;
  568.     }
  569.     prepare_sample_reading(header, allocation, &groupingtable,
  570.     &factor, &codelength, &c, &d);
  571.   }
  572. }
  573. bool SubbandLayer2::read_sampledata(Ibitstream *stream)
  574. {
  575.   if (allocation)
  576.  if (groupingtable)
  577.  {
  578. uint32 samplecode = stream->get_bits(codelength);
  579. // create requantized samples:
  580. samplecode += samplecode << 1;
  581. register real *target = samples;
  582. register const real *source = groupingtable + samplecode;
  583. *target++ = *source++;
  584. *target++ = *source++;
  585. *target = *source;
  586. // memcpy (samples, groupingtable + samplecode, 3 * sizeof (real));
  587.  }
  588.  else
  589.  {
  590. samples[0] = real (stream->get_bits(codelength)) * factor - 1.0f;
  591. samples[1] = real (stream->get_bits(codelength)) * factor - 1.0f;
  592. samples[2] = real (stream->get_bits(codelength)) * factor - 1.0f;
  593.  }
  594.   samplenumber = 0;
  595.   if (++groupnumber == 12)
  596.  return true;
  597.   else
  598.  return false;
  599. }
  600. bool SubbandLayer2::put_next_sample (e_channels channels,
  601.  SynthesisFilter *filter1,
  602.                                      SynthesisFilter *)
  603. {
  604.   if (allocation && channels != right)
  605.   {
  606.  register real sample = samples[samplenumber];
  607.  if (!groupingtable)
  608. sample = (sample + d) * c;
  609.  if (groupnumber <= 4)
  610. sample *= scalefactor1;
  611.  else if (groupnumber <= 8)
  612. sample *= scalefactor2;
  613.  else
  614. sample *= scalefactor3;
  615.  filter1->input_sample(sample, subbandnumber);
  616.   }
  617.   if (++samplenumber == 3)
  618.  return true;
  619.   else
  620.  return false;
  621. }
  622. /******************************/
  623. /*** Intensity Stereo Class ***/
  624. /******************************/
  625. SubbandLayer2IntensityStereo::SubbandLayer2IntensityStereo(uint32 subbandnumber)
  626. : SubbandLayer2(subbandnumber)
  627. {
  628. }
  629. void SubbandLayer2IntensityStereo::read_scalefactor_selection(Ibitstream *stream,
  630.   Crc16 *crc)
  631. {
  632.   if (allocation)
  633.   {
  634.  scfsi = stream->get_bits(2);
  635.  channel2_scfsi = stream->get_bits(2);
  636.  if (crc)
  637.  {
  638. crc->add_bits(scfsi, 2);
  639. crc->add_bits(channel2_scfsi, 2);
  640.  }
  641.   }
  642. }
  643. void SubbandLayer2IntensityStereo::read_scalefactor(Ibitstream *stream, Header *header)
  644. {
  645.   if (allocation)
  646.   {
  647.  SubbandLayer2::read_scalefactor(stream, header);
  648.  switch (channel2_scfsi)
  649.  {
  650. case 0:
  651. channel2_scalefactor1 = scalefactors[stream->get_bits(6)];
  652. channel2_scalefactor2 = scalefactors[stream->get_bits(6)];
  653. channel2_scalefactor3 = scalefactors[stream->get_bits(6)];
  654. break;
  655. case 1:
  656. channel2_scalefactor1 = channel2_scalefactor2 = scalefactors[stream->get_bits (6)];
  657. channel2_scalefactor3 = scalefactors[stream->get_bits(6)];
  658. break;
  659. case 2:
  660. channel2_scalefactor1 = channel2_scalefactor2 =
  661. channel2_scalefactor3 = scalefactors[stream->get_bits(6)];
  662. break;
  663. case 3:
  664. channel2_scalefactor1 = scalefactors[stream->get_bits(6)];
  665. channel2_scalefactor2 = channel2_scalefactor3 = scalefactors[stream->get_bits (6)];
  666. break;
  667.  }
  668.   }
  669. }
  670. bool SubbandLayer2IntensityStereo::put_next_sample (e_channels channels,
  671. SynthesisFilter *filter1, SynthesisFilter *filter2)
  672. {
  673.   if (allocation)
  674.   {
  675.  register real sample = samples[samplenumber];
  676.  if (!groupingtable)
  677. sample = (sample + d) * c;
  678.     if (channels == both)
  679.     {
  680. register float sample2 = sample;
  681.       if (groupnumber <= 4)
  682.       {
  683. sample *= scalefactor1;
  684. sample2 *= channel2_scalefactor1;
  685. }
  686. else if (groupnumber <= 8)
  687. {
  688. sample *= scalefactor2;
  689. sample2 *= channel2_scalefactor2;
  690. }
  691. else
  692. {
  693. sample *= scalefactor3;
  694. sample2 *= channel2_scalefactor3;
  695. }
  696. filter1->input_sample(sample, subbandnumber);
  697.       filter2->input_sample(sample2, subbandnumber);
  698.     }
  699.     else if (channels == left)
  700.  {
  701. if (groupnumber <= 4)
  702. sample *= scalefactor1;
  703.       else if (groupnumber <= 8)
  704. sample *= scalefactor2;
  705. else
  706. sample *= scalefactor3;
  707. filter1->input_sample(sample, subbandnumber);
  708.  }
  709.  else
  710.  {
  711. if (groupnumber <= 4)
  712. sample *= channel2_scalefactor1;
  713. else if (groupnumber <= 8)
  714. sample *= channel2_scalefactor2;
  715. else
  716. sample *= channel2_scalefactor3;
  717. filter1->input_sample(sample, subbandnumber);
  718.  }
  719.   }
  720.   if (++samplenumber == 3)
  721.  return true;
  722.   else
  723.  return false;
  724. }
  725. /********************/
  726. /*** Stereo Class ***/
  727. /********************/
  728. SubbandLayer2Stereo::SubbandLayer2Stereo(uint32 subbandnumber)
  729. : SubbandLayer2(subbandnumber)
  730. {
  731. }
  732. void SubbandLayer2Stereo::read_allocation(Ibitstream *stream, Header *header, Crc16 *crc)
  733. {
  734.   uint32 length = get_allocationlength(header);
  735.   allocation = stream->get_bits(length);
  736.   channel2_allocation = stream->get_bits(length);
  737.   if (crc)
  738.   {
  739.  crc->add_bits(allocation, length);
  740.  crc->add_bits(channel2_allocation, length);
  741.   }
  742. }
  743. void SubbandLayer2Stereo::read_scalefactor_selection(Ibitstream *stream, Crc16 *crc)
  744. {
  745.   if (allocation)
  746.   {
  747.  scfsi = stream->get_bits(2);
  748.  if (crc)
  749. crc->add_bits(scfsi, 2);
  750.   }
  751.   if (channel2_allocation)
  752.   {
  753.  channel2_scfsi = stream->get_bits(2);
  754.  if (crc)
  755. crc->add_bits(channel2_scfsi, 2);
  756.   }
  757. }
  758. void SubbandLayer2Stereo::read_scalefactor(Ibitstream *stream, Header *header)
  759. {
  760.   SubbandLayer2::read_scalefactor(stream, header);
  761.   if (channel2_allocation)
  762.   {
  763.  switch (channel2_scfsi)
  764.  {
  765. case 0:
  766.       channel2_scalefactor1 = scalefactors[stream->get_bits(6)];
  767.    channel2_scalefactor2 = scalefactors[stream->get_bits(6)];
  768.    channel2_scalefactor3 = scalefactors[stream->get_bits(6)];
  769.    break;
  770. case 1:
  771.    channel2_scalefactor1 = channel2_scalefactor2 =
  772.              scalefactors[stream->get_bits(6)];
  773.    channel2_scalefactor3 = scalefactors[stream->get_bits(6)];
  774.    break;
  775. case 2:
  776.    channel2_scalefactor1 = channel2_scalefactor2 =
  777.    channel2_scalefactor3 = scalefactors[stream->get_bits(6)];
  778.    break;
  779. case 3:
  780.    channel2_scalefactor1 = scalefactors[stream->get_bits(6)];
  781.    channel2_scalefactor2 = channel2_scalefactor3 =
  782.           scalefactors[stream->get_bits(6)];
  783.       break;
  784.  }
  785.  prepare_sample_reading(header, channel2_allocation, &channel2_groupingtable,
  786.                            &channel2_factor, &channel2_codelength, &channel2_c,
  787.                            &channel2_d);
  788.   }
  789. }
  790. bool SubbandLayer2Stereo::read_sampledata(Ibitstream *stream)
  791. {
  792.   bool returnvalue = SubbandLayer2::read_sampledata(stream);
  793.   if (channel2_allocation)
  794.  if (channel2_groupingtable) {
  795. uint32 samplecode = stream->get_bits(channel2_codelength);
  796. // create requantized samples:
  797. samplecode += samplecode << 1;
  798. register real *target = channel2_samples;
  799. register const real *source = channel2_groupingtable + samplecode;
  800. *target++ = *source++;
  801. *target++ = *source++;
  802. *target = *source;
  803. // memcpy (channel2_samples, channel2_groupingtable + samplecode, 3 * sizeof (real));
  804.     } else {
  805. channel2_samples[0] = real (stream->get_bits(channel2_codelength)) *
  806.         channel2_factor - 1.0f;
  807. channel2_samples[1] = real (stream->get_bits(channel2_codelength)) *
  808.         channel2_factor - 1.0f;
  809. channel2_samples[2] = real (stream->get_bits(channel2_codelength)) *
  810.                             channel2_factor - 1.0f;
  811.  }
  812.   return returnvalue;
  813. }
  814. bool SubbandLayer2Stereo::put_next_sample(e_channels channels,
  815. SynthesisFilter *filter1,
  816.                                           SynthesisFilter *filter2)
  817. {
  818.   bool returnvalue = SubbandLayer2::put_next_sample(channels, filter1, filter2);
  819.   if (channel2_allocation && channels != left)
  820.   {
  821.  register real sample = channel2_samples[samplenumber - 1];
  822.  if (!channel2_groupingtable)
  823. sample = (sample + channel2_d) * channel2_c;
  824.  if (groupnumber <= 4)
  825. sample *= channel2_scalefactor1;
  826.  else if (groupnumber <= 8)
  827. sample *= channel2_scalefactor2;
  828.  else
  829. sample *= channel2_scalefactor3;
  830.  if (channels == both)
  831. filter2->input_sample(sample, subbandnumber);
  832.  else
  833. filter1->input_sample(sample, subbandnumber);
  834.   }
  835.   return returnvalue;
  836. }