add another test case for ssjava:
authoryeom <yeom>
Tue, 26 Apr 2011 00:44:47 +0000 (00:44 +0000)
committeryeom <yeom>
Tue, 26 Apr 2011 00:44:47 +0000 (00:44 +0000)
trying to put annotations on mp3 decoder source codes using the current ssjava scheme.

29 files changed:
Robust/src/Tests/ssJava/mp3decoder/BitReserve.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/Bitstream.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/BitstreamErrors.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/BitstreamException.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/Control.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/Crc16.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/Decoder.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/DecoderErrors.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/DecoderException.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/Equalizer.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/FrameDecoder.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/Header.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/InputStreamSource.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/JavaLayerError.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/JavaLayerErrors.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/JavaLayerException.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/JavaLayerHook.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/JavaLayerUtils.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/LayerIDecoder.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/LayerIIDecoder.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/Manager.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/Obuffer.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/OutputChannels.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/Player.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/SampleBuffer.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/Source.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/SynthesisFilter.java [new file with mode: 0644]
Robust/src/Tests/ssJava/mp3decoder/huffcodetab.java [new file with mode: 0644]

diff --git a/Robust/src/Tests/ssJava/mp3decoder/BitReserve.java b/Robust/src/Tests/ssJava/mp3decoder/BitReserve.java
new file mode 100644 (file)
index 0000000..9b6da48
--- /dev/null
@@ -0,0 +1,223 @@
+/*\r
+ * 11/19/04                    1.0 moved to LGPL.\r
+ * \r
+ * 12/12/99 0.0.7      Implementation stores single bits \r
+ *                                     as ints for better performance. mdm@techie.com.\r
+ *\r
+ * 02/28/99 0.0     Java Conversion by E.B, javalayer@javazoom.net\r
+ *\r
+ *                  Adapted from the public c code by Jeff Tsay.\r
+ *\r
+ *-----------------------------------------------------------------------\r
+ *   This program is free software; you can redistribute it and/or modify\r
+ *   it under the terms of the GNU Library General Public License as published\r
+ *   by the Free Software Foundation; either version 2 of the License, or\r
+ *   (at your option) any later version.\r
+ *\r
+ *   This program is distributed in the hope that it will be useful,\r
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *   GNU Library General Public License for more details.\r
+ *\r
+ *   You should have received a copy of the GNU Library General Public\r
+ *   License along with this program; if not, write to the Free Software\r
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ *----------------------------------------------------------------------\r
+ */\r
+\r
+package javazoom.jl.decoder;\r
+       \r
+/**\r
+ * Implementation of Bit Reservoir for Layer III.\r
+ * <p>\r
+ * The implementation stores single bits as a word in the buffer. If\r
+ * a bit is set, the corresponding word in the buffer will be non-zero.\r
+ * If a bit is clear, the corresponding word is zero. Although this\r
+ * may seem waseful, this can be a factor of two quicker than \r
+ * packing 8 bits to a byte and extracting. \r
+ * <p> \r
+ */\r
+\r
+// REVIEW: there is no range checking, so buffer underflow or overflow\r
+// can silently occur.\r
+final class BitReserve\r
+{\r
+   /**\r
+    * Size of the internal buffer to store the reserved bits.\r
+    * Must be a power of 2. And x8, as each bit is stored as a single\r
+    * entry.\r
+    */\r
+       private static final int                BUFSIZE = 4096*8;\r
+       \r
+       /**\r
+        * Mask that can be used to quickly implement the\r
+        * modulus operation on BUFSIZE.\r
+        */\r
+       private static final int                BUFSIZE_MASK = BUFSIZE-1;\r
+       \r
+       private int                                     offset, totbit, buf_byte_idx;\r
+       private final int[]                     buf = new int[BUFSIZE];\r
+       private int                                     buf_bit_idx;\r
+       \r
+   BitReserve()\r
+   {\r
+         \r
+         offset = 0;\r
+      totbit = 0;\r
+      buf_byte_idx = 0;          \r
+   }\r
+      \r
+   \r
+   /**\r
+    * Return totbit Field.\r
+       */\r
+   public int hsstell() \r
+   { \r
+          return(totbit); \r
+   }\r
+\r
+   /**\r
+    * Read a number bits from the bit stream.\r
+    * @param N the number of\r
+       */\r
+   public int hgetbits(int N)\r
+   {\r
+        totbit += N;\r
+        \r
+        int val = 0;\r
+        \r
+        int pos = buf_byte_idx;\r
+        if (pos+N < BUFSIZE)\r
+        {\r
+               while (N-- > 0)\r
+               {\r
+                       val <<= 1;\r
+                       val |= ((buf[pos++]!=0) ? 1 : 0);                \r
+               }\r
+       }\r
+        else\r
+        {       \r
+                while (N-- > 0)\r
+               {\r
+                        val <<= 1;                      \r
+                        val |= ((buf[pos]!=0) ? 1 : 0);\r
+                        pos = (pos+1) & BUFSIZE_MASK;\r
+               }                \r
+        }      \r
+        buf_byte_idx = pos;\r
+        return val;\r
+   }\r
+   \r
+        \r
+   \r
+   /**\r
+    * Read 1 bit from the bit stream.\r
+       */\r
+/*\r
+   public int hget1bit_old()\r
+   {\r
+         int val;\r
+         totbit++;\r
+         if (buf_bit_idx == 0)\r
+         {\r
+         buf_bit_idx = 8;\r
+            buf_byte_idx++;             \r
+         }\r
+      // BUFSIZE = 4096 = 2^12, so\r
+      // buf_byte_idx%BUFSIZE == buf_byte_idx & 0xfff\r
+      val = buf[buf_byte_idx & BUFSIZE_MASK] & putmask[buf_bit_idx];\r
+      buf_bit_idx--;\r
+         val = val >>> buf_bit_idx;\r
+      return val;   \r
+   }\r
+ */\r
+   /**\r
+    * Returns next bit from reserve.\r
+    * @returns 0 if next bit is reset, or 1 if next bit is set.\r
+    */\r
+   public int hget1bit()\r
+   {             \r
+         totbit++;       \r
+         int val = buf[buf_byte_idx];\r
+         buf_byte_idx = (buf_byte_idx+1) & BUFSIZE_MASK;\r
+      return val;\r
+   }\r
+   \r
+   /**\r
+    * Retrieves bits from the reserve.     \r
+    */\r
+/*   \r
+   public int readBits(int[] out, int len)\r
+   {\r
+               if (buf_bit_idx == 0)\r
+               {\r
+                  buf_bit_idx = 8;\r
+                  buf_byte_idx++;\r
+                  current = buf[buf_byte_idx & BUFSIZE_MASK];\r
+               }      \r
+               \r
+               \r
+               \r
+               // save total number of bits returned\r
+               len = buf_bit_idx;\r
+               buf_bit_idx = 0;\r
+                 \r
+               int b = current;\r
+               int count = len-1;\r
+                 \r
+               while (count >= 0)\r
+               {\r
+                   out[count--] = (b & 0x1);\r
+                   b >>>= 1;\r
+               }\r
+         \r
+               totbit += len;\r
+               return len;\r
+   }\r
+  */\r
+   \r
+   /**\r
+    * Write 8 bits into the bit stream.\r
+       */\r
+   public void hputbuf(int val)\r
+   {             \r
+          int ofs = offset;\r
+          buf[ofs++] = val & 0x80;\r
+          buf[ofs++] = val & 0x40;\r
+          buf[ofs++] = val & 0x20;\r
+          buf[ofs++] = val & 0x10;\r
+          buf[ofs++] = val & 0x08;\r
+          buf[ofs++] = val & 0x04;\r
+          buf[ofs++] = val & 0x02;\r
+          buf[ofs++] = val & 0x01;\r
+          \r
+          if (ofs==BUFSIZE)\r
+                       offset = 0;\r
+          else\r
+                       offset = ofs;\r
+          \r
+   }\r
\r
+   /**\r
+    * Rewind N bits in Stream.\r
+       */\r
+   public void rewindNbits(int N)\r
+   {\r
+         totbit -= N;            \r
+         buf_byte_idx -= N;\r
+         if (buf_byte_idx<0)\r
+                 buf_byte_idx += BUFSIZE;\r
+   }\r
+       \r
+   /**\r
+    * Rewind N bytes in Stream.\r
+       */\r
+   public void rewindNbytes(int N)\r
+   {\r
+      int bits = (N << 3);\r
+         totbit -= bits;\r
+         buf_byte_idx -= bits;   \r
+         if (buf_byte_idx<0)\r
+                 buf_byte_idx += BUFSIZE;\r
+   }\r
+}\r
diff --git a/Robust/src/Tests/ssJava/mp3decoder/Bitstream.java b/Robust/src/Tests/ssJava/mp3decoder/Bitstream.java
new file mode 100644 (file)
index 0000000..d91ea26
--- /dev/null
@@ -0,0 +1,655 @@
+/*\r
+ * 11/19/04  1.0 moved to LGPL.\r
+ * \r
+ * 11/17/04     Uncomplete frames discarded. E.B, javalayer@javazoom.net \r
+ *\r
+ * 12/05/03     ID3v2 tag returned. E.B, javalayer@javazoom.net \r
+ *\r
+ * 12/12/99     Based on Ibitstream. Exceptions thrown on errors,\r
+ *                      Temporary removed seek functionality. mdm@techie.com\r
+ *\r
+ * 02/12/99 : Java Conversion by E.B , javalayer@javazoom.net\r
+ *\r
+ * 04/14/97 : Added function prototypes for new syncing and seeking\r
+ * mechanisms. Also made this file portable. Changes made by Jeff Tsay\r
+ *\r
+ *  @(#) ibitstream.h 1.5, last edit: 6/15/94 16:55:34\r
+ *  @(#) Copyright (C) 1993, 1994 Tobias Bading (bading@cs.tu-berlin.de)\r
+ *  @(#) Berlin University of Technology\r
+ *-----------------------------------------------------------------------\r
+ *   This program is free software; you can redistribute it and/or modify\r
+ *   it under the terms of the GNU Library General Public License as published\r
+ *   by the Free Software Foundation; either version 2 of the License, or\r
+ *   (at your option) any later version.\r
+ *\r
+ *   This program is distributed in the hope that it will be useful,\r
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *   GNU Library General Public License for more details.\r
+ *\r
+ *   You should have received a copy of the GNU Library General Public\r
+ *   License along with this program; if not, write to the Free Software\r
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ *----------------------------------------------------------------------\r
+ */\r
+\r
+package javazoom.jl.decoder;\r
+\r
+import java.io.BufferedInputStream;\r
+import java.io.ByteArrayInputStream;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.io.PushbackInputStream;\r
+\r
+\r
+/**\r
+ * The <code>Bistream</code> class is responsible for parsing\r
+ * an MPEG audio bitstream.\r
+ *\r
+ * <b>REVIEW:</b> much of the parsing currently occurs in the\r
+ * various decoders. This should be moved into this class and associated\r
+ * inner classes.\r
+ */\r
+public final class Bitstream implements BitstreamErrors\r
+{\r
+       /**\r
+        * Synchronization control constant for the initial\r
+        * synchronization to the start of a frame.\r
+        */\r
+       static byte             INITIAL_SYNC = 0;\r
+\r
+       /**\r
+        * Synchronization control constant for non-initial frame\r
+        * synchronizations.\r
+        */\r
+       static byte             STRICT_SYNC = 1;\r
+\r
+       // max. 1730 bytes per frame: 144 * 384kbit/s / 32000 Hz + 2 Bytes CRC\r
+       /**\r
+        * Maximum size of the frame buffer.\r
+        */\r
+       private static final int        BUFFER_INT_SIZE = 433;\r
+\r
+       /**\r
+        * The frame buffer that holds the data for the current frame.\r
+        */\r
+       private final int[]             framebuffer = new int[BUFFER_INT_SIZE];\r
+\r
+       /**\r
+        * Number of valid bytes in the frame buffer.\r
+        */\r
+       private int                             framesize;\r
+\r
+       /**\r
+        * The bytes read from the stream.\r
+        */\r
+       private byte[]                  frame_bytes = new byte[BUFFER_INT_SIZE*4];\r
+\r
+       /**\r
+        * Index into <code>framebuffer</code> where the next bits are\r
+        * retrieved.\r
+        */\r
+       private int                             wordpointer;\r
+\r
+       /**\r
+        * Number (0-31, from MSB to LSB) of next bit for get_bits()\r
+        */\r
+       private int                             bitindex;\r
+\r
+       /**\r
+        * The current specified syncword\r
+        */\r
+       private int                             syncword;\r
+       \r
+       /**\r
+        * Audio header position in stream.\r
+        */\r
+       private int                             header_pos = 0;\r
+\r
+       /**\r
+        *\r
+        */\r
+       private boolean                 single_ch_mode;\r
+  //private int                        current_frame_number;\r
+  //private int                                last_frame_number;\r
+\r
+       private final int               bitmask[] = {0, // dummy\r
+        0x00000001, 0x00000003, 0x00000007, 0x0000000F,\r
+        0x0000001F, 0x0000003F, 0x0000007F, 0x000000FF,\r
+        0x000001FF, 0x000003FF, 0x000007FF, 0x00000FFF,\r
+        0x00001FFF, 0x00003FFF, 0x00007FFF, 0x0000FFFF,\r
+     0x0001FFFF };\r
+\r
+       private final PushbackInputStream       source;\r
+\r
+       private final Header                    header = new Header();\r
+\r
+       private final byte                              syncbuf[] = new byte[4];\r
+\r
+       private Crc16[]                                 crc = new Crc16[1];\r
+\r
+       private byte[]                                  rawid3v2 = null;\r
+\r
+       private boolean                                 firstframe = true;\r
+\r
+\r
+       /**\r
+        * Construct a IBitstream that reads data from a\r
+        * given InputStream.\r
+        *\r
+        * @param in    The InputStream to read from.\r
+        */\r
+       public Bitstream(InputStream in)\r
+       {\r
+               if (in==null) throw new NullPointerException("in");\r
+               in = new BufferedInputStream(in);               \r
+               loadID3v2(in);\r
+               firstframe = true;\r
+               //source = new PushbackInputStream(in, 1024);\r
+               source = new PushbackInputStream(in, BUFFER_INT_SIZE*4);\r
+               \r
+               closeFrame();\r
+               //current_frame_number = -1;\r
+               //last_frame_number = -1;\r
+       }\r
+\r
+       /**\r
+        * Return position of the first audio header.\r
+        * @return size of ID3v2 tag frames.\r
+        */\r
+       public int header_pos()\r
+       {\r
+               return header_pos;\r
+       }\r
+       \r
+       /**\r
+        * Load ID3v2 frames.\r
+        * @param in MP3 InputStream.\r
+        * @author JavaZOOM\r
+        */\r
+       private void loadID3v2(InputStream in)\r
+       {               \r
+               int size = -1;\r
+               try\r
+               {\r
+                       // Read ID3v2 header (10 bytes).\r
+                       in.mark(10);                    \r
+                       size = readID3v2Header(in);\r
+                       header_pos = size;                      \r
+               }\r
+               catch (IOException e)\r
+               {}\r
+               finally\r
+               {\r
+                       try\r
+                       {\r
+                               // Unread ID3v2 header (10 bytes).\r
+                               in.reset();\r
+                       }\r
+                       catch (IOException e)\r
+                       {}\r
+               }\r
+               // Load ID3v2 tags.\r
+               try\r
+               {\r
+                       if (size > 0)\r
+                       {\r
+                               rawid3v2 = new byte[size];\r
+                               in.read(rawid3v2,0,rawid3v2.length);\r
+                       }                       \r
+               }\r
+               catch (IOException e)\r
+               {}\r
+       }\r
+       \r
+       /**\r
+        * Parse ID3v2 tag header to find out size of ID3v2 frames. \r
+        * @param in MP3 InputStream\r
+        * @return size of ID3v2 frames + header\r
+        * @throws IOException\r
+        * @author JavaZOOM\r
+        */\r
+       private int readID3v2Header(InputStream in) throws IOException\r
+       {               \r
+               byte[] id3header = new byte[4];\r
+               int size = -10;\r
+               in.read(id3header,0,3);\r
+               // Look for ID3v2\r
+               if ( (id3header[0]=='I') && (id3header[1]=='D') && (id3header[2]=='3'))\r
+               {\r
+                       in.read(id3header,0,3);\r
+                       int majorVersion = id3header[0];\r
+                       int revision = id3header[1];\r
+                       in.read(id3header,0,4);\r
+                       size = (int) (id3header[0] << 21) + (id3header[1] << 14) + (id3header[2] << 7) + (id3header[3]);\r
+               }\r
+               return (size+10);\r
+       }\r
+       \r
+       /**\r
+        * Return raw ID3v2 frames + header.\r
+        * @return ID3v2 InputStream or null if ID3v2 frames are not available.\r
+        */\r
+       public InputStream getRawID3v2()\r
+       {\r
+               if (rawid3v2 == null) return null;\r
+               else\r
+               {\r
+                       ByteArrayInputStream bain = new ByteArrayInputStream(rawid3v2);         \r
+                       return bain;\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Close the Bitstream.\r
+        * @throws BitstreamException\r
+        */\r
+       public void close() throws BitstreamException\r
+       {\r
+               try\r
+               {\r
+                       source.close();\r
+               }\r
+               catch (IOException ex)\r
+               {\r
+                       throw newBitstreamException(STREAM_ERROR, ex);\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Reads and parses the next frame from the input source.\r
+        * @return the Header describing details of the frame read,\r
+        *      or null if the end of the stream has been reached.\r
+        */\r
+       public Header readFrame() throws BitstreamException\r
+       {\r
+               Header result = null;\r
+               try\r
+               {\r
+                       result = readNextFrame();\r
+                       // E.B, Parse VBR (if any) first frame.\r
+                       if (firstframe == true)\r
+                       {\r
+                               result.parseVBR(frame_bytes);\r
+                               firstframe = false;\r
+                       }                       \r
+               }\r
+               catch (BitstreamException ex)\r
+               {\r
+                       if ((ex.getErrorCode()==INVALIDFRAME))\r
+                       {\r
+                               // Try to skip this frame.\r
+                               //System.out.println("INVALIDFRAME");\r
+                               try\r
+                               {\r
+                                       closeFrame();\r
+                                       result = readNextFrame();\r
+                               }\r
+                               catch (BitstreamException e)\r
+                               {\r
+                                       if ((e.getErrorCode()!=STREAM_EOF))\r
+                                       {\r
+                                               // wrap original exception so stack trace is maintained.\r
+                                               throw newBitstreamException(e.getErrorCode(), e);\r
+                                       }\r
+                               }\r
+                       }\r
+                       else if ((ex.getErrorCode()!=STREAM_EOF))\r
+                       {\r
+                               // wrap original exception so stack trace is maintained.\r
+                               throw newBitstreamException(ex.getErrorCode(), ex);\r
+                       }\r
+               }\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * Read next MP3 frame.\r
+        * @return MP3 frame header.\r
+        * @throws BitstreamException\r
+        */\r
+       private Header readNextFrame() throws BitstreamException\r
+       {\r
+               if (framesize == -1)\r
+               {\r
+                       nextFrame();\r
+               }\r
+               return header;\r
+       }\r
+\r
+\r
+       /**\r
+        * Read next MP3 frame.\r
+        * @throws BitstreamException\r
+        */\r
+       private void nextFrame() throws BitstreamException\r
+       {\r
+               // entire frame is read by the header class.\r
+               header.read_header(this, crc);\r
+       }\r
+\r
+       /**\r
+        * Unreads the bytes read from the frame.\r
+        * @throws BitstreamException\r
+        */\r
+       // REVIEW: add new error codes for this.\r
+       public void unreadFrame() throws BitstreamException\r
+       {\r
+               if (wordpointer==-1 && bitindex==-1 && (framesize>0))\r
+               {\r
+                       try\r
+                       {\r
+                               source.unread(frame_bytes, 0, framesize);\r
+                       }\r
+                       catch (IOException ex)\r
+                       {\r
+                               throw newBitstreamException(STREAM_ERROR);\r
+                       }\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Close MP3 frame.\r
+        */\r
+       public void closeFrame()\r
+       {\r
+               framesize = -1;\r
+               wordpointer = -1;\r
+               bitindex = -1;\r
+       }\r
+\r
+       /**\r
+        * Determines if the next 4 bytes of the stream represent a\r
+        * frame header.\r
+        */\r
+       public boolean isSyncCurrentPosition(int syncmode) throws BitstreamException\r
+       {\r
+               int read = readBytes(syncbuf, 0, 4);\r
+               int headerstring = ((syncbuf[0] << 24) & 0xFF000000) | ((syncbuf[1] << 16) & 0x00FF0000) | ((syncbuf[2] << 8) & 0x0000FF00) | ((syncbuf[3] << 0) & 0x000000FF);\r
+\r
+               try\r
+               {\r
+                       source.unread(syncbuf, 0, read);\r
+               }\r
+               catch (IOException ex)\r
+               {\r
+               }\r
+\r
+               boolean sync = false;\r
+               switch (read)\r
+               {\r
+                       case 0:\r
+                               sync = true;\r
+                               break;\r
+                       case 4:\r
+                               sync = isSyncMark(headerstring, syncmode, syncword);\r
+                               break;\r
+               }\r
+\r
+               return sync;\r
+       }\r
+\r
+\r
+       // REVIEW: this class should provide inner classes to\r
+       // parse the frame contents. Eventually, readBits will\r
+       // be removed.\r
+       public int readBits(int n)\r
+       {\r
+               return get_bits(n);\r
+       }\r
+\r
+       public int readCheckedBits(int n)\r
+       {\r
+               // REVIEW: implement CRC check.\r
+               return get_bits(n);\r
+       }\r
+\r
+       protected BitstreamException newBitstreamException(int errorcode)\r
+       {\r
+               return new BitstreamException(errorcode, null);\r
+       }\r
+       protected BitstreamException newBitstreamException(int errorcode, Throwable throwable)\r
+       {\r
+               return new BitstreamException(errorcode, throwable);\r
+       }\r
+\r
+  /**\r
+   * Get next 32 bits from bitstream.\r
+   * They are stored in the headerstring.\r
+   * syncmod allows Synchro flag ID\r
+   * The returned value is False at the end of stream.\r
+   */\r
+\r
+       int syncHeader(byte syncmode) throws BitstreamException\r
+       {\r
+               boolean sync;\r
+               int headerstring;\r
+               // read additional 2 bytes\r
+               int bytesRead = readBytes(syncbuf, 0, 3);\r
+\r
+               if (bytesRead!=3) throw newBitstreamException(STREAM_EOF, null);\r
+\r
+               headerstring = ((syncbuf[0] << 16) & 0x00FF0000) | ((syncbuf[1] << 8) & 0x0000FF00) | ((syncbuf[2] << 0) & 0x000000FF);\r
+\r
+               do\r
+               {\r
+                       headerstring <<= 8;\r
+\r
+                       if (readBytes(syncbuf, 3, 1)!=1)\r
+                               throw newBitstreamException(STREAM_EOF, null);\r
+\r
+                       headerstring |= (syncbuf[3] & 0x000000FF);\r
+\r
+                       sync = isSyncMark(headerstring, syncmode, syncword);\r
+               }\r
+               while (!sync);\r
+\r
+               //current_frame_number++;\r
+               //if (last_frame_number < current_frame_number) last_frame_number = current_frame_number;\r
+\r
+               return headerstring;\r
+       }\r
+\r
+       public boolean isSyncMark(int headerstring, int syncmode, int word)\r
+       {\r
+               boolean sync = false;\r
+\r
+               if (syncmode == INITIAL_SYNC)\r
+               {\r
+                       //sync =  ((headerstring & 0xFFF00000) == 0xFFF00000);\r
+                       sync =  ((headerstring & 0xFFE00000) == 0xFFE00000);    // SZD: MPEG 2.5\r
+               }\r
+               else\r
+               {\r
+                       sync =  ((headerstring & 0xFFF80C00) == word) &&\r
+                           (((headerstring & 0x000000C0) == 0x000000C0) == single_ch_mode);\r
+               }\r
+\r
+               // filter out invalid sample rate\r
+               if (sync)\r
+                       sync = (((headerstring >>> 10) & 3)!=3);\r
+               // filter out invalid layer\r
+               if (sync)\r
+                       sync = (((headerstring >>> 17) & 3)!=0);\r
+               // filter out invalid version\r
+               if (sync)\r
+                       sync = (((headerstring >>> 19) & 3)!=1);\r
+\r
+               return sync;\r
+       }\r
+\r
+       /**\r
+        * Reads the data for the next frame. The frame is not parsed\r
+        * until parse frame is called.\r
+        */\r
+       int read_frame_data(int bytesize) throws BitstreamException\r
+       {\r
+               int     numread = 0;\r
+               numread = readFully(frame_bytes, 0, bytesize);\r
+               framesize = bytesize;\r
+               wordpointer = -1;\r
+           bitindex = -1;\r
+           return numread;\r
+       }\r
+\r
+  /**\r
+   * Parses the data previously read with read_frame_data().\r
+   */\r
+  void parse_frame() throws BitstreamException\r
+  {\r
+       // Convert Bytes read to int\r
+       int     b=0;\r
+       byte[] byteread = frame_bytes;\r
+       int bytesize = framesize;\r
+\r
+       // Check ID3v1 TAG (True only if last frame).\r
+       //for (int t=0;t<(byteread.length)-2;t++)\r
+       //{\r
+       //      if ((byteread[t]=='T') && (byteread[t+1]=='A') && (byteread[t+2]=='G'))\r
+       //      {\r
+       //              System.out.println("ID3v1 detected at offset "+t);\r
+       //              throw newBitstreamException(INVALIDFRAME, null);\r
+       //      }       \r
+       //}\r
+       \r
+       for (int k=0;k<bytesize;k=k+4)\r
+       {\r
+               int convert = 0;\r
+               byte b0 = 0;\r
+               byte b1 = 0;\r
+               byte b2 = 0;\r
+               byte b3 = 0;\r
+               b0 = byteread[k];\r
+               if (k+1<bytesize) b1 = byteread[k+1];\r
+               if (k+2<bytesize) b2 = byteread[k+2];\r
+               if (k+3<bytesize) b3 = byteread[k+3];\r
+               framebuffer[b++] = ((b0 << 24) &0xFF000000) | ((b1 << 16) & 0x00FF0000) | ((b2 << 8) & 0x0000FF00) | (b3 & 0x000000FF);\r
+       }\r
+       wordpointer = 0;\r
+    bitindex = 0;\r
+  }\r
+\r
+  /**\r
+   * Read bits from buffer into the lower bits of an unsigned int.\r
+   * The LSB contains the latest read bit of the stream.\r
+   * (1 <= number_of_bits <= 16)\r
+   */\r
+  public int get_bits(int number_of_bits)\r
+  {\r
+       int                             returnvalue = 0;\r
+       int                     sum = bitindex + number_of_bits;\r
+\r
+       // E.B\r
+       // There is a problem here, wordpointer could be -1 ?!\r
+    if (wordpointer < 0) wordpointer = 0;\r
+    // E.B : End.\r
+\r
+       if (sum <= 32)\r
+       {\r
+          // all bits contained in *wordpointer\r
+          returnvalue = (framebuffer[wordpointer] >>> (32 - sum)) & bitmask[number_of_bits];\r
+          // returnvalue = (wordpointer[0] >> (32 - sum)) & bitmask[number_of_bits];\r
+          if ((bitindex += number_of_bits) == 32)\r
+          {\r
+                bitindex = 0;\r
+                wordpointer++; // added by me!\r
+          }\r
+          return returnvalue;\r
+    }\r
+\r
+    // E.B : Check that ?\r
+    //((short[])&returnvalue)[0] = ((short[])wordpointer + 1)[0];\r
+    //wordpointer++; // Added by me!\r
+    //((short[])&returnvalue + 1)[0] = ((short[])wordpointer)[0];\r
+       int Right = (framebuffer[wordpointer] & 0x0000FFFF);\r
+       wordpointer++;\r
+       int Left = (framebuffer[wordpointer] & 0xFFFF0000);\r
+       returnvalue = ((Right << 16) & 0xFFFF0000) | ((Left >>> 16)& 0x0000FFFF);\r
+\r
+    returnvalue >>>= 48 - sum; // returnvalue >>= 16 - (number_of_bits - (32 - bitindex))\r
+    returnvalue &= bitmask[number_of_bits];\r
+    bitindex = sum - 32;\r
+    return returnvalue;\r
+}\r
+\r
+       /**\r
+        * Set the word we want to sync the header to.\r
+        * In Big-Endian byte order\r
+        */\r
+       void set_syncword(int syncword0)\r
+       {\r
+               syncword = syncword0 & 0xFFFFFF3F;\r
+               single_ch_mode = ((syncword0 & 0x000000C0) == 0x000000C0);\r
+       }\r
+       /**\r
+        * Reads the exact number of bytes from the source\r
+        * input stream into a byte array.\r
+        *\r
+        * @param b             The byte array to read the specified number\r
+        *                              of bytes into.\r
+        * @param offs  The index in the array where the first byte\r
+        *                              read should be stored.\r
+        * @param len   the number of bytes to read.\r
+        *\r
+        * @exception BitstreamException is thrown if the specified\r
+        *              number of bytes could not be read from the stream.\r
+        */\r
+       private int readFully(byte[] b, int offs, int len)\r
+               throws BitstreamException\r
+       {               \r
+               int nRead = 0;\r
+               try\r
+               {\r
+                       while (len > 0)\r
+                       {\r
+                               int bytesread = source.read(b, offs, len);\r
+                               if (bytesread == -1)\r
+                               {\r
+                                       while (len-->0)\r
+                                       {\r
+                                               b[offs++] = 0;\r
+                                       }\r
+                                       break;\r
+                                       //throw newBitstreamException(UNEXPECTED_EOF, new EOFException());\r
+                               }\r
+                               nRead = nRead + bytesread;\r
+                               offs += bytesread;\r
+                               len -= bytesread;\r
+                       }\r
+               }\r
+               catch (IOException ex)\r
+               {\r
+                       throw newBitstreamException(STREAM_ERROR, ex);\r
+               }\r
+               return nRead;\r
+       }\r
+\r
+       /**\r
+        * Simlar to readFully, but doesn't throw exception when\r
+        * EOF is reached.\r
+        */\r
+       private int readBytes(byte[] b, int offs, int len)\r
+               throws BitstreamException\r
+       {\r
+               int totalBytesRead = 0;\r
+               try\r
+               {\r
+                       while (len > 0)\r
+                       {\r
+                               int bytesread = source.read(b, offs, len);\r
+                               if (bytesread == -1)\r
+                               {\r
+                                       break;\r
+                               }\r
+                               totalBytesRead += bytesread;\r
+                               offs += bytesread;\r
+                               len -= bytesread;\r
+                       }\r
+               }\r
+               catch (IOException ex)\r
+               {\r
+                       throw newBitstreamException(STREAM_ERROR, ex);\r
+               }\r
+               return totalBytesRead;\r
+       }\r
+}\r
diff --git a/Robust/src/Tests/ssJava/mp3decoder/BitstreamErrors.java b/Robust/src/Tests/ssJava/mp3decoder/BitstreamErrors.java
new file mode 100644 (file)
index 0000000..26daeb9
--- /dev/null
@@ -0,0 +1,72 @@
+/*\r
+ * 11/19/04            1.0 moved to LGPL.\r
+ * 11/17/04            INVALIDFRAME code added.        javalayer@javazoom.net\r
+ * 12/12/99            Initial version.                        mdm@techie.com\r
+ *-----------------------------------------------------------------------\r
+ *   This program is free software; you can redistribute it and/or modify\r
+ *   it under the terms of the GNU Library General Public License as published\r
+ *   by the Free Software Foundation; either version 2 of the License, or\r
+ *   (at your option) any later version.\r
+ *\r
+ *   This program is distributed in the hope that it will be useful,\r
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *   GNU Library General Public License for more details.\r
+ *\r
+ *   You should have received a copy of the GNU Library General Public\r
+ *   License along with this program; if not, write to the Free Software\r
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ *----------------------------------------------------------------------\r
+ */\r
+\r
+package javazoom.jl.decoder;\r
+\r
+/**\r
+ * This interface describes all error codes that can be thrown \r
+ * in <code>BistreamException</code>s.\r
+ * \r
+ * @see BitstreamException\r
+ * \r
+ * @author     MDM             12/12/99\r
+ * @since      0.0.6\r
+ */\r
+\r
+public interface BitstreamErrors extends JavaLayerErrors\r
+{\r
+       \r
+       /**\r
+        * An undeterminable error occurred. \r
+        */\r
+       static public final int UNKNOWN_ERROR = BITSTREAM_ERROR + 0;\r
+       \r
+       /**\r
+        * The header describes an unknown sample rate.\r
+        */\r
+       static public final int UNKNOWN_SAMPLE_RATE = BITSTREAM_ERROR + 1;\r
+\r
+       /**\r
+        * A problem occurred reading from the stream.\r
+        */\r
+       static public final int STREAM_ERROR = BITSTREAM_ERROR + 2;\r
+       \r
+       /**\r
+        * The end of the stream was reached prematurely. \r
+        */\r
+       static public final int UNEXPECTED_EOF = BITSTREAM_ERROR + 3;\r
+       \r
+       /**\r
+        * The end of the stream was reached. \r
+        */\r
+       static public final int STREAM_EOF = BITSTREAM_ERROR + 4;\r
+       \r
+       /**\r
+        * Frame data are missing. \r
+        */\r
+       static public final int INVALIDFRAME = BITSTREAM_ERROR + 5;\r
+\r
+       /**\r
+        * \r
+        */\r
+       static public final int BITSTREAM_LAST = 0x1ff;\r
+       \r
+}\r
diff --git a/Robust/src/Tests/ssJava/mp3decoder/BitstreamException.java b/Robust/src/Tests/ssJava/mp3decoder/BitstreamException.java
new file mode 100644 (file)
index 0000000..e4afb1a
--- /dev/null
@@ -0,0 +1,71 @@
+/*\r
+ * 11/19/04            1.0 moved to LGPL.\r
+ * 12/12/99            Initial version.        mdm@techie.com\r
+ *-----------------------------------------------------------------------\r
+ *   This program is free software; you can redistribute it and/or modify\r
+ *   it under the terms of the GNU Library General Public License as published\r
+ *   by the Free Software Foundation; either version 2 of the License, or\r
+ *   (at your option) any later version.\r
+ *\r
+ *   This program is distributed in the hope that it will be useful,\r
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *   GNU Library General Public License for more details.\r
+ *\r
+ *   You should have received a copy of the GNU Library General Public\r
+ *   License along with this program; if not, write to the Free Software\r
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ *----------------------------------------------------------------------\r
+ */\r
+\r
+package javazoom.jl.decoder;\r
+\r
+/**\r
+ * Instances of <code>BitstreamException</code> are thrown \r
+ * when operations on a <code>Bitstream</code> fail. \r
+ * <p>\r
+ * The exception provides details of the exception condition \r
+ * in two ways:\r
+ * <ol><li>\r
+ *             as an error-code describing the nature of the error\r
+ * </li><br></br><li>\r
+ *             as the <code>Throwable</code> instance, if any, that was thrown\r
+ *             indicating that an exceptional condition has occurred. \r
+ * </li></ol></p>\r
+ * \r
+ * @since 0.0.6\r
+ * @author MDM 12/12/99\r
+ */\r
+\r
+public class BitstreamException extends JavaLayerException\r
+       implements BitstreamErrors\r
+{      \r
+       private int errorcode = UNKNOWN_ERROR;\r
+       \r
+       public BitstreamException(String msg, Throwable t)\r
+       {\r
+               super(msg, t);  \r
+       }\r
+       \r
+       public BitstreamException(int errorcode, Throwable t)\r
+       {\r
+               this(getErrorString(errorcode), t);\r
+               this.errorcode = errorcode;\r
+       }\r
+       \r
+       public int getErrorCode()\r
+       {\r
+               return errorcode;       \r
+       }\r
+       \r
+       \r
+       static public String getErrorString(int errorcode)\r
+       {\r
+               // REVIEW: use resource bundle to map error codes\r
+               // to locale-sensitive strings.\r
+               \r
+               return "Bitstream errorcode "+Integer.toHexString(errorcode);\r
+       }\r
+       \r
+       \r
+}\r
diff --git a/Robust/src/Tests/ssJava/mp3decoder/Control.java b/Robust/src/Tests/ssJava/mp3decoder/Control.java
new file mode 100644 (file)
index 0000000..9d56604
--- /dev/null
@@ -0,0 +1,57 @@
+/*\r
+ * 11/19/04            1.0 moved to LGPL. \r
+ *-----------------------------------------------------------------------\r
+ *   This program is free software; you can redistribute it and/or modify\r
+ *   it under the terms of the GNU Library General Public License as published\r
+ *   by the Free Software Foundation; either version 2 of the License, or\r
+ *   (at your option) any later version.\r
+ *\r
+ *   This program is distributed in the hope that it will be useful,\r
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *   GNU Library General Public License for more details.\r
+ *\r
+ *   You should have received a copy of the GNU Library General Public\r
+ *   License along with this program; if not, write to the Free Software\r
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ *----------------------------------------------------------------------\r
+ */\r
+\r
+package javazoom.jl.decoder;\r
+\r
+/**\r
+ * Work in progress.\r
+ */\r
+\r
+public interface Control\r
+{\r
+       \r
+       /**\r
+        * Starts playback of the media presented by this control.\r
+        */\r
+       public void start();\r
+       \r
+       /**\r
+        * Stops playback of the media presented by this control.\r
+        */\r
+       public void stop();\r
+       \r
+       public boolean isPlaying();\r
+       \r
+       public void pause();\r
+               \r
+       \r
+       public boolean isRandomAccess();\r
+       \r
+       /**\r
+        * Retrieves the current position.\r
+        */\r
+       public double   getPosition();\r
+       \r
+       /**\r
+        * \r
+        */\r
+       public void             setPosition(double d);\r
+       \r
+       \r
+}\r
diff --git a/Robust/src/Tests/ssJava/mp3decoder/Crc16.java b/Robust/src/Tests/ssJava/mp3decoder/Crc16.java
new file mode 100644 (file)
index 0000000..caad01c
--- /dev/null
@@ -0,0 +1,70 @@
+/*\r
+ * 11/19/04 : 1.0 moved to LGPL.\r
+ * \r
+ * 02/12/99 : Java Conversion by E.B , javalayer@javazoom.net\r
+ *\r
+ *  @(#) crc.h 1.5, last edit: 6/15/94 16:55:32\r
+ *  @(#) Copyright (C) 1993, 1994 Tobias Bading (bading@cs.tu-berlin.de)\r
+ *  @(#) Berlin University of Technology\r
+ *-----------------------------------------------------------------------\r
+ *   This program is free software; you can redistribute it and/or modify\r
+ *   it under the terms of the GNU Library General Public License as published\r
+ *   by the Free Software Foundation; either version 2 of the License, or\r
+ *   (at your option) any later version.\r
+ *\r
+ *   This program is distributed in the hope that it will be useful,\r
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *   GNU Library General Public License for more details.\r
+ *\r
+ *   You should have received a copy of the GNU Library General Public\r
+ *   License along with this program; if not, write to the Free Software\r
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ *----------------------------------------------------------------------\r
+ */\r
+package javazoom.jl.decoder;\r
+\r
+/**\r
+ * 16-Bit CRC checksum\r
+ */\r
+public final class Crc16\r
+{\r
+  private static       short polynomial=(short)0x8005;\r
+  private                      short crc;\r
+\r
+  /**\r
+   * Dummy Constructor\r
+   */\r
+  public Crc16()\r
+  { \r
+       crc = (short) 0xFFFF;\r
+  }\r
+\r
+  /**\r
+   * Feed a bitstring to the crc calculation (0 < length <= 32).\r
+   */\r
+  public void add_bits (int bitstring, int length)\r
+  {\r
+       int bitmask = 1 << (length - 1);\r
+       do\r
+        if (((crc & 0x8000) == 0) ^ ((bitstring & bitmask) == 0 ))\r
+        {\r
+               crc <<= 1;\r
+               crc ^= polynomial;\r
+        }\r
+        else\r
+               crc <<= 1;\r
+       while ((bitmask >>>= 1) != 0);\r
+  }\r
+\r
+  /**\r
+   * Return the calculated checksum.\r
+   * Erase it for next calls to add_bits().\r
+   */\r
+  public short checksum()\r
+  {\r
+    short sum = crc;\r
+    crc = (short) 0xFFFF;\r
+    return sum;\r
+  }\r
+}\r
diff --git a/Robust/src/Tests/ssJava/mp3decoder/Decoder.java b/Robust/src/Tests/ssJava/mp3decoder/Decoder.java
new file mode 100644 (file)
index 0000000..6de5599
--- /dev/null
@@ -0,0 +1,357 @@
+/*\r
+ * 11/19/04            1.0 moved to LGPL.\r
+ * 01/12/99            Initial version.        mdm@techie.com\r
+ *-----------------------------------------------------------------------\r
+ *   This program is free software; you can redistribute it and/or modify\r
+ *   it under the terms of the GNU Library General Public License as published\r
+ *   by the Free Software Foundation; either version 2 of the License, or\r
+ *   (at your option) any later version.\r
+ *\r
+ *   This program is distributed in the hope that it will be useful,\r
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *   GNU Library General Public License for more details.\r
+ *\r
+ *   You should have received a copy of the GNU Library General Public\r
+ *   License along with this program; if not, write to the Free Software\r
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ *----------------------------------------------------------------------\r
+ */\r
\r
+package javazoom.jl.decoder;\r
+\r
+/**\r
+ * The <code>Decoder</code> class encapsulates the details of\r
+ * decoding an MPEG audio frame. \r
+ * \r
+ * @author     MDM     \r
+ * @version 0.0.7 12/12/99\r
+ * @since      0.0.5\r
+ */\r
+public class Decoder implements DecoderErrors\r
+{\r
+       static private final Params DEFAULT_PARAMS = new Params();\r
+       \r
+       /**\r
+        * The Bistream from which the MPEG audio frames are read.\r
+        */\r
+       //private Bitstream                             stream;\r
+       \r
+       /**\r
+        * The Obuffer instance that will receive the decoded\r
+        * PCM samples.\r
+        */\r
+       private Obuffer                 output;\r
+               \r
+       /**\r
+        * Synthesis filter for the left channel.\r
+        */\r
+       private SynthesisFilter                 filter1;\r
+       \r
+       /**\r
+        * Sythesis filter for the right channel.\r
+        */\r
+       private SynthesisFilter                 filter2;        \r
+                       \r
+       /**\r
+        * The decoder used to decode layer III frames.\r
+        */\r
+       private LayerIIIDecoder                 l3decoder;\r
+       private LayerIIDecoder                  l2decoder;\r
+       private LayerIDecoder                   l1decoder;\r
+       \r
+       private int                                             outputFrequency;\r
+       private int                                             outputChannels;\r
+       \r
+       private Equalizer                               equalizer = new Equalizer();\r
+       \r
+       private Params                                  params;\r
+       \r
+       private boolean                                 initialized;\r
+               \r
+       \r
+       /**\r
+        * Creates a new <code>Decoder</code> instance with default \r
+        * parameters.\r
+        */\r
+       \r
+       public Decoder()\r
+       {\r
+               this(null);\r
+       }\r
+\r
+       /**\r
+        * Creates a new <code>Decoder</code> instance with default \r
+        * parameters.\r
+        * \r
+        * @param params        The <code>Params</code> instance that describes\r
+        *                                      the customizable aspects of the decoder.  \r
+        */\r
+       public Decoder(Params params0)\r
+       {\r
+               if (params0==null)\r
+                       params0 = DEFAULT_PARAMS;\r
+       \r
+               params = params0;\r
+               \r
+               Equalizer eq = params.getInitialEqualizerSettings();\r
+               if (eq!=null)\r
+               {\r
+                       equalizer.setFrom(eq);\r
+               }\r
+       }\r
+       \r
+       static public Params getDefaultParams()\r
+       {\r
+               return (Params)DEFAULT_PARAMS.clone();\r
+       }\r
+       \r
+       public void setEqualizer(Equalizer eq)\r
+       {\r
+               if (eq==null)\r
+                       eq = Equalizer.PASS_THRU_EQ;\r
+               \r
+               equalizer.setFrom(eq);\r
+               \r
+               float[] factors = equalizer.getBandFactors();\r
+\r
+               if (filter1!=null)\r
+                       filter1.setEQ(factors);\r
+               \r
+               if (filter2!=null)\r
+                       filter2.setEQ(factors);                 \r
+       }\r
+       \r
+       /**\r
+        * Decodes one frame from an MPEG audio bitstream.\r
+        * \r
+        * @param header                The header describing the frame to decode.\r
+        * @param bitstream             The bistream that provides the bits for te body of the frame. \r
+        * \r
+        * @return A SampleBuffer containing the decoded samples.\r
+        */\r
+       public Obuffer decodeFrame(Header header, Bitstream stream)\r
+               throws DecoderException\r
+       {\r
+               if (!initialized)\r
+               {\r
+                       initialize(header);\r
+               }\r
+               \r
+               int layer = header.layer();\r
+               \r
+               output.clear_buffer();\r
+               \r
+               FrameDecoder decoder = retrieveDecoder(header, stream, layer);\r
+               \r
+               decoder.decodeFrame();\r
+                               \r
+               output.write_buffer(1);\r
+               \r
+               return output;  \r
+       }\r
+       \r
+       /**\r
+        * Changes the output buffer. This will take effect the next time\r
+        * decodeFrame() is called. \r
+        */\r
+       public void setOutputBuffer(Obuffer out)\r
+       {\r
+               output = out;\r
+       }\r
+       \r
+       /**\r
+        * Retrieves the sample frequency of the PCM samples output\r
+        * by this decoder. This typically corresponds to the sample\r
+        * rate encoded in the MPEG audio stream.\r
+        * \r
+        * @param the sample rate (in Hz) of the samples written to the\r
+        *              output buffer when decoding. \r
+        */\r
+       public int getOutputFrequency()\r
+       {\r
+               return outputFrequency;\r
+       }\r
+       \r
+       /**\r
+        * Retrieves the number of channels of PCM samples output by\r
+        * this decoder. This usually corresponds to the number of\r
+        * channels in the MPEG audio stream, although it may differ.\r
+        * \r
+        * @return The number of output channels in the decoded samples: 1 \r
+        *              for mono, or 2 for stereo.\r
+        *              \r
+        */\r
+       public int getOutputChannels()\r
+       {\r
+               return outputChannels;  \r
+       }\r
+       \r
+       /**\r
+        * Retrieves the maximum number of samples that will be written to\r
+        * the output buffer when one frame is decoded. This can be used to\r
+        * help calculate the size of other buffers whose size is based upon \r
+        * the number of samples written to the output buffer. NB: this is\r
+        * an upper bound and fewer samples may actually be written, depending\r
+        * upon the sample rate and number of channels.\r
+        * \r
+        * @return The maximum number of samples that are written to the \r
+        *              output buffer when decoding a single frame of MPEG audio.\r
+        */\r
+       public int getOutputBlockSize()\r
+       {\r
+               return Obuffer.OBUFFERSIZE;\r
+       }\r
+       \r
+       \r
+       protected DecoderException newDecoderException(int errorcode)\r
+       {\r
+               return new DecoderException(errorcode, null);\r
+       }\r
+       \r
+       protected DecoderException newDecoderException(int errorcode, Throwable throwable)\r
+       {\r
+               return new DecoderException(errorcode, throwable);\r
+       }\r
+       \r
+       protected FrameDecoder retrieveDecoder(Header header, Bitstream stream, int layer)\r
+               throws DecoderException\r
+       {\r
+               FrameDecoder decoder = null;\r
+               \r
+               // REVIEW: allow channel output selection type\r
+               // (LEFT, RIGHT, BOTH, DOWNMIX)\r
+               switch (layer)\r
+               {\r
+               case 3:\r
+                       if (l3decoder==null)\r
+                       {\r
+                               l3decoder = new LayerIIIDecoder(stream, \r
+                                       header, filter1, filter2, \r
+                                       output, OutputChannels.BOTH_CHANNELS);\r
+                       }                                               \r
+                       \r
+                       decoder = l3decoder;\r
+                       break;\r
+               case 2:\r
+                       if (l2decoder==null)\r
+                       {\r
+                               l2decoder = new LayerIIDecoder();\r
+                               l2decoder.create(stream, \r
+                                       header, filter1, filter2, \r
+                                       output, OutputChannels.BOTH_CHANNELS);                          \r
+                       }\r
+                       decoder = l2decoder;\r
+                       break;\r
+               case 1:\r
+                       if (l1decoder==null)\r
+                       {\r
+                               l1decoder = new LayerIDecoder();\r
+                               l1decoder.create(stream, \r
+                                       header, filter1, filter2, \r
+                                       output, OutputChannels.BOTH_CHANNELS);                          \r
+                       }\r
+                       decoder = l1decoder;\r
+                       break;\r
+               }\r
+                                               \r
+               if (decoder==null)\r
+               {\r
+                       throw newDecoderException(UNSUPPORTED_LAYER, null);\r
+               }\r
+               \r
+               return decoder;\r
+       }\r
+       \r
+       private void initialize(Header header)\r
+               throws DecoderException\r
+       {\r
+               \r
+               // REVIEW: allow customizable scale factor\r
+               float scalefactor = 32700.0f;\r
+               \r
+               int mode = header.mode();\r
+               int layer = header.layer();\r
+               int channels = mode==Header.SINGLE_CHANNEL ? 1 : 2;\r
+\r
+                                       \r
+               // set up output buffer if not set up by client.\r
+               if (output==null)\r
+                       output = new SampleBuffer(header.frequency(), channels);\r
+               \r
+               float[] factors = equalizer.getBandFactors();\r
+               filter1 = new SynthesisFilter(0, scalefactor, factors);\r
+               \r
+               // REVIEW: allow mono output for stereo\r
+               if (channels==2) \r
+                       filter2 = new SynthesisFilter(1, scalefactor, factors);\r
+\r
+               outputChannels = channels;\r
+               outputFrequency = header.frequency();\r
+               \r
+               initialized = true;\r
+       }\r
+       \r
+       /**\r
+        * The <code>Params</code> class presents the customizable\r
+        * aspects of the decoder. \r
+        * <p>\r
+        * Instances of this class are not thread safe. \r
+        */\r
+       public static class Params implements Cloneable\r
+       {\r
+               private OutputChannels  outputChannels = OutputChannels.BOTH;\r
+               \r
+               private Equalizer               equalizer = new Equalizer();\r
+               \r
+               public Params()\r
+               {                       \r
+               }\r
+               \r
+               public Object clone()\r
+               {\r
+                       try\r
+                       {\r
+                               return super.clone();\r
+                       }\r
+                       catch (CloneNotSupportedException ex)\r
+                       {                               \r
+                               throw new InternalError(this+": "+ex);\r
+                       }\r
+               }\r
+                               \r
+               public void setOutputChannels(OutputChannels out)\r
+               {\r
+                       if (out==null)\r
+                               throw new NullPointerException("out");\r
+                       \r
+                       outputChannels = out;\r
+               }\r
+               \r
+               public OutputChannels getOutputChannels()\r
+               {\r
+                       return outputChannels;\r
+               }\r
+               \r
+               /**\r
+                * Retrieves the equalizer settings that the decoder's equalizer\r
+                * will be initialized from.\r
+                * <p>\r
+                * The <code>Equalizer</code> instance returned \r
+                * cannot be changed in real time to affect the \r
+                * decoder output as it is used only to initialize the decoders\r
+                * EQ settings. To affect the decoder's output in realtime,\r
+                * use the Equalizer returned from the getEqualizer() method on\r
+                * the decoder. \r
+                * \r
+                * @return      The <code>Equalizer</code> used to initialize the\r
+                *                      EQ settings of the decoder. \r
+                */\r
+               public Equalizer getInitialEqualizerSettings()\r
+               {\r
+                       return equalizer;       \r
+               }\r
+                               \r
+       };\r
+}\r
+\r
diff --git a/Robust/src/Tests/ssJava/mp3decoder/DecoderErrors.java b/Robust/src/Tests/ssJava/mp3decoder/DecoderErrors.java
new file mode 100644 (file)
index 0000000..686f260
--- /dev/null
@@ -0,0 +1,45 @@
+/*\r
+ * 09/26/08     throw exception on subbband alloc error: Christopher G. Jennings (cjennings@acm.org)\r
+ * 11/19/04            1.0 moved to LGPL.\r
+ * 01/12/99            Initial version.        mdm@techie.com\r
+ *-----------------------------------------------------------------------\r
+ *   This program is free software; you can redistribute it and/or modify\r
+ *   it under the terms of the GNU Library General Public License as published\r
+ *   by the Free Software Foundation; either version 2 of the License, or\r
+ *   (at your option) any later version.\r
+ *\r
+ *   This program is distributed in the hope that it will be useful,\r
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *   GNU Library General Public License for more details.\r
+ *\r
+ *   You should have received a copy of the GNU Library General Public\r
+ *   License along with this program; if not, write to the Free Software\r
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ *----------------------------------------------------------------------\r
+ */\r
+\r
+package javazoom.jl.decoder;\r
+\r
+/**\r
+ * This interface provides constants describing the error\r
+ * codes used by the Decoder to indicate errors. \r
+ * \r
+ * @author     MDM\r
+ */\r
+public interface DecoderErrors extends JavaLayerErrors\r
+{\r
+       \r
+       static public final int UNKNOWN_ERROR = DECODER_ERROR + 0;\r
+       \r
+       /**\r
+        * Layer not supported by the decoder. \r
+        */\r
+       static public final int UNSUPPORTED_LAYER = DECODER_ERROR + 1;\r
+\r
+    /**\r
+        * Illegal allocation in subband layer. Indicates a corrupt stream.\r
+        */\r
+       static public final int ILLEGAL_SUBBAND_ALLOCATION = DECODER_ERROR + 2;\r
+\r
+}\r
diff --git a/Robust/src/Tests/ssJava/mp3decoder/DecoderException.java b/Robust/src/Tests/ssJava/mp3decoder/DecoderException.java
new file mode 100644 (file)
index 0000000..87638ad
--- /dev/null
@@ -0,0 +1,61 @@
+/*\r
+ * 11/19/04            1.0 moved to LGPL.\r
+ * 01/12/99            Initial version.        mdm@techie.com\r
+ *-----------------------------------------------------------------------\r
+ *   This program is free software; you can redistribute it and/or modify\r
+ *   it under the terms of the GNU Library General Public License as published\r
+ *   by the Free Software Foundation; either version 2 of the License, or\r
+ *   (at your option) any later version.\r
+ *\r
+ *   This program is distributed in the hope that it will be useful,\r
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *   GNU Library General Public License for more details.\r
+ *\r
+ *   You should have received a copy of the GNU Library General Public\r
+ *   License along with this program; if not, write to the Free Software\r
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ *----------------------------------------------------------------------\r
+ */\r
+\r
+package javazoom.jl.decoder;\r
+\r
+/**\r
+ * The <code>DecoderException</code> represents the class of\r
+ * errors that can occur when decoding MPEG audio. \r
+ * \r
+ * @author MDM\r
+ */\r
+public class DecoderException extends JavaLayerException\r
+       implements DecoderErrors\r
+{      \r
+       private int             errorcode = UNKNOWN_ERROR;\r
+       \r
+       public DecoderException(String msg, Throwable t)\r
+       {\r
+               super(msg, t);  \r
+       }\r
+       \r
+       public DecoderException(int errorcode, Throwable t)\r
+       {\r
+               this(getErrorString(errorcode), t);\r
+               this.errorcode = errorcode;\r
+       }\r
+       \r
+       public int getErrorCode()\r
+       {\r
+               return errorcode;       \r
+       }\r
+       \r
+       \r
+       static public String getErrorString(int errorcode)\r
+       {\r
+               // REVIEW: use resource file to map error codes\r
+               // to locale-sensitive strings. \r
+               \r
+               return "Decoder errorcode "+Integer.toHexString(errorcode);\r
+       }\r
+       \r
+       \r
+}\r
+\r
diff --git a/Robust/src/Tests/ssJava/mp3decoder/Equalizer.java b/Robust/src/Tests/ssJava/mp3decoder/Equalizer.java
new file mode 100644 (file)
index 0000000..439279e
--- /dev/null
@@ -0,0 +1,227 @@
+/*\r
+ * 11/19/04            1.0 moved to LGPL.\r
+ * 12/12/99            Initial version.        mdm@techie.com\r
+ *-----------------------------------------------------------------------\r
+ *   This program is free software; you can redistribute it and/or modify\r
+ *   it under the terms of the GNU Library General Public License as published\r
+ *   by the Free Software Foundation; either version 2 of the License, or\r
+ *   (at your option) any later version.\r
+ *\r
+ *   This program is distributed in the hope that it will be useful,\r
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *   GNU Library General Public License for more details.\r
+ *\r
+ *   You should have received a copy of the GNU Library General Public\r
+ *   License along with this program; if not, write to the Free Software\r
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ *----------------------------------------------------------------------\r
+ */\r
+\r
+\r
+package javazoom.jl.decoder;\r
+\r
+/**\r
+ * The <code>Equalizer</code> class can be used to specify\r
+ * equalization settings for the MPEG audio decoder. \r
+ * <p>\r
+ * The equalizer consists of 32 band-pass filters. \r
+ * Each band of the equalizer can take on a fractional value between \r
+ * -1.0 and +1.0.\r
+ * At -1.0, the input signal is attenuated by 6dB, at +1.0 the signal is\r
+ * amplified by 6dB. \r
+ * \r
+ * @see Decoder\r
+ * \r
+ * @author MDM\r
+ */\r
+public final class Equalizer\r
+{              \r
+       /**\r
+        * Equalizer setting to denote that a given band will not be\r
+        * present in the output signal.\r
+        */\r
+       static public final float BAND_NOT_PRESENT = Float.NEGATIVE_INFINITY;\r
+               \r
+       static public final Equalizer   PASS_THRU_EQ = new Equalizer();\r
+       \r
+       private static final int BANDS = 32;\r
+       \r
+       private final float[]   settings = new float[BANDS];\r
+       \r
+       /**\r
+        * Creates a new <code>Equalizer</code> instance. \r
+        */\r
+       public Equalizer()\r
+       {               \r
+       }\r
+       \r
+//     private Equalizer(float b1, float b2, float b3, float b4, float b5,\r
+//                                      float b6, float b7, float b8, float b9, float b10, float b11,\r
+//                                      float b12, float b13, float b14, float b15, float b16,\r
+//                                      float b17, float b18, float b19, float b20);\r
+\r
+       public Equalizer(float[] settings)\r
+       {\r
+               setFrom(settings);\r
+       }\r
+       \r
+       public Equalizer(EQFunction eq)\r
+       {\r
+               setFrom(eq);\r
+       }\r
+       \r
+       public void setFrom(float[] eq)\r
+       {\r
+               reset();\r
+               int max = (eq.length > BANDS) ? BANDS : eq.length;\r
+               \r
+               for (int i=0; i<max; i++)\r
+               {\r
+                       settings[i] = limit(eq[i]);\r
+               }\r
+       }\r
+\r
+       public void setFrom(EQFunction eq)\r
+       {\r
+               reset();\r
+               int max = BANDS;\r
+               \r
+               for (int i=0; i<max; i++)\r
+               {\r
+                       settings[i] = limit(eq.getBand(i));\r
+               }               \r
+       }\r
+       \r
+       /**\r
+        * Sets the bands of this equalizer to the value the bands of\r
+        * another equalizer. Bands that are not present in both equalizers are ignored. \r
+        */\r
+       public void setFrom(Equalizer eq)\r
+       {\r
+               if (eq!=this)\r
+               {\r
+                       setFrom(eq.settings);\r
+               }\r
+       }\r
+       \r
+       \r
+       \r
+       \r
+       /**\r
+        * Sets all bands to 0.0\r
+        */\r
+       public void reset()\r
+       {\r
+               for (int i=0; i<BANDS; i++)\r
+               {\r
+                       settings[i] = 0.0f;\r
+               }\r
+       }\r
+\r
+       \r
+       /**\r
+        * Retrieves the number of bands present in this equalizer.\r
+        */\r
+       public int getBandCount()\r
+       {\r
+               return settings.length; \r
+       }\r
+       \r
+       public float setBand(int band, float neweq)\r
+       {\r
+               float eq = 0.0f;\r
+               \r
+               if ((band>=0) && (band<BANDS))\r
+               {\r
+                       eq = settings[band];\r
+                       settings[band] = limit(neweq);\r
+               }\r
+               \r
+               return eq;              \r
+       }\r
+       \r
+       \r
+       \r
+       /**\r
+        * Retrieves the eq setting for a given band.\r
+        */\r
+       public float getBand(int band)\r
+       {\r
+               float eq = 0.0f;\r
+               \r
+               if ((band>=0) && (band<BANDS))\r
+               {\r
+                       eq = settings[band];\r
+               }\r
+               \r
+               return eq;\r
+       }\r
+       \r
+       private float limit(float eq)\r
+       {\r
+               if (eq==BAND_NOT_PRESENT)\r
+                       return eq;\r
+               if (eq > 1.0f)\r
+                       return 1.0f;\r
+               if (eq < -1.0f)\r
+                       return -1.0f;\r
+               \r
+               return eq;\r
+       }\r
+       \r
+       /**\r
+        * Retrieves an array of floats whose values represent a\r
+        * scaling factor that can be applied to linear samples\r
+        * in each band to provide the equalization represented by\r
+        * this instance. \r
+        * \r
+        * @return      an array of factors that can be applied to the\r
+        *                      subbands.\r
+        */\r
+       float[] getBandFactors()\r
+       {\r
+               float[] factors = new float[BANDS];\r
+               for (int i=0, maxCount=BANDS; i<maxCount; i++)\r
+               {\r
+                       factors[i] = getBandFactor(settings[i]);\r
+               }\r
+               \r
+               return factors;\r
+       }\r
+       \r
+       /**\r
+        * Converts an equalizer band setting to a sample factor.\r
+        * The factor is determined by the function f = 2^n where\r
+        * n is the equalizer band setting in the range [-1.0,1.0].\r
+        *       \r
+        */\r
+       float getBandFactor(float eq)\r
+       {\r
+               if (eq==BAND_NOT_PRESENT)\r
+                       return 0.0f;\r
+               \r
+               float f = (float)Math.pow(2.0, eq);\r
+               return f;\r
+       }\r
+       \r
+       \r
+       static abstract public class EQFunction\r
+       {\r
+               /**\r
+                * Returns the setting of a band in the equalizer. \r
+                * \r
+                * @param band  The index of the band to retrieve the setting\r
+                *                              for. \r
+                * \r
+                * @return              the setting of the specified band. This is a value between\r
+                *                              -1 and +1.\r
+                */\r
+               public float getBand(int band)\r
+               {\r
+                       return 0.0f;    \r
+               }\r
+               \r
+       }\r
+               \r
+}\r
diff --git a/Robust/src/Tests/ssJava/mp3decoder/FrameDecoder.java b/Robust/src/Tests/ssJava/mp3decoder/FrameDecoder.java
new file mode 100644 (file)
index 0000000..12912f6
--- /dev/null
@@ -0,0 +1,39 @@
+/*\r
+ * 09/26/08     throw exception on subbband alloc error: Christopher G. Jennings (cjennings@acm.org)\r
+ * 11/19/04            1.0 moved to LGPL.\r
+ * 12/12/99            Initial version.        mdm@techie.com\r
+ *-----------------------------------------------------------------------\r
+ *   This program is free software; you can redistribute it and/or modify\r
+ *   it under the terms of the GNU Library General Public License as published\r
+ *   by the Free Software Foundation; either version 2 of the License, or\r
+ *   (at your option) any later version.\r
+ *\r
+ *   This program is distributed in the hope that it will be useful,\r
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *   GNU Library General Public License for more details.\r
+ *\r
+ *   You should have received a copy of the GNU Library General Public\r
+ *   License along with this program; if not, write to the Free Software\r
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ *----------------------------------------------------------------------\r
+ */\r
+\r
+package javazoom.jl.decoder;\r
+\r
+/**\r
+ * Implementations of FrameDecoder are responsible for decoding\r
+ * an MPEG audio frame.\r
+ *  \r
+ */\r
+//REVIEW: the interface currently is too thin. There should be\r
+// methods to specify the output buffer, the synthesis filters and\r
+// possibly other objects used by the decoder. \r
+public interface FrameDecoder\r
+{\r
+       /**\r
+        * Decodes one frame of MPEG audio. \r
+        */\r
+       public void decodeFrame() throws DecoderException;\r
+               \r
+}\r
diff --git a/Robust/src/Tests/ssJava/mp3decoder/Header.java b/Robust/src/Tests/ssJava/mp3decoder/Header.java
new file mode 100644 (file)
index 0000000..a36572d
--- /dev/null
@@ -0,0 +1,762 @@
+/*\r
+ * 11/19/04 : 1.0 moved to LGPL.\r
+ *            VBRI header support added, E.B javalayer@javazoom.net\r
+ * \r
+ * 12/04/03 : VBR (XING) header support added, E.B javalayer@javazoom.net\r
+ *\r
+ * 02/13/99 : Java Conversion by JavaZOOM , E.B javalayer@javazoom.net\r
+ *\r
+ * Declarations for MPEG header class\r
+ * A few layer III, MPEG-2 LSF, and seeking modifications made by Jeff Tsay.\r
+ * Last modified : 04/19/97\r
+ *\r
+ *  @(#) header.h 1.7, last edit: 6/15/94 16:55:33\r
+ *  @(#) Copyright (C) 1993, 1994 Tobias Bading (bading@cs.tu-berlin.de)\r
+ *  @(#) Berlin University of Technology\r
+ *-----------------------------------------------------------------------\r
+ *   This program is free software; you can redistribute it and/or modify\r
+ *   it under the terms of the GNU Library General Public License as published\r
+ *   by the Free Software Foundation; either version 2 of the License, or\r
+ *   (at your option) any later version.\r
+ *\r
+ *   This program is distributed in the hope that it will be useful,\r
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *   GNU Library General Public License for more details.\r
+ *\r
+ *   You should have received a copy of the GNU Library General Public\r
+ *   License along with this program; if not, write to the Free Software\r
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ *----------------------------------------------------------------------\r
+ */\r
+package javazoom.jl.decoder;\r
+\r
+/**\r
+ * Class for extracting information from a frame header.\r
+ */\r
+public final class Header\r
+{\r
+       public  static final int[][]    frequencies =\r
+                                               {{22050, 24000, 16000, 1},\r
+                                               {44100, 48000, 32000, 1},\r
+                                               {11025, 12000, 8000, 1}};       // SZD: MPEG25\r
+\r
+       /**\r
+        * Constant for MPEG-2 LSF version\r
+        */\r
+       public static final int         MPEG2_LSF = 0;\r
+       public static final int         MPEG25_LSF = 2; // SZD\r
+\r
+       /**\r
+        * Constant for MPEG-1 version\r
+        */\r
+       public static final int         MPEG1 = 1;\r
+\r
+       public static final int         STEREO = 0;\r
+       public static final int         JOINT_STEREO = 1;\r
+       public static final int         DUAL_CHANNEL = 2;\r
+       public static final int         SINGLE_CHANNEL = 3;\r
+       public static final int         FOURTYFOUR_POINT_ONE = 0;\r
+       public static final int         FOURTYEIGHT=1;\r
+       public static final int         THIRTYTWO=2;\r
+\r
+       private int                             h_layer, h_protection_bit, h_bitrate_index,\r
+                                                       h_padding_bit, h_mode_extension;\r
+       private int                             h_version;\r
+       private int                             h_mode;\r
+       private int                             h_sample_frequency;\r
+       private int                             h_number_of_subbands, h_intensity_stereo_bound;\r
+       private boolean                 h_copyright, h_original;\r
+       // VBR support added by E.B\r
+       private double[]                h_vbr_time_per_frame = {-1, 384, 1152, 1152};\r
+       private boolean                 h_vbr;\r
+       private int                             h_vbr_frames;\r
+       private int                             h_vbr_scale;\r
+       private int                             h_vbr_bytes;\r
+       private byte[]                  h_vbr_toc;\r
+       \r
+       private byte                    syncmode = Bitstream.INITIAL_SYNC;\r
+       private Crc16                   crc;\r
+\r
+       public short                    checksum;\r
+       public int                              framesize;\r
+       public int                              nSlots;\r
+\r
+       private int                             _headerstring = -1; // E.B\r
+\r
+       Header()\r
+       {\r
+       }\r
+       public String toString()\r
+       {\r
+               StringBuffer buffer = new StringBuffer(200);\r
+               buffer.append("Layer ");\r
+               buffer.append(layer_string());\r
+               buffer.append(" frame ");\r
+               buffer.append(mode_string());\r
+               buffer.append(' ');\r
+               buffer.append(version_string());\r
+               if (!checksums())\r
+                       buffer.append(" no");\r
+               buffer.append(" checksums");\r
+               buffer.append(' ');\r
+               buffer.append(sample_frequency_string());\r
+               buffer.append(',');\r
+               buffer.append(' ');\r
+               buffer.append(bitrate_string());\r
+\r
+               String s =  buffer.toString();\r
+               return s;\r
+       }\r
+\r
+       /**\r
+        * Read a 32-bit header from the bitstream.\r
+        */\r
+       void read_header(Bitstream stream, Crc16[] crcp) throws BitstreamException\r
+       {\r
+               int headerstring;\r
+               int channel_bitrate;\r
+               boolean sync = false;\r
+               do\r
+               {\r
+                       headerstring = stream.syncHeader(syncmode);\r
+                       _headerstring = headerstring; // E.B\r
+                       if (syncmode == Bitstream.INITIAL_SYNC)\r
+                       {\r
+                               h_version = ((headerstring >>> 19) & 1);\r
+                               if (((headerstring >>> 20) & 1) == 0) // SZD: MPEG2.5 detection\r
+                                       if (h_version == MPEG2_LSF)\r
+                                               h_version = MPEG25_LSF;\r
+                                       else\r
+                                               throw stream.newBitstreamException(Bitstream.UNKNOWN_ERROR);\r
+                               if ((h_sample_frequency = ((headerstring >>> 10) & 3)) == 3)\r
+                               {\r
+                                       throw stream.newBitstreamException(Bitstream.UNKNOWN_ERROR);\r
+                               }\r
+                       }\r
+                       h_layer = 4 - (headerstring >>> 17) & 3;\r
+                       h_protection_bit = (headerstring >>> 16) & 1;\r
+                       h_bitrate_index = (headerstring >>> 12) & 0xF;\r
+                       h_padding_bit = (headerstring >>> 9) & 1;\r
+                       h_mode = ((headerstring >>> 6) & 3);\r
+                       h_mode_extension = (headerstring >>> 4) & 3;\r
+                       if (h_mode == JOINT_STEREO)\r
+                               h_intensity_stereo_bound = (h_mode_extension << 2) + 4;\r
+                       else\r
+                               h_intensity_stereo_bound = 0; // should never be used\r
+                       if (((headerstring >>> 3) & 1) == 1)\r
+                               h_copyright = true;\r
+                       if (((headerstring >>> 2) & 1) == 1)\r
+                               h_original = true;\r
+                       // calculate number of subbands:\r
+                       if (h_layer == 1)\r
+                               h_number_of_subbands = 32;\r
+                       else\r
+                       {\r
+                               channel_bitrate = h_bitrate_index;\r
+                               // calculate bitrate per channel:\r
+                               if (h_mode != SINGLE_CHANNEL)\r
+                                       if (channel_bitrate == 4)\r
+                                               channel_bitrate = 1;\r
+                                       else\r
+                                               channel_bitrate -= 4;\r
+                               if ((channel_bitrate == 1) || (channel_bitrate == 2))\r
+                                       if (h_sample_frequency == THIRTYTWO)\r
+                                               h_number_of_subbands = 12;\r
+                                       else\r
+                                               h_number_of_subbands = 8;\r
+                               else if ((h_sample_frequency == FOURTYEIGHT) || ((channel_bitrate >= 3) && (channel_bitrate <= 5)))\r
+                                       h_number_of_subbands = 27;\r
+                               else\r
+                                       h_number_of_subbands = 30;\r
+                       }\r
+                       if (h_intensity_stereo_bound > h_number_of_subbands)\r
+                               h_intensity_stereo_bound = h_number_of_subbands;\r
+                       // calculate framesize and nSlots\r
+                       calculate_framesize();\r
+                       // read framedata:\r
+                       int framesizeloaded = stream.read_frame_data(framesize);\r
+                       if ((framesize >=0) && (framesizeloaded != framesize))\r
+                       {\r
+                               // Data loaded does not match to expected framesize,\r
+                               // it might be an ID3v1 TAG. (Fix 11/17/04).\r
+                               throw stream.newBitstreamException(Bitstream.INVALIDFRAME);\r
+                       }\r
+                       if (stream.isSyncCurrentPosition(syncmode))\r
+                       {\r
+                               if (syncmode == Bitstream.INITIAL_SYNC)\r
+                               {\r
+                                       syncmode = Bitstream.STRICT_SYNC;\r
+                                       stream.set_syncword(headerstring & 0xFFF80CC0);\r
+                               }\r
+                               sync = true;\r
+                       }\r
+                       else\r
+                       {\r
+                               stream.unreadFrame();\r
+                       }\r
+               }\r
+               while (!sync);\r
+               stream.parse_frame();\r
+               if (h_protection_bit == 0)\r
+               {\r
+                       // frame contains a crc checksum\r
+                       checksum = (short) stream.get_bits(16);\r
+                       if (crc == null)\r
+                               crc = new Crc16();\r
+                       crc.add_bits(headerstring, 16);\r
+                       crcp[0] = crc;\r
+               }\r
+               else\r
+                       crcp[0] = null;\r
+               if (h_sample_frequency == FOURTYFOUR_POINT_ONE)\r
+               {\r
+                       /*\r
+                               if (offset == null)\r
+                         {\r
+                                 int max = max_number_of_frames(stream);\r
+                                 offset = new int[max];\r
+                            for(int i=0; i<max; i++) offset[i] = 0;\r
+                         }\r
+                         // E.B : Investigate more\r
+                         int cf = stream.current_frame();\r
+                         int lf = stream.last_frame();\r
+                         if ((cf > 0) && (cf == lf))\r
+                         {\r
+                                  offset[cf] = offset[cf-1] + h_padding_bit;\r
+                         }\r
+                         else\r
+                         {\r
+                                      offset[0] = h_padding_bit;\r
+                         }\r
+                       */\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Parse frame to extract optionnal VBR frame.\r
+        * @param firstframe\r
+        * @author E.B (javalayer@javazoom.net)\r
+        */\r
+       void parseVBR(byte[] firstframe) throws BitstreamException\r
+       {\r
+               // Trying Xing header.\r
+               String xing = "Xing";\r
+               byte tmp[] = new byte[4];\r
+               int offset = 0;\r
+               // Compute "Xing" offset depending on MPEG version and channels.\r
+               if (h_version == MPEG1) \r
+               {\r
+                 if (h_mode == SINGLE_CHANNEL)  offset=21-4;\r
+                 else offset=36-4;\r
+               } \r
+               else \r
+               {\r
+                 if (h_mode == SINGLE_CHANNEL) offset=13-4;\r
+                 else offset = 21-4;             \r
+               }\r
+               try\r
+               {\r
+                       System.arraycopy(firstframe, offset, tmp, 0, 4);\r
+                       // Is "Xing" ?\r
+                       if (xing.equals(new String(tmp)))\r
+                       {\r
+                               //Yes.\r
+                               h_vbr = true;\r
+                               h_vbr_frames = -1;\r
+                               h_vbr_bytes = -1;\r
+                               h_vbr_scale = -1;\r
+                               h_vbr_toc = new byte[100];\r
+                                                               \r
+                               int length = 4;\r
+                               // Read flags.\r
+                               byte flags[] = new byte[4];\r
+                               System.arraycopy(firstframe, offset + length, flags, 0, flags.length);\r
+                               length += flags.length;\r
+                               // Read number of frames (if available).\r
+                               if ((flags[3] & (byte) (1 << 0)) != 0)\r
+                               {\r
+                                       System.arraycopy(firstframe, offset + length, tmp, 0, tmp.length);\r
+                                       h_vbr_frames = (tmp[0] << 24)&0xFF000000 | (tmp[1] << 16)&0x00FF0000 | (tmp[2] << 8)&0x0000FF00 | tmp[3]&0x000000FF;\r
+                                       length += 4;    \r
+                               }\r
+                               // Read size (if available).\r
+                               if ((flags[3] & (byte) (1 << 1)) != 0)\r
+                               {\r
+                                       System.arraycopy(firstframe, offset + length, tmp, 0, tmp.length);\r
+                                       h_vbr_bytes = (tmp[0] << 24)&0xFF000000 | (tmp[1] << 16)&0x00FF0000 | (tmp[2] << 8)&0x0000FF00 | tmp[3]&0x000000FF;\r
+                                       length += 4;    \r
+                               }\r
+                               // Read TOC (if available).\r
+                               if ((flags[3] & (byte) (1 << 2)) != 0)\r
+                               {\r
+                                       System.arraycopy(firstframe, offset + length, h_vbr_toc, 0, h_vbr_toc.length);\r
+                                       length += h_vbr_toc.length;     \r
+                               }\r
+                               // Read scale (if available).\r
+                               if ((flags[3] & (byte) (1 << 3)) != 0)\r
+                               {\r
+                                       System.arraycopy(firstframe, offset + length, tmp, 0, tmp.length);\r
+                                       h_vbr_scale = (tmp[0] << 24)&0xFF000000 | (tmp[1] << 16)&0x00FF0000 | (tmp[2] << 8)&0x0000FF00 | tmp[3]&0x000000FF;\r
+                                       length += 4;    \r
+                               }\r
+                               //System.out.println("VBR:"+xing+" Frames:"+ h_vbr_frames +" Size:"+h_vbr_bytes);                       \r
+                       }                               \r
+               }\r
+               catch (ArrayIndexOutOfBoundsException e)\r
+               {\r
+                       throw new BitstreamException("XingVBRHeader Corrupted",e);\r
+               }\r
+               \r
+               // Trying VBRI header.                  \r
+               String vbri = "VBRI";\r
+               offset = 36-4;\r
+               try\r
+               {\r
+                       System.arraycopy(firstframe, offset, tmp, 0, 4);\r
+                       // Is "VBRI" ?\r
+                       if (vbri.equals(new String(tmp)))\r
+                       {\r
+                               //Yes.\r
+                               h_vbr = true;\r
+                               h_vbr_frames = -1;\r
+                               h_vbr_bytes = -1;\r
+                               h_vbr_scale = -1;\r
+                               h_vbr_toc = new byte[100];\r
+                               // Bytes.                               \r
+                               int length = 4 + 6;\r
+                               System.arraycopy(firstframe, offset + length, tmp, 0, tmp.length);\r
+                               h_vbr_bytes = (tmp[0] << 24)&0xFF000000 | (tmp[1] << 16)&0x00FF0000 | (tmp[2] << 8)&0x0000FF00 | tmp[3]&0x000000FF;\r
+                               length += 4;    \r
+                               // Frames.      \r
+                               System.arraycopy(firstframe, offset + length, tmp, 0, tmp.length);\r
+                               h_vbr_frames = (tmp[0] << 24)&0xFF000000 | (tmp[1] << 16)&0x00FF0000 | (tmp[2] << 8)&0x0000FF00 | tmp[3]&0x000000FF;\r
+                               length += 4;    \r
+                               //System.out.println("VBR:"+vbri+" Frames:"+ h_vbr_frames +" Size:"+h_vbr_bytes);\r
+                               // TOC\r
+                               // TODO                         \r
+                       }\r
+               }\r
+               catch (ArrayIndexOutOfBoundsException e)\r
+               {\r
+                       throw new BitstreamException("VBRIVBRHeader Corrupted",e);\r
+               }\r
+       }\r
+       \r
+       // Functions to query header contents:\r
+       /**\r
+        * Returns version.\r
+        */\r
+       public int version() { return h_version; }\r
+\r
+       /**\r
+        * Returns Layer ID.\r
+        */\r
+       public int layer() { return h_layer; }\r
+\r
+       /**\r
+        * Returns bitrate index.\r
+        */\r
+       public int bitrate_index() { return h_bitrate_index; }\r
+\r
+       /**\r
+        * Returns Sample Frequency.\r
+        */\r
+       public int sample_frequency() { return h_sample_frequency; }\r
+\r
+       /**\r
+        * Returns Frequency.\r
+        */\r
+       public int frequency() {return frequencies[h_version][h_sample_frequency];}\r
+\r
+       /**\r
+        * Returns Mode.\r
+        */\r
+       public int mode() { return h_mode; }\r
+\r
+       /**\r
+        * Returns Protection bit.\r
+        */\r
+       public boolean checksums()\r
+       {\r
+               if (h_protection_bit == 0) return true;\r
+         else return false;\r
+       }\r
+\r
+       /**\r
+        * Returns Copyright.\r
+        */\r
+       public boolean copyright() { return h_copyright; }\r
+\r
+       /**\r
+        * Returns Original.\r
+        */\r
+       public boolean original() { return h_original; }\r
+\r
+       /**\r
+        * Return VBR.\r
+        * @return true if VBR header is found\r
+        */\r
+       public boolean vbr() { return h_vbr; }\r
+\r
+       /**\r
+        * Return VBR scale.\r
+        * @return scale of -1 if not available\r
+        */\r
+       public int vbr_scale() { return h_vbr_scale; }\r
+\r
+       /**\r
+        * Return VBR TOC.\r
+        * @return vbr toc ot null if not available\r
+        */\r
+       public byte[] vbr_toc() { return h_vbr_toc; }\r
+\r
+       /**\r
+        * Returns Checksum flag.\r
+        * Compares computed checksum with stream checksum.\r
+        */\r
+       public boolean checksum_ok () { return (checksum == crc.checksum()); }\r
+\r
+       // Seeking and layer III stuff\r
+       /**\r
+        * Returns Layer III Padding bit.\r
+        */\r
+       public boolean padding()\r
+       {\r
+               if (h_padding_bit == 0) return false;\r
+         else return true;\r
+       }\r
+\r
+       /**\r
+        * Returns Slots.\r
+        */\r
+       public int slots() { return nSlots; }\r
+\r
+       /**\r
+        * Returns Mode Extension.\r
+        */\r
+       public int mode_extension() { return h_mode_extension; }\r
+\r
+       // E.B -> private to public\r
+       public static final int bitrates[][][] = {\r
+               {{0 /*free format*/, 32000, 48000, 56000, 64000, 80000, 96000,\r
+         112000, 128000, 144000, 160000, 176000, 192000 ,224000, 256000, 0},\r
+               {0 /*free format*/, 8000, 16000, 24000, 32000, 40000, 48000,\r
+         56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000, 0},\r
+               {0 /*free format*/, 8000, 16000, 24000, 32000, 40000, 48000,\r
+         56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000, 0}},\r
+\r
+               {{0 /*free format*/, 32000, 64000, 96000, 128000, 160000, 192000,\r
+          224000, 256000, 288000, 320000, 352000, 384000, 416000, 448000, 0},\r
+         {0 /*free format*/, 32000, 48000, 56000, 64000, 80000, 96000,\r
+          112000, 128000, 160000, 192000, 224000, 256000, 320000, 384000, 0},\r
+         {0 /*free format*/, 32000, 40000, 48000, 56000, 64000, 80000,\r
+          96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000, 0}},\r
+               // SZD: MPEG2.5\r
+               {{0 /*free format*/, 32000, 48000, 56000, 64000, 80000, 96000,\r
+         112000, 128000, 144000, 160000, 176000, 192000 ,224000, 256000, 0},\r
+               {0 /*free format*/, 8000, 16000, 24000, 32000, 40000, 48000,\r
+         56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000, 0},\r
+               {0 /*free format*/, 8000, 16000, 24000, 32000, 40000, 48000,\r
+         56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000, 0}},\r
+\r
+               };\r
+\r
+       // E.B -> private to public\r
+       /**\r
+        * Calculate Frame size.\r
+        * Calculates framesize in bytes excluding header size.\r
+        */\r
+       public int calculate_framesize()\r
+       {\r
+\r
+        if (h_layer == 1)\r
+        {\r
+          framesize = (12 * bitrates[h_version][0][h_bitrate_index]) /\r
+                      frequencies[h_version][h_sample_frequency];\r
+          if (h_padding_bit != 0 ) framesize++;\r
+          framesize <<= 2;             // one slot is 4 bytes long\r
+          nSlots = 0;\r
+        }\r
+        else\r
+        {\r
+          framesize = (144 * bitrates[h_version][h_layer - 1][h_bitrate_index]) /\r
+                      frequencies[h_version][h_sample_frequency];\r
+          if (h_version == MPEG2_LSF || h_version == MPEG25_LSF) framesize >>= 1;      // SZD\r
+          if (h_padding_bit != 0) framesize++;\r
+          // Layer III slots\r
+          if (h_layer == 3)\r
+          {\r
+            if (h_version == MPEG1)\r
+            {\r
+                        nSlots = framesize - ((h_mode == SINGLE_CHANNEL) ? 17 : 32) // side info size\r
+                                                                         -  ((h_protection_bit!=0) ? 0 : 2)                   // CRC size\r
+                                                                         - 4;                                                                       // header size\r
+            }\r
+            else\r
+                {  // MPEG-2 LSF, SZD: MPEG-2.5 LSF\r
+               nSlots = framesize - ((h_mode == SINGLE_CHANNEL) ?  9 : 17) // side info size\r
+                                                                 -  ((h_protection_bit!=0) ? 0 : 2)                   // CRC size\r
+                                                                         - 4;                                                                       // header size\r
+            }\r
+          }\r
+          else\r
+          {\r
+                nSlots = 0;\r
+          }\r
+        }\r
+        framesize -= 4;             // subtract header size\r
+        return framesize;\r
+       }\r
+\r
+       /**\r
+        * Returns the maximum number of frames in the stream.\r
+        * @param streamsize\r
+        * @return number of frames\r
+        */\r
+       public int max_number_of_frames(int streamsize)  // E.B\r
+       {\r
+               if (h_vbr == true) return h_vbr_frames;\r
+               else\r
+               {\r
+                       if ((framesize + 4 - h_padding_bit) == 0) return 0;\r
+                       else return(streamsize / (framesize + 4 - h_padding_bit));\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Returns the maximum number of frames in the stream.\r
+        * @param streamsize\r
+        * @return number of frames\r
+        */\r
+       public int min_number_of_frames(int streamsize) // E.B\r
+       {\r
+               if (h_vbr == true) return h_vbr_frames;\r
+               else\r
+               {\r
+                       if ((framesize + 5 - h_padding_bit) == 0) return 0;\r
+                       else return(streamsize / (framesize + 5 - h_padding_bit));\r
+               }\r
+       }\r
+\r
+\r
+       /**\r
+        * Returns ms/frame.\r
+        * @return milliseconds per frame\r
+        */\r
+       public float ms_per_frame() // E.B\r
+       {\r
+               if (h_vbr == true)\r
+               {                       \r
+                       double tpf = h_vbr_time_per_frame[layer()] / frequency();\r
+                       if ((h_version == MPEG2_LSF) || (h_version == MPEG25_LSF)) tpf /= 2;\r
+                       return ((float) (tpf * 1000));\r
+               }\r
+               else\r
+               {\r
+                       float ms_per_frame_array[][] = {{8.707483f,  8.0f, 12.0f},\r
+                                                                                       {26.12245f, 24.0f, 36.0f},\r
+                                                                                       {26.12245f, 24.0f, 36.0f}};\r
+                       return(ms_per_frame_array[h_layer-1][h_sample_frequency]);\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Returns total ms.\r
+        * @param streamsize\r
+        * @return total milliseconds\r
+        */\r
+       public float total_ms(int streamsize) // E.B\r
+       {\r
+               return(max_number_of_frames(streamsize) * ms_per_frame());\r
+       }\r
+\r
+       /**\r
+        * Returns synchronized header.\r
+        */\r
+       public int getSyncHeader() // E.B\r
+       {\r
+               return _headerstring;\r
+       }\r
+\r
+       // functions which return header informations as strings:\r
+       /**\r
+        * Return Layer version.\r
+        */\r
+       public String layer_string()\r
+       {\r
+               switch (h_layer)\r
+               {\r
+          case 1:\r
+               return "I";\r
+          case 2:\r
+               return "II";\r
+          case 3:\r
+               return "III";\r
+               }\r
+         return null;\r
+       }\r
+\r
+       // E.B -> private to public\r
+       public static final String bitrate_str[][][] = {\r
+               {{"free format", "32 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s",\r
+         "80 kbit/s", "96 kbit/s", "112 kbit/s", "128 kbit/s", "144 kbit/s",\r
+         "160 kbit/s", "176 kbit/s", "192 kbit/s", "224 kbit/s", "256 kbit/s",\r
+         "forbidden"},\r
+         {"free format", "8 kbit/s", "16 kbit/s", "24 kbit/s", "32 kbit/s",\r
+         "40 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s", "80 kbit/s",\r
+         "96 kbit/s", "112 kbit/s", "128 kbit/s", "144 kbit/s", "160 kbit/s",\r
+         "forbidden"},\r
+         {"free format", "8 kbit/s", "16 kbit/s", "24 kbit/s", "32 kbit/s",\r
+         "40 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s", "80 kbit/s",\r
+         "96 kbit/s", "112 kbit/s", "128 kbit/s", "144 kbit/s", "160 kbit/s",\r
+         "forbidden"}},\r
+\r
+         {{"free format", "32 kbit/s", "64 kbit/s", "96 kbit/s", "128 kbit/s",\r
+         "160 kbit/s", "192 kbit/s", "224 kbit/s", "256 kbit/s", "288 kbit/s",\r
+         "320 kbit/s", "352 kbit/s", "384 kbit/s", "416 kbit/s", "448 kbit/s",\r
+         "forbidden"},\r
+         {"free format", "32 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s",\r
+         "80 kbit/s", "96 kbit/s", "112 kbit/s", "128 kbit/s", "160 kbit/s",\r
+         "192 kbit/s", "224 kbit/s", "256 kbit/s", "320 kbit/s", "384 kbit/s",\r
+         "forbidden"},\r
+         {"free format", "32 kbit/s", "40 kbit/s", "48 kbit/s", "56 kbit/s",\r
+         "64 kbit/s", "80 kbit/s" , "96 kbit/s", "112 kbit/s", "128 kbit/s",\r
+         "160 kbit/s", "192 kbit/s", "224 kbit/s", "256 kbit/s", "320 kbit/s",\r
+         "forbidden"}},\r
+               // SZD: MPEG2.5\r
+               {{"free format", "32 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s",\r
+         "80 kbit/s", "96 kbit/s", "112 kbit/s", "128 kbit/s", "144 kbit/s",\r
+         "160 kbit/s", "176 kbit/s", "192 kbit/s", "224 kbit/s", "256 kbit/s",\r
+         "forbidden"},\r
+         {"free format", "8 kbit/s", "16 kbit/s", "24 kbit/s", "32 kbit/s",\r
+         "40 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s", "80 kbit/s",\r
+         "96 kbit/s", "112 kbit/s", "128 kbit/s", "144 kbit/s", "160 kbit/s",\r
+         "forbidden"},\r
+         {"free format", "8 kbit/s", "16 kbit/s", "24 kbit/s", "32 kbit/s",\r
+         "40 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s", "80 kbit/s",\r
+         "96 kbit/s", "112 kbit/s", "128 kbit/s", "144 kbit/s", "160 kbit/s",\r
+         "forbidden"}},\r
+         };\r
+\r
+       /**\r
+        * Return Bitrate.\r
+        * @return bitrate in bps\r
+        */\r
+       public String bitrate_string()\r
+       {\r
+               if (h_vbr == true)\r
+               {\r
+                       return Integer.toString(bitrate()/1000)+" kb/s";                \r
+               }\r
+         else return bitrate_str[h_version][h_layer - 1][h_bitrate_index];\r
+       }\r
+\r
+       /**\r
+        * Return Bitrate.\r
+        * @return bitrate in bps and average bitrate for VBR header\r
+        */\r
+       public int bitrate()\r
+       {\r
+               if (h_vbr == true)\r
+               {\r
+                       return ((int) ((h_vbr_bytes * 8) / (ms_per_frame() * h_vbr_frames)))*1000;              \r
+               }\r
+               else return bitrates[h_version][h_layer - 1][h_bitrate_index];\r
+       }\r
+\r
+       /**\r
+        * Return Instant Bitrate.\r
+        * Bitrate for VBR is not constant.\r
+        * @return bitrate in bps\r
+        */\r
+       public int bitrate_instant()\r
+       {\r
+               return bitrates[h_version][h_layer - 1][h_bitrate_index];\r
+       }\r
+\r
+       /**\r
+        * Returns Frequency\r
+        * @return frequency string in kHz\r
+        */\r
+       public String sample_frequency_string()\r
+       {\r
+               switch (h_sample_frequency)\r
+               {\r
+           case THIRTYTWO:\r
+               if (h_version == MPEG1)\r
+                       return "32 kHz";\r
+               else if (h_version == MPEG2_LSF)\r
+               return "16 kHz";\r
+           else        // SZD\r
+               return "8 kHz";\r
+           case FOURTYFOUR_POINT_ONE:\r
+               if (h_version == MPEG1)\r
+                       return "44.1 kHz";\r
+               else if (h_version == MPEG2_LSF)\r
+               return "22.05 kHz";\r
+               else    // SZD\r
+               return "11.025 kHz";\r
+           case FOURTYEIGHT:\r
+               if (h_version == MPEG1)\r
+                       return "48 kHz";\r
+               else if (h_version == MPEG2_LSF)\r
+               return "24 kHz";\r
+               else    // SZD\r
+                       return "12 kHz";\r
+         }\r
+         return(null);\r
+       }\r
+\r
+       /**\r
+        * Returns Mode.\r
+        */\r
+       public String mode_string()\r
+       {\r
+          switch (h_mode)\r
+          {\r
+            case STEREO:\r
+               return "Stereo";\r
+            case JOINT_STEREO:\r
+               return "Joint stereo";\r
+            case DUAL_CHANNEL:\r
+               return "Dual channel";\r
+            case SINGLE_CHANNEL:\r
+               return "Single channel";\r
+          }\r
+          return null;\r
+       }\r
+\r
+       /**\r
+        * Returns Version.\r
+        * @return MPEG-1 or MPEG-2 LSF or MPEG-2.5 LSF\r
+        */\r
+       public String version_string()\r
+       {\r
+         switch (h_version)\r
+         {\r
+           case MPEG1:\r
+             return "MPEG-1";\r
+           case MPEG2_LSF:\r
+             return "MPEG-2 LSF";\r
+           case MPEG25_LSF:    // SZD\r
+             return "MPEG-2.5 LSF";\r
+         }\r
+         return(null);\r
+       }\r
+\r
+       /**\r
+        * Returns the number of subbands in the current frame.\r
+        * @return number of subbands\r
+        */\r
+       public int number_of_subbands() {return h_number_of_subbands;}\r
+\r
+       /**\r
+        * Returns Intensity Stereo.\r
+        * (Layer II joint stereo only).\r
+        * Returns the number of subbands which are in stereo mode,\r
+        * subbands above that limit are in intensity stereo mode.\r
+        * @return intensity\r
+        */\r
+       public int intensity_stereo_bound() {return h_intensity_stereo_bound;}\r
+}\r
diff --git a/Robust/src/Tests/ssJava/mp3decoder/InputStreamSource.java b/Robust/src/Tests/ssJava/mp3decoder/InputStreamSource.java
new file mode 100644 (file)
index 0000000..fb6c029
--- /dev/null
@@ -0,0 +1,80 @@
+/*\r
+ * 11/19/04            1.0 moved to LGPL.\r
+ * 12/12/99            Initial version.        mdm@techie.com\r
+ *-----------------------------------------------------------------------\r
+ *   This program is free software; you can redistribute it and/or modify\r
+ *   it under the terms of the GNU Library General Public License as published\r
+ *   by the Free Software Foundation; either version 2 of the License, or\r
+ *   (at your option) any later version.\r
+ *\r
+ *   This program is distributed in the hope that it will be useful,\r
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *   GNU Library General Public License for more details.\r
+ *\r
+ *   You should have received a copy of the GNU Library General Public\r
+ *   License along with this program; if not, write to the Free Software\r
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ *----------------------------------------------------------------------\r
+ */\r
+\r
+package javazoom.jl.decoder;\r
+\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+\r
+/**\r
+ * <i>Work In Progress.</i>\r
+ * \r
+ * An instance of <code>InputStreamSource</code> implements a\r
+ * <code>Source</code> that provides data from an <code>InputStream\r
+ * </code>. Seeking functionality is not supported. \r
+ * \r
+ * @author MDM\r
+ */\r
+public class InputStreamSource implements Source\r
+{\r
+       private final InputStream               in;\r
+       \r
+       public InputStreamSource(InputStream in)\r
+       {\r
+               if (in==null)\r
+                       throw new NullPointerException("in");\r
+               \r
+               this.in = in;           \r
+       }\r
+       \r
+       public int read(byte[] b, int offs, int len)\r
+               throws IOException\r
+       {\r
+               int read = in.read(b, offs, len);\r
+               return read;\r
+       }\r
+       \r
+       public boolean willReadBlock()\r
+       {\r
+               return true;\r
+               //boolean block = (in.available()==0);\r
+               //return block;\r
+       }\r
+       \r
+       public boolean isSeekable()\r
+       {\r
+               return false;   \r
+       }\r
+       \r
+       public long     tell()\r
+       {\r
+               return -1;      \r
+       }\r
+       \r
+       public long     seek(long to)\r
+       {\r
+               return -1;      \r
+       }\r
+       \r
+       public long length()\r
+       {\r
+               return -1;\r
+       }\r
+}\r
diff --git a/Robust/src/Tests/ssJava/mp3decoder/JavaLayerError.java b/Robust/src/Tests/ssJava/mp3decoder/JavaLayerError.java
new file mode 100644 (file)
index 0000000..042d83a
--- /dev/null
@@ -0,0 +1,31 @@
+/*\r
+ * 11/19/04            1.0 moved to LGPL.\r
+ * 12/12/99            Initial version.        mdm@techie.com\r
+ *-----------------------------------------------------------------------\r
+ *   This program is free software; you can redistribute it and/or modify\r
+ *   it under the terms of the GNU Library General Public License as published\r
+ *   by the Free Software Foundation; either version 2 of the License, or\r
+ *   (at your option) any later version.\r
+ *\r
+ *   This program is distributed in the hope that it will be useful,\r
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *   GNU Library General Public License for more details.\r
+ *\r
+ *   You should have received a copy of the GNU Library General Public\r
+ *   License along with this program; if not, write to the Free Software\r
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ *----------------------------------------------------------------------\r
+ */\r
+\r
+package javazoom.jl.decoder;\r
+\r
+/**\r
+ * Work in progress.\r
+ * \r
+ * API usage errors may be handled by throwing an instance of this\r
+ * class, as per JMF 2.0. \r
+ */\r
+public class JavaLayerError extends Error\r
+{      \r
+}\r
diff --git a/Robust/src/Tests/ssJava/mp3decoder/JavaLayerErrors.java b/Robust/src/Tests/ssJava/mp3decoder/JavaLayerErrors.java
new file mode 100644 (file)
index 0000000..b141ce8
--- /dev/null
@@ -0,0 +1,40 @@
+/*\r
+ * 11/19/04            1.0 moved to LGPL.\r
+ * 12/12/99            Initial version.        mdm@techie.com\r
+ *-----------------------------------------------------------------------\r
+ *   This program is free software; you can redistribute it and/or modify\r
+ *   it under the terms of the GNU Library General Public License as published\r
+ *   by the Free Software Foundation; either version 2 of the License, or\r
+ *   (at your option) any later version.\r
+ *\r
+ *   This program is distributed in the hope that it will be useful,\r
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *   GNU Library General Public License for more details.\r
+ *\r
+ *   You should have received a copy of the GNU Library General Public\r
+ *   License along with this program; if not, write to the Free Software\r
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ *----------------------------------------------------------------------\r
+ */\r
+\r
+package javazoom.jl.decoder;\r
+\r
+/**\r
+ * Exception erorr codes for components of the JavaLayer API.\r
+ */\r
+public interface JavaLayerErrors\r
+{\r
+       /**\r
+        * The first bitstream error code. See the {@link DecoderErrors DecoderErrors}\r
+        * interface for other bitstream error codes.\r
+        */\r
+       static public final int BITSTREAM_ERROR = 0x100;\r
+\r
+       /**\r
+        * The first decoder error code. See the {@link DecoderErrors DecoderErrors}\r
+        * interface for other decoder error codes.\r
+        */\r
+       static public final int DECODER_ERROR = 0x200;\r
+\r
+}\r
diff --git a/Robust/src/Tests/ssJava/mp3decoder/JavaLayerException.java b/Robust/src/Tests/ssJava/mp3decoder/JavaLayerException.java
new file mode 100644 (file)
index 0000000..0767bf2
--- /dev/null
@@ -0,0 +1,80 @@
+/*\r
+ * 11/19/04            1.0 moved to LGPL.\r
+ * 12/12/99            Initial version.        mdm@techie.com\r
+ *-----------------------------------------------------------------------\r
+ *   This program is free software; you can redistribute it and/or modify\r
+ *   it under the terms of the GNU Library General Public License as published\r
+ *   by the Free Software Foundation; either version 2 of the License, or\r
+ *   (at your option) any later version.\r
+ *\r
+ *   This program is distributed in the hope that it will be useful,\r
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *   GNU Library General Public License for more details.\r
+ *\r
+ *   You should have received a copy of the GNU Library General Public\r
+ *   License along with this program; if not, write to the Free Software\r
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ *----------------------------------------------------------------------\r
+ */\r
+\r
+package javazoom.jl.decoder;\r
+\r
+import java.io.PrintStream;\r
+\r
+\r
+/**\r
+ * The JavaLayerException is the base class for all API-level\r
+ * exceptions thrown by JavaLayer. To facilitate conversion and \r
+ * common handling of exceptions from other domains, the class \r
+ * can delegate some functionality to a contained Throwable instance. \r
+ * <p> \r
+ * \r
+ * @author MDM\r
+ */\r
+public class JavaLayerException extends Exception\r
+{\r
+       \r
+       private Throwable               exception;\r
+       \r
+       \r
+       public JavaLayerException()\r
+       {\r
+       }\r
+       \r
+       public JavaLayerException(String msg)\r
+       {\r
+               super(msg);\r
+       }\r
+       \r
+       public JavaLayerException(String msg, Throwable t)\r
+       {\r
+               super(msg);\r
+               exception = t;\r
+       }\r
+       \r
+       public Throwable getException()\r
+       {\r
+               return exception;       \r
+       }\r
+       \r
+       \r
+       public void printStackTrace()\r
+       {\r
+               printStackTrace(System.err);    \r
+       }\r
+       \r
+       public void printStackTrace(PrintStream ps)\r
+       {\r
+               if (this.exception==null)\r
+               {\r
+                       super.printStackTrace(ps);      \r
+               }\r
+               else\r
+               {\r
+                       exception.printStackTrace();\r
+               }\r
+       }\r
+       \r
+       \r
+}\r
diff --git a/Robust/src/Tests/ssJava/mp3decoder/JavaLayerHook.java b/Robust/src/Tests/ssJava/mp3decoder/JavaLayerHook.java
new file mode 100644 (file)
index 0000000..edd890d
--- /dev/null
@@ -0,0 +1,36 @@
+/*\r
+ * 11/19/04            1.0 moved to LGPL.\r
+ *-----------------------------------------------------------------------\r
+ *   This program is free software; you can redistribute it and/or modify\r
+ *   it under the terms of the GNU Library General Public License as published\r
+ *   by the Free Software Foundation; either version 2 of the License, or\r
+ *   (at your option) any later version.\r
+ *\r
+ *   This program is distributed in the hope that it will be useful,\r
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *   GNU Library General Public License for more details.\r
+ *\r
+ *   You should have received a copy of the GNU Library General Public\r
+ *   License along with this program; if not, write to the Free Software\r
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ *----------------------------------------------------------------------\r
+ */\r
+\r
+package javazoom.jl.decoder;\r
+\r
+import java.io.InputStream;\r
+\r
+/**\r
+ * The <code>JavaLayerHooks</code> class allows developers to change\r
+ * the way the JavaLayer library uses Resources. \r
+ */\r
+\r
+public interface JavaLayerHook\r
+{\r
+       /**\r
+        * Retrieves the named resource. This allows resources to be\r
+        * obtained without specifying how they are retrieved. \r
+        */\r
+       public InputStream getResourceAsStream(String name);\r
+}\r
diff --git a/Robust/src/Tests/ssJava/mp3decoder/JavaLayerUtils.java b/Robust/src/Tests/ssJava/mp3decoder/JavaLayerUtils.java
new file mode 100644 (file)
index 0000000..b7cd548
--- /dev/null
@@ -0,0 +1,207 @@
+/*\r
+ * 11/19/04            1.0 moved to LGPL.\r
+ * 12/12/99            Initial version.        mdm@techie.com\r
+ *-----------------------------------------------------------------------\r
+ *   This program is free software; you can redistribute it and/or modify\r
+ *   it under the terms of the GNU Library General Public License as published\r
+ *   by the Free Software Foundation; either version 2 of the License, or\r
+ *   (at your option) any later version.\r
+ *\r
+ *   This program is distributed in the hope that it will be useful,\r
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *   GNU Library General Public License for more details.\r
+ *\r
+ *   You should have received a copy of the GNU Library General Public\r
+ *   License along with this program; if not, write to the Free Software\r
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ *----------------------------------------------------------------------\r
+ */\r
+\r
+package javazoom.jl.decoder;\r
+\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.io.InvalidClassException;\r
+import java.io.InvalidObjectException;\r
+import java.io.ObjectInputStream;\r
+import java.io.ObjectOutputStream;\r
+import java.io.OutputStream;\r
+import java.lang.reflect.Array;\r
+\r
+/**\r
+ * The JavaLayerUtils class is not strictly part of the JavaLayer API.\r
+ * It serves to provide useful methods and system-wide hooks.\r
+ * \r
+ * @author MDM\r
+ */\r
+public class JavaLayerUtils\r
+{\r
+       static private JavaLayerHook    hook = null;\r
+       \r
+       /**\r
+        * Deserializes the object contained in the given input stream.\r
+        * @param in    The input stream to deserialize an object from.\r
+        * @param cls   The expected class of the deserialized object. \r
+        */\r
+       static public Object deserialize(InputStream in, Class cls)\r
+               throws IOException\r
+       {\r
+               if (cls==null)\r
+                       throw new NullPointerException("cls");\r
+               \r
+               Object obj = deserialize(in, cls);\r
+               if (!cls.isInstance(obj))\r
+               {\r
+                       throw new InvalidObjectException("type of deserialized instance not of required class.");\r
+               }\r
+               \r
+               return obj;\r
+       }\r
+       \r
+       /**\r
+        * Deserializes an object from the given <code>InputStream</code>.\r
+        * The deserialization is delegated to an <code>\r
+        * ObjectInputStream</code> instance. \r
+        * \r
+        * @param in    The <code>InputStream</code> to deserialize an object\r
+        *                              from.\r
+        * \r
+        * @return The object deserialized from the stream. \r
+        * @exception IOException is thrown if there was a problem reading\r
+        *              the underlying stream, or an object could not be deserialized\r
+        *              from the stream.\r
+        * \r
+        * @see java.io.ObjectInputStream\r
+        */\r
+       static public Object deserialize(InputStream in)\r
+               throws IOException\r
+       {\r
+               if (in==null)\r
+                       throw new NullPointerException("in");\r
+               \r
+               ObjectInputStream objIn = new ObjectInputStream(in);\r
+               \r
+               Object obj;\r
+               \r
+               try\r
+               {\r
+                       obj = objIn.readObject();\r
+               }\r
+               catch (ClassNotFoundException ex)\r
+               {\r
+                       throw new InvalidClassException(ex.toString());\r
+               }\r
+               \r
+               return obj;\r
+       }\r
+\r
+       /**\r
+        * Deserializes an array from a given <code>InputStream</code>.\r
+        * \r
+        * @param in            The <code>InputStream</code> to \r
+        *                                      deserialize an object from.\r
+        *                              \r
+        * @param elemType      The class denoting the type of the array\r
+        *                                      elements.\r
+        * @param length        The expected length of the array, or -1 if\r
+        *                                      any length is expected.\r
+        */\r
+       static public Object deserializeArray(InputStream in, Class elemType, int length)\r
+               throws IOException\r
+       {\r
+               if (elemType==null)\r
+                       throw new NullPointerException("elemType");\r
+               \r
+               if (length<-1)\r
+                       throw new IllegalArgumentException("length");\r
+               \r
+               Object obj = deserialize(in);\r
+               \r
+               Class cls = obj.getClass();\r
+               \r
+               \r
+               if (!cls.isArray())\r
+                       throw new InvalidObjectException("object is not an array");\r
+               \r
+               Class arrayElemType = cls.getComponentType();\r
+               if (arrayElemType!=elemType)\r
+                       throw new InvalidObjectException("unexpected array component type");\r
+                               \r
+               if (length != -1)\r
+               {\r
+                       int arrayLength = Array.getLength(obj);\r
+                       if (arrayLength!=length)\r
+                               throw new InvalidObjectException("array length mismatch");\r
+               }\r
+               \r
+               return obj;\r
+       }\r
+\r
+       static public Object deserializeArrayResource(String name, Class elemType, int length)\r
+               throws IOException\r
+       {               \r
+               InputStream str = getResourceAsStream(name);\r
+               if (str==null)\r
+                       throw new IOException("unable to load resource '"+name+"'");\r
+               \r
+               Object obj = deserializeArray(str, elemType, length);\r
+               \r
+               return obj;\r
+       }       \r
+       \r
+       static public void serialize(OutputStream out, Object obj)\r
+               throws IOException\r
+       {\r
+               if (out==null)\r
+                       throw new NullPointerException("out");\r
+               \r
+               if (obj==null)\r
+                       throw new NullPointerException("obj");\r
+               \r
+               ObjectOutputStream objOut = new ObjectOutputStream(out);\r
+               objOut.writeObject(obj);\r
+                               \r
+       }\r
+\r
+       /**\r
+        * Sets the system-wide JavaLayer hook.\r
+        */\r
+       static synchronized public void setHook(JavaLayerHook hook0)            \r
+       {\r
+               hook = hook0;\r
+       }\r
+       \r
+       static synchronized public JavaLayerHook getHook()\r
+       {\r
+               return hook;    \r
+       }\r
+       \r
+       /**\r
+        * Retrieves an InputStream for a named resource. \r
+        * \r
+        * @param name  The name of the resource. This must be a simple\r
+        *                              name, and not a qualified package name.\r
+        * \r
+        * @return              The InputStream for the named resource, or null if\r
+        *                              the resource has not been found. If a hook has been \r
+        *                              provided, its getResourceAsStream() method is called\r
+        *                              to retrieve the resource. \r
+        */\r
+       static synchronized public InputStream getResourceAsStream(String name)\r
+       {\r
+               InputStream is = null;\r
+               \r
+               if (hook!=null)\r
+               {\r
+                       is = hook.getResourceAsStream(name);    \r
+               }\r
+               else\r
+               {\r
+                       Class cls = JavaLayerUtils.class;\r
+                       is = cls.getResourceAsStream(name);\r
+               }\r
+               \r
+               return is;              \r
+       }\r
+}\r
diff --git a/Robust/src/Tests/ssJava/mp3decoder/LayerIDecoder.java b/Robust/src/Tests/ssJava/mp3decoder/LayerIDecoder.java
new file mode 100644 (file)
index 0000000..fb936d2
--- /dev/null
@@ -0,0 +1,448 @@
+/*
+ * 09/26/08     throw exception on subbband alloc error: Christopher G. Jennings (cjennings@acm.org)
+ * 
+ * 11/19/04            1.0 moved to LGPL.
+ * 
+ * 12/12/99            Initial version. Adapted from javalayer.java
+ *                             and Subband*.java. mdm@techie.com
+ *
+ * 02/28/99            Initial version : javalayer.java by E.B
+ *-----------------------------------------------------------------------
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU Library General Public License as published
+ *   by the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU Library General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Library General Public
+ *   License along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *----------------------------------------------------------------------
+ */
+package javazoom.jl.decoder;
+
+/**
+ * Implements decoding of MPEG Audio Layer I frames. 
+ */
+class LayerIDecoder implements FrameDecoder
+{
+       protected Bitstream                     stream;
+    protected Header                           header;
+    protected SynthesisFilter          filter1, filter2;
+    protected Obuffer                          buffer;
+    protected int                                      which_channels;
+       protected int                                   mode;
+       
+       protected int                                   num_subbands;
+       protected Subband[]                             subbands;
+       protected Crc16                                 crc     = null; // new Crc16[1] to enable CRC checking.
+       
+       public LayerIDecoder()
+       {
+               crc = new Crc16();
+       }
+       
+       public void create(Bitstream stream0, Header header0,
+               SynthesisFilter filtera, SynthesisFilter filterb,
+               Obuffer buffer0, int which_ch0)
+       {               
+               stream         = stream0;
+               header         = header0;
+               filter1        = filtera;
+               filter2        = filterb;
+               buffer         = buffer0;
+               which_channels = which_ch0;
+                 
+       }
+       
+       public void decodeFrame() throws DecoderException
+       {
+               
+               num_subbands = header.number_of_subbands();
+               subbands = new Subband[32];
+               mode = header.mode();
+               
+               createSubbands();
+               
+               readAllocation();
+               readScaleFactorSelection();
+               
+           if ((crc != null) || header.checksum_ok())
+               {
+                       readScaleFactors();
+                       
+                       readSampleData();                       
+               }
+
+       }
+
+       protected void createSubbands()
+       {               
+               int i;
+               if (mode == Header.SINGLE_CHANNEL)
+                 for (i = 0; i < num_subbands; ++i)
+                   subbands[i] = new SubbandLayer1(i);
+               else if (mode == Header.JOINT_STEREO)
+               {
+                 for (i = 0; i < header.intensity_stereo_bound(); ++i)
+                   subbands[i] = new SubbandLayer1Stereo(i);
+                 for (; i < num_subbands; ++i)
+                   subbands[i] = new SubbandLayer1IntensityStereo(i);
+               }
+               else
+               {
+                 for (i = 0; i < num_subbands; ++i)
+                   subbands[i] = new SubbandLayer1Stereo(i);
+           }           
+       }
+       
+       protected void readAllocation() throws DecoderException
+       {
+               // start to read audio data:
+           for (int i = 0; i < num_subbands; ++i)
+             subbands[i].read_allocation(stream, header, crc);
+               
+       }
+
+       protected void readScaleFactorSelection()
+       {
+               // scale factor selection not present for layer I. 
+       }
+       
+       protected void readScaleFactors()
+       {
+               for (int i = 0; i < num_subbands; ++i)
+                 subbands[i].read_scalefactor(stream, header);                 
+       }
+       
+       protected void readSampleData()
+       {
+               boolean read_ready = false;
+               boolean write_ready = false;
+               int mode = header.mode();
+               int i;
+               do
+               {
+                 for (i = 0; i < num_subbands; ++i)
+                       read_ready = subbands[i].read_sampledata(stream);
+                 do
+                 {
+                       for (i = 0; i < num_subbands; ++i)
+                               write_ready = subbands[i].put_next_sample(which_channels,filter1, filter2);
+
+                       filter1.calculate_pcm_samples(buffer);
+                       if ((which_channels == OutputChannels.BOTH_CHANNELS) && (mode != Header.SINGLE_CHANNEL))
+                       filter2.calculate_pcm_samples(buffer);
+                 } while (!write_ready);
+               } while (!read_ready);
+               
+       }
+
+       /**
+        * Abstract base class for subband classes of layer I and II
+        */
+       static abstract class Subband
+       {
+        /*
+         *  Changes from version 1.1 to 1.2:
+         *    - array size increased by one, although a scalefactor with index 63
+         *      is illegal (to prevent segmentation faults)
+         */
+         // Scalefactors for layer I and II, Annex 3-B.1 in ISO/IEC DIS 11172:
+         public static final float scalefactors[] =
+         {
+         2.00000000000000f, 1.58740105196820f, 1.25992104989487f, 1.00000000000000f,
+         0.79370052598410f, 0.62996052494744f, 0.50000000000000f, 0.39685026299205f,
+         0.31498026247372f, 0.25000000000000f, 0.19842513149602f, 0.15749013123686f,
+         0.12500000000000f, 0.09921256574801f, 0.07874506561843f, 0.06250000000000f,
+         0.04960628287401f, 0.03937253280921f, 0.03125000000000f, 0.02480314143700f,
+         0.01968626640461f, 0.01562500000000f, 0.01240157071850f, 0.00984313320230f,
+         0.00781250000000f, 0.00620078535925f, 0.00492156660115f, 0.00390625000000f,
+         0.00310039267963f, 0.00246078330058f, 0.00195312500000f, 0.00155019633981f,
+         0.00123039165029f, 0.00097656250000f, 0.00077509816991f, 0.00061519582514f,
+         0.00048828125000f, 0.00038754908495f, 0.00030759791257f, 0.00024414062500f,
+         0.00019377454248f, 0.00015379895629f, 0.00012207031250f, 0.00009688727124f,
+         0.00007689947814f, 0.00006103515625f, 0.00004844363562f, 0.00003844973907f,
+         0.00003051757813f, 0.00002422181781f, 0.00001922486954f, 0.00001525878906f,
+         0.00001211090890f, 0.00000961243477f, 0.00000762939453f, 0.00000605545445f,
+         0.00000480621738f, 0.00000381469727f, 0.00000302772723f, 0.00000240310869f,
+         0.00000190734863f, 0.00000151386361f, 0.00000120155435f, 0.00000000000000f /* illegal scalefactor */
+         };
+
+         public abstract void read_allocation (Bitstream stream, Header header, Crc16 crc) throws DecoderException;
+         public abstract void read_scalefactor (Bitstream stream, Header header);
+         public abstract boolean read_sampledata (Bitstream stream);
+         public abstract boolean put_next_sample (int channels, SynthesisFilter filter1, SynthesisFilter filter2);
+       };
+       
+       /**
+        * Class for layer I subbands in single channel mode.
+        * Used for single channel mode
+        * and in derived class for intensity stereo mode
+        */
+       static class SubbandLayer1 extends Subband
+       {
+
+         // Factors and offsets for sample requantization
+         public static final float table_factor[] = {
+          0.0f, (1.0f/2.0f) * (4.0f/3.0f), (1.0f/4.0f) * (8.0f/7.0f), (1.0f/8.0f) * (16.0f/15.0f),
+         (1.0f/16.0f) * (32.0f/31.0f), (1.0f/32.0f) * (64.0f/63.0f), (1.0f/64.0f) * (128.0f/127.0f),
+         (1.0f/128.0f) * (256.0f/255.0f), (1.0f/256.0f) * (512.0f/511.0f),
+         (1.0f/512.0f) * (1024.0f/1023.0f), (1.0f/1024.0f) * (2048.0f/2047.0f),
+         (1.0f/2048.0f) * (4096.0f/4095.0f), (1.0f/4096.0f) * (8192.0f/8191.0f),
+         (1.0f/8192.0f) * (16384.0f/16383.0f), (1.0f/16384.0f) * (32768.0f/32767.0f)
+         };
+
+         public static final float table_offset[] = {
+          0.0f, ((1.0f/2.0f)-1.0f) * (4.0f/3.0f), ((1.0f/4.0f)-1.0f) * (8.0f/7.0f), ((1.0f/8.0f)-1.0f) * (16.0f/15.0f),
+         ((1.0f/16.0f)-1.0f) * (32.0f/31.0f), ((1.0f/32.0f)-1.0f) * (64.0f/63.0f), ((1.0f/64.0f)-1.0f) * (128.0f/127.0f),
+         ((1.0f/128.0f)-1.0f) * (256.0f/255.0f), ((1.0f/256.0f)-1.0f) * (512.0f/511.0f),
+         ((1.0f/512.0f)-1.0f) * (1024.0f/1023.0f), ((1.0f/1024.0f)-1.0f) * (2048.0f/2047.0f),
+         ((1.0f/2048.0f)-1.0f) * (4096.0f/4095.0f), ((1.0f/4096.0f)-1.0f) * (8192.0f/8191.0f),
+         ((1.0f/8192.0f)-1.0f) * (16384.0f/16383.0f), ((1.0f/16384.0f)-1.0f) * (32768.0f/32767.0f)
+         };
+
+         protected int                  subbandnumber;
+         protected int                  samplenumber;
+         protected int                  allocation;
+         protected float                scalefactor;
+         protected int                  samplelength;
+         protected float                sample;
+         protected float                factor, offset;
+
+         /**
+          * Construtor.
+          */
+         public SubbandLayer1(int subbandnumber)
+         {
+           this.subbandnumber = subbandnumber;
+           samplenumber = 0;  
+         }
+         
+         /**
+          *
+          */
+         public void read_allocation(Bitstream stream, Header header, Crc16 crc) throws DecoderException
+         {
+           if ((allocation = stream.get_bits (4)) == 15) 
+           {
+               // CGJ: catch this condition and throw appropriate exception
+               throw new DecoderException(DecoderErrors.ILLEGAL_SUBBAND_ALLOCATION, null);     
+               //       cerr << "WARNING: stream contains an illegal allocation!\n";
+                       // MPEG-stream is corrupted!
+           }
+
+               if (crc != null) crc.add_bits (allocation, 4);
+               if (allocation != 0)
+           {
+                samplelength = allocation + 1;
+                factor = table_factor[allocation];
+            offset = table_offset[allocation];
+           }
+         }
+
+         /**
+          *
+          */
+         public void read_scalefactor(Bitstream stream, Header header)
+         {
+           if (allocation != 0) scalefactor = scalefactors[stream.get_bits(6)];
+         }
+
+         /**
+          *
+          */
+         public boolean read_sampledata(Bitstream stream)
+         {
+           if (allocation != 0)
+           {
+                  sample = (float) (stream.get_bits(samplelength));
+           }
+           if (++samplenumber == 12)
+           {
+                  samplenumber = 0;
+                  return true;
+           }
+           return false;  
+         }
+
+         /**
+          *
+          */
+         public boolean put_next_sample(int channels, SynthesisFilter filter1, SynthesisFilter filter2)
+         {
+           if ((allocation !=0) && (channels != OutputChannels.RIGHT_CHANNEL))
+           {
+                  float scaled_sample = (sample * factor + offset) * scalefactor;
+                  filter1.input_sample (scaled_sample, subbandnumber);
+           }
+           return true;
+         }
+       };
+       
+       /**
+        * Class for layer I subbands in joint stereo mode.
+        */
+       static class SubbandLayer1IntensityStereo extends SubbandLayer1
+       {
+         protected float               channel2_scalefactor;
+
+         /**
+          * Constructor
+          */
+         public SubbandLayer1IntensityStereo(int subbandnumber)
+         {
+               super(subbandnumber);  
+         }
+
+         /**
+          *
+          */
+         public void read_allocation(Bitstream stream, Header header, Crc16 crc) throws DecoderException
+         {
+           super.read_allocation (stream, header, crc);
+         }
+         
+         /**
+          *
+          */
+         public void read_scalefactor (Bitstream stream, Header header)
+         {
+           if (allocation != 0)
+           {
+                 scalefactor = scalefactors[stream.get_bits(6)];
+                 channel2_scalefactor = scalefactors[stream.get_bits(6)];
+           }
+         }
+
+         /**
+          *
+          */
+         public boolean read_sampledata(Bitstream stream)
+         {
+                return super.read_sampledata (stream);
+         }
+         
+         /**
+          *
+          */
+         public boolean put_next_sample (int channels, SynthesisFilter filter1, SynthesisFilter filter2)
+         {
+           if (allocation !=0 )
+           {
+             sample = sample * factor + offset;                // requantization
+                 if (channels == OutputChannels.BOTH_CHANNELS)
+             {
+                       float sample1 = sample * scalefactor,
+                       sample2 = sample * channel2_scalefactor;
+                       filter1.input_sample(sample1, subbandnumber);
+                       filter2.input_sample(sample2, subbandnumber);
+                 }
+                 else if (channels == OutputChannels.LEFT_CHANNEL)
+                 {
+                       float sample1 = sample * scalefactor;
+                       filter1.input_sample(sample1, subbandnumber);
+                 }
+                 else
+                 {
+                       float sample2 = sample * channel2_scalefactor;
+                       filter1.input_sample(sample2, subbandnumber);
+                 }
+           }
+           return true;
+         }
+       };
+       
+       /**
+        * Class for layer I subbands in stereo mode.
+        */
+       static class SubbandLayer1Stereo extends SubbandLayer1
+       {
+         protected int                 channel2_allocation;
+         protected float               channel2_scalefactor;
+         protected int                 channel2_samplelength;
+         protected float               channel2_sample;
+         protected float               channel2_factor, channel2_offset;
+
+
+         /**
+          * Constructor
+          */
+         public SubbandLayer1Stereo(int subbandnumber)
+         {
+           super(subbandnumber);
+         }
+         
+         /**
+          *
+          */
+         public void read_allocation (Bitstream stream, Header header, Crc16 crc) throws DecoderException
+         {
+                allocation = stream.get_bits(4);
+            channel2_allocation = stream.get_bits(4);
+            if (crc != null)
+            {
+                  crc.add_bits (allocation, 4);
+              crc.add_bits (channel2_allocation, 4);
+            }
+            if (allocation != 0)
+            {
+                   samplelength = allocation + 1;
+               factor = table_factor[allocation];
+               offset = table_offset[allocation];
+            }
+            if (channel2_allocation != 0)
+            {
+               channel2_samplelength = channel2_allocation + 1;
+                   channel2_factor = table_factor[channel2_allocation];
+                   channel2_offset = table_offset[channel2_allocation];
+            }
+         }
+         
+         /**
+          *
+          */
+         public void read_scalefactor(Bitstream stream, Header header)
+         {
+           if (allocation != 0) scalefactor = scalefactors[stream.get_bits(6)];
+           if (channel2_allocation != 0) channel2_scalefactor = scalefactors[stream.get_bits(6)];
+         }
+
+         /**
+          *
+          */
+         public boolean read_sampledata (Bitstream stream)
+         {
+            boolean returnvalue = super.read_sampledata(stream);
+            if (channel2_allocation != 0)
+            {
+                   channel2_sample = (float) (stream.get_bits(channel2_samplelength));
+             }
+           return(returnvalue);
+         }
+         
+         /**
+          *
+          */
+         public boolean put_next_sample(int channels, SynthesisFilter filter1, SynthesisFilter filter2)
+         {
+            super.put_next_sample (channels, filter1, filter2);
+            if ((channel2_allocation != 0) && (channels != OutputChannels.LEFT_CHANNEL))
+            {
+                   float sample2 = (channel2_sample * channel2_factor + channel2_offset) *
+                                         channel2_scalefactor;
+                   if (channels == OutputChannels.BOTH_CHANNELS)
+                          filter2.input_sample (sample2, subbandnumber);
+                   else
+                          filter1.input_sample (sample2, subbandnumber);
+            }
+            return true;
+         }
+       };
+       
+}
diff --git a/Robust/src/Tests/ssJava/mp3decoder/LayerIIDecoder.java b/Robust/src/Tests/ssJava/mp3decoder/LayerIIDecoder.java
new file mode 100644 (file)
index 0000000..7265b1f
--- /dev/null
@@ -0,0 +1,1064 @@
+/*
+ * 11/19/04  1.0 moved to LGPL.
+ * 
+ * 29/05/01  Michael Scheerer,  Fixed some C++ to Java porting bugs. 
+ *
+ * 16/07/01  Michael Scheerer, Catched a bug in method
+ *           read_sampledata, which causes an outOfIndexException.
+ * 
+ * 12/12/99  Initial version. Adapted from javalayer.java
+ *                      and Subband*.java. mdm@techie.com
+ *
+ * 02/28/99  Initial version : javalayer.java by E.B
+ *-----------------------------------------------------------------------
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU Library General Public License as published
+ *   by the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU Library General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Library General Public
+ *   License along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *----------------------------------------------------------------------
+ */
+
+package javazoom.jl.decoder;
+
+/**
+ * Implements decoding of MPEG Audio Layer II frames. 
+ */
+class LayerIIDecoder extends LayerIDecoder implements FrameDecoder
+{
+
+       public LayerIIDecoder()
+       {
+       }
+
+       
+       protected void createSubbands()
+       {               
+               int i;
+               if (mode == Header.SINGLE_CHANNEL)
+                 for (i = 0; i < num_subbands; ++i)
+                   subbands[i] = new SubbandLayer2(i);
+               else if (mode == Header.JOINT_STEREO)
+               {
+                 for (i = 0; i < header.intensity_stereo_bound(); ++i)
+                     subbands[i] = new SubbandLayer2Stereo(i);
+                 for (; i < num_subbands; ++i)
+                     subbands[i] = new SubbandLayer2IntensityStereo(i);
+               }
+               else
+               {
+                 for (i = 0; i < num_subbands; ++i)
+                     subbands[i] = new SubbandLayer2Stereo(i);
+        }
+               
+       }
+       
+       protected void readScaleFactorSelection()
+       {
+               for (int i = 0; i < num_subbands; ++i)
+                 ((SubbandLayer2)subbands[i]).read_scalefactor_selection(stream, crc);         
+       }
+       
+       
+
+        /**
+         * Class for layer II subbands in single channel mode.
+         */
+       static class SubbandLayer2 extends Subband
+       {
+         // this table contains 3 requantized samples for each legal codeword
+         // when grouped in 5 bits, i.e. 3 quantizationsteps per sample
+       public static final float grouping_5bits[] = new float[]
+       {
+         -2.0f/3.0f, -2.0f/3.0f, -2.0f/3.0f,
+                        0.0f, -2.0f/3.0f, -2.0f/3.0f,
+               2.0f/3.0f, -2.0f/3.0f, -2.0f/3.0f,
+         -2.0f/3.0f,      0.0f, -2.0f/3.0f,
+                        0.0f,      0.0f, -2.0f/3.0f,
+               2.0f/3.0f,      0.0f, -2.0f/3.0f,
+         -2.0f/3.0f,  2.0f/3.0f, -2.0f/3.0f,
+                        0.0f,  2.0f/3.0f, -2.0f/3.0f,
+               2.0f/3.0f,  2.0f/3.0f, -2.0f/3.0f,
+         -2.0f/3.0f, -2.0f/3.0f,      0.0f,
+                        0.0f, -2.0f/3.0f,      0.0f,
+               2.0f/3.0f, -2.0f/3.0f,      0.0f,
+         -2.0f/3.0f,      0.0f,      0.0f,
+                        0.0f,      0.0f,      0.0f,
+               2.0f/3.0f,      0.0f,      0.0f,
+         -2.0f/3.0f,  2.0f/3.0f,      0.0f,
+                        0.0f,  2.0f/3.0f,      0.0f,
+               2.0f/3.0f,  2.0f/3.0f,      0.0f,
+         -2.0f/3.0f, -2.0f/3.0f,  2.0f/3.0f,
+              0.0f, -2.0f/3.0f,  2.0f/3.0f,
+               2.0f/3.0f, -2.0f/3.0f,  2.0f/3.0f,
+         -2.0f/3.0f,      0.0f,  2.0f/3.0f,
+              0.0f,      0.0f,  2.0f/3.0f,
+          2.0f/3.0f,      0.0f,  2.0f/3.0f,
+         -2.0f/3.0f,  2.0f/3.0f,  2.0f/3.0f,
+                        0.0f,  2.0f/3.0f,  2.0f/3.0f,
+          2.0f/3.0f,  2.0f/3.0f,  2.0f/3.0f
+       };
+
+       // this table contains 3 requantized samples for each legal codeword
+       // when grouped in 7 bits, i.e. 5 quantizationsteps per sample
+       public static final float grouping_7bits[] = new float[]
+       {
+         -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,
+         -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,
+         -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,
+         -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,
+         -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,
+         -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,
+         -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,
+         -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,
+         -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,
+         -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,
+         -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,
+         -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,
+         -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,
+         -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,
+         -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,
+         -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,
+         -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,
+         -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,
+         -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,
+         -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,
+         -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,
+         -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,
+         -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,
+         -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,
+         -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
+       };
+
+       // this table contains 3 requantized samples for each legal codeword
+       // when grouped in 10 bits, i.e. 9 quantizationsteps per sample
+       public static final float grouping_10bits[] =
+       {
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -8.0f/9.0f,      0.0f,      0.0f,   -6.0f/9.0f,      0.0f,      0.0f,   -4.0f/9.0f,      0.0f,      0.0f,
+         -2.0f/9.0f,      0.0f,      0.0f,        0.0f,      0.0f,      0.0f,    2.0f/9.0f,      0.0f,      0.0f,
+               4.0f/9.0f,      0.0f,      0.0f,    6.0f/9.0f,      0.0f,      0.0f,    8.0f/9.0f,      0.0f,      0.0f,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+          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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+          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,
+         -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,
+         -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,
+          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,
+         -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,
+         -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,
+          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,
+         -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,
+         -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,
+          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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+          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,
+         -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,
+         -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,
+          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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+          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,
+         -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,
+         -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,
+          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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+          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,
+         -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,
+         -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,
+          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,
+         -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,
+         -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,
+          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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+          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,
+         -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,
+         -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,
+          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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+          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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+          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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+          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,
+         -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,
+         -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,
+          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,
+         -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,
+         -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,
+          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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+               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,
+         -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,
+         -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,
+          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,
+         -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,
+         -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,
+          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
+       };
+
+       // data taken from ISO/IEC DIS 11172, Annexes 3-B.2[abcd] and 3-B.4:
+
+       // subbands 0-2 in tables 3-B.2a and 2b: (index is allocation)
+       public static final int table_ab1_codelength[] =
+         // bits per codeword
+       { 0, 5, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
+
+       public static final float table_ab1_groupingtables[][] =
+         // pointer to sample grouping table, or NULL-pointer if ungrouped
+       { null, grouping_5bits, null, null, null, null, null, null, null, null, null, null, null, null, null, null };
+
+       public static final float table_ab1_factor[] =
+         // factor for requantization: (real)sample * factor - 1.0 gives requantized sample
+       { 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,
+         1.0f/128.0f, 1.0f/256.0f, 1.0f/512.0f, 1.0f/1024.0f, 1.0f/2048.0f,
+         1.0f/4096.0f, 1.0f/8192.0f, 1.0f/16384.0f, 1.0f/32768.0f };
+
+       public static final float table_ab1_c[] =
+         // factor c for requantization from table 3-B.4
+       { 0.0f,           1.33333333333f, 1.14285714286f, 1.06666666666f, 1.03225806452f,
+         1.01587301587f, 1.00787401575f, 1.00392156863f, 1.00195694716f, 1.00097751711f,
+         1.00048851979f, 1.00024420024f, 1.00012208522f, 1.00006103888f, 1.00003051851f,
+         1.00001525902f };
+
+       public static final float table_ab1_d[] =
+         // addend d for requantization from table 3-B.4
+       { 0.0f,           0.50000000000f, 0.25000000000f, 0.12500000000f, 0.06250000000f,
+         0.03125000000f, 0.01562500000f, 0.00781250000f, 0.00390625000f, 0.00195312500f,
+         0.00097656250f, 0.00048828125f, 0.00024414063f, 0.00012207031f, 0.00006103516f,
+         0.00003051758f };
+
+       // subbands 3-... tables 3-B.2a and 2b:
+       public static final float[] table_ab234_groupingtables[] =
+       { null, grouping_5bits, grouping_7bits, null, grouping_10bits, null, null, null, null, null, null, null, null, null, null, null };
+
+       // subbands 3-10 in tables 3-B.2a and 2b:
+       public static final int table_ab2_codelength[] =
+       { 0, 5, 7, 3, 10, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16 };
+       public static final float table_ab2_factor[] =
+       { 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/32.0f, 1.0f/64.0f, 1.0f/128.0f, 1.0f/256.0f, 1.0f/512.0f,
+         1.0f/1024.0f, 1.0f/2048.0f, 1.0f/4096.0f, 1.0f/32768.0f };
+       public static final float table_ab2_c[] =
+       { 0.0f,           1.33333333333f, 1.60000000000f, 1.14285714286f, 1.77777777777f,
+         1.06666666666f, 1.03225806452f, 1.01587301587f, 1.00787401575f, 1.00392156863f,
+         1.00195694716f, 1.00097751711f, 1.00048851979f, 1.00024420024f, 1.00012208522f,
+         1.00001525902f };
+       public static final float table_ab2_d[] =
+       { 0.0f,           0.50000000000f, 0.50000000000f, 0.25000000000f, 0.50000000000f,
+         0.12500000000f, 0.06250000000f, 0.03125000000f, 0.01562500000f, 0.00781250000f,
+         0.00390625000f, 0.00195312500f, 0.00097656250f, 0.00048828125f, 0.00024414063f,
+         0.00003051758f };
+
+       // subbands 11-22 in tables 3-B.2a and 2b:
+       public static final int table_ab3_codelength[] = { 0, 5, 7, 3, 10, 4, 5, 16 };
+       public static final float table_ab3_factor[] =
+       { 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 };
+       public static final float table_ab3_c[] =
+       { 0.0f,           1.33333333333f, 1.60000000000f, 1.14285714286f, 1.77777777777f,
+         1.06666666666f, 1.03225806452f, 1.00001525902f };
+       public static final float table_ab3_d[] =
+       { 0.0f,           0.50000000000f, 0.50000000000f, 0.25000000000f, 0.50000000000f,
+         0.12500000000f, 0.06250000000f, 0.00003051758f };
+
+       // subbands 23-... in tables 3-B.2a and 2b:
+       public static final int table_ab4_codelength[] = { 0, 5, 7, 16 };
+       public static final float table_ab4_factor[] = { 0.0f, 1.0f/2.0f, 1.0f/4.0f, 1.0f/32768.0f };
+       public static final float table_ab4_c[] = { 0.0f, 1.33333333333f, 1.60000000000f, 1.00001525902f };
+       public static final float table_ab4_d[] = { 0.0f, 0.50000000000f, 0.50000000000f, 0.00003051758f };
+
+       // subbands in tables 3-B.2c and 2d:
+       public static final int table_cd_codelength[] =
+       { 0, 5, 7, 10, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
+       public static final float table_cd_groupingtables[][] =
+       { null, grouping_5bits, grouping_7bits, grouping_10bits, null, null, null, null, null, null, null, null, null, null, null, null };
+       public static final float table_cd_factor[] =
+       { 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,
+         1.0f/128.0f, 1.0f/256.0f, 1.0f/512.0f, 1.0f/1024.0f, 1.0f/2048.0f, 1.0f/4096.0f,
+         1.0f/8192.0f, 1.0f/16384.0f };
+       public static final float table_cd_c[] =
+       { 0.0f,           1.33333333333f, 1.60000000000f, 1.77777777777f, 1.06666666666f,
+         1.03225806452f, 1.01587301587f, 1.00787401575f, 1.00392156863f, 1.00195694716f,
+         1.00097751711f, 1.00048851979f, 1.00024420024f, 1.00012208522f, 1.00006103888f,
+         1.00003051851f };
+       public static final float table_cd_d[] =
+       { 0.0f,           0.50000000000f, 0.50000000000f, 0.50000000000f, 0.12500000000f,
+         0.06250000000f, 0.03125000000f, 0.01562500000f, 0.00781250000f, 0.00390625000f,
+         0.00195312500f, 0.00097656250f, 0.00048828125f, 0.00024414063f, 0.00012207031f,
+         0.00006103516f };
+
+
+
+         protected int                     subbandnumber;
+         protected int                         allocation;
+         protected int                         scfsi;
+         protected float                       scalefactor1, scalefactor2, scalefactor3;
+         protected int[]                       codelength = {0}; 
+         protected float groupingtable[][] = new float[2][]; 
+         //protected float[][]                 groupingtable = {{0},{0}} ;
+         protected float[]                     factor = {0.0f};
+         protected int                         groupnumber;
+         protected int                         samplenumber;
+         protected float[]                     samples = new float[3];
+         protected float[]                     c = {0};
+         protected float[]                 d = {0};
+         /**
+          * Constructor
+          */
+         public SubbandLayer2(int subbandnumber)
+         {     
+               this.subbandnumber = subbandnumber;
+           groupnumber = samplenumber = 0;  
+         }
+         
+         
+         /**
+          *
+          */
+         protected int get_allocationlength (Header header)
+         {
+               if (header.version() == Header.MPEG1)
+               {
+                 int channel_bitrate = header.bitrate_index();
+
+                 // calculate bitrate per channel:
+                 if (header.mode() != Header.SINGLE_CHANNEL)
+                        if (channel_bitrate == 4)
+                               channel_bitrate = 1;
+                        else
+                               channel_bitrate -= 4;
+
+                 if (channel_bitrate == 1 || channel_bitrate == 2)
+                        // table 3-B.2c or 3-B.2d
+                        if (subbandnumber <= 1)
+                               return 4;
+                        else
+                               return 3;
+                 else
+                        // tables 3-B.2a or 3-B.2b
+                        if (subbandnumber <= 10)
+                               return 4;
+                        else if (subbandnumber <= 22)
+                               return 3;
+                        else
+                               return 2;
+           }
+               else
+               { // MPEG-2 LSF -- Jeff
+
+                // table B.1 of ISO/IEC 13818-3
+            if (subbandnumber <= 3)
+                       return 4;
+            else if (subbandnumber <= 10)
+                       return 3;
+            else
+                       return 2;
+           }
+         }
+         
+         /**
+          *
+          */
+          protected void prepare_sample_reading(Header header, int allocation,
+                                                                                        //float[][] groupingtable,
+                                                                                          int channel,
+                                                float[] factor, int[] codelength,
+                                                float[] c, float[] d)
+          {
+                       int channel_bitrate = header.bitrate_index();
+                       // calculate bitrate per channel:
+                       if (header.mode() != Header.SINGLE_CHANNEL)
+                               if (channel_bitrate == 4)
+                                       channel_bitrate = 1;
+                               else
+                                       channel_bitrate -= 4;
+                       
+                        if (channel_bitrate == 1 || channel_bitrate == 2)
+                        {
+                                // table 3-B.2c or 3-B.2d
+                                groupingtable[channel] = table_cd_groupingtables[allocation];
+                                factor[0] = table_cd_factor[allocation];
+                                codelength[0] = table_cd_codelength[allocation];
+                                c[0] = table_cd_c[allocation];
+                                d[0] = table_cd_d[allocation];
+                        }
+                        else
+                        {
+                                // tables 3-B.2a or 3-B.2b
+                                if (subbandnumber <= 2)
+                                {
+                                       groupingtable[channel] = table_ab1_groupingtables[allocation];
+                                       factor[0] = table_ab1_factor[allocation];
+                                       codelength[0] = table_ab1_codelength[allocation];
+                               c[0] = table_ab1_c[allocation];
+                               d[0] = table_ab1_d[allocation];
+                            }
+                                else
+                                {
+                               groupingtable[channel] = table_ab234_groupingtables[allocation];
+                                       if (subbandnumber <= 10)
+                                       {
+                                               factor[0] = table_ab2_factor[allocation];
+                                               codelength[0] = table_ab2_codelength[allocation];
+                                               c[0] = table_ab2_c[allocation];
+                                               d[0] = table_ab2_d[allocation];
+                               }
+                               else if (subbandnumber <= 22)
+                               {
+                                               factor[0] = table_ab3_factor[allocation];
+                                               codelength[0] = table_ab3_codelength[allocation];
+                                               c[0] = table_ab3_c[allocation];
+                                               d[0] = table_ab3_d[allocation];
+                               }
+                                       else
+                               {
+                                               factor[0] = table_ab4_factor[allocation];
+                                               codelength[0] = table_ab4_codelength[allocation];
+                                               c[0] = table_ab4_c[allocation];
+                                               d[0] = table_ab4_d[allocation];
+                               }
+                                }
+                        }   
+          }
+                                        
+         
+         /**
+          *
+          */
+         public void read_allocation(Bitstream stream, Header header, Crc16 crc)
+         {
+                int length = get_allocationlength(header);
+                allocation = stream.get_bits(length);
+                if (crc != null) 
+                        crc.add_bits(allocation, length);  
+         }
+         
+         /**
+          *
+          */
+         public void read_scalefactor_selection (Bitstream stream, Crc16 crc)
+         {
+               if (allocation != 0)
+               {
+               scfsi = stream.get_bits(2);
+               if (crc != null) crc.add_bits(scfsi, 2);
+           }
+         }
+
+         /**
+          *
+          */
+         public void read_scalefactor (Bitstream stream, Header header)
+         {
+               if (allocation != 0)
+               {
+                  switch (scfsi)
+              {
+               case 0:
+                        scalefactor1 = scalefactors[stream.get_bits(6)];
+                        scalefactor2 = scalefactors[stream.get_bits(6)];
+                        scalefactor3 = scalefactors[stream.get_bits(6)];
+                        break;
+                       case 1:
+                        scalefactor1 = scalefactor2 = scalefactors[stream.get_bits(6)];
+                        scalefactor3 = scalefactors[stream.get_bits(6)];
+                        break;
+               case 2:
+                        scalefactor1 = scalefactor2 = scalefactor3 = scalefactors[stream.get_bits(6)];
+                        break;
+                   case 3:
+                        scalefactor1 = scalefactors[stream.get_bits(6)];
+                    scalefactor2 = scalefactor3 = scalefactors[stream.get_bits(6)];
+                    break;
+               }
+               prepare_sample_reading(header, allocation, 0,
+                                   factor, codelength, c, d);
+         }
+         }
+         
+         /**
+          *
+          */
+         public boolean read_sampledata (Bitstream stream)
+         {
+               if (allocation != 0)
+                if (groupingtable[0] != null)
+                {
+                       int samplecode = stream.get_bits(codelength[0]);
+                       // create requantized samples:
+                       samplecode += samplecode << 1;
+                       float[] target = samples;
+                       float[] source = groupingtable[0];
+                 /*
+                 int tmp = 0;
+                       int temp = 0;
+                       target[tmp++] = source[samplecode + temp];
+                       temp++;
+                       target[tmp++] = source[samplecode + temp];
+                       temp++;
+                       target[tmp] = source[samplecode + temp];
+                       */
+                       //Bugfix:
+                       int tmp = 0;
+                       int temp = samplecode;
+                       
+                       if(temp > source.length - 3) temp = source.length - 3;
+                       
+                       target[tmp] = source[temp];
+                       temp++;tmp++;
+                       target[tmp] = source[temp];
+                       temp++;tmp++;
+                       target[tmp] = source[temp];
+                       
+                       // memcpy (samples, groupingtable + samplecode, 3 * sizeof (real));
+                }
+                else
+                {
+                       samples[0] = (float) ((stream.get_bits(codelength[0])) * factor[0] - 1.0);
+                       samples[1] = (float) ((stream.get_bits(codelength[0])) * factor[0] - 1.0);
+                       samples[2] = (float) ((stream.get_bits(codelength[0])) * factor[0] - 1.0);
+                }
+
+               samplenumber = 0;
+                 if (++groupnumber == 12)
+                        return true;
+                 else
+                        return false;
+         }
+
+         /**
+          *
+          */
+         public boolean put_next_sample(int channels, SynthesisFilter filter1, SynthesisFilter filter2)
+         {
+           if ((allocation != 0) && (channels != OutputChannels.RIGHT_CHANNEL))
+           {
+                float sample = samples[samplenumber];
+         
+                if (groupingtable[0] == null)
+                       sample = (sample + d[0]) * c[0];
+                if (groupnumber <= 4)
+                       sample *= scalefactor1;
+                else if (groupnumber <= 8)
+                       sample *= scalefactor2;
+                else
+                       sample *= scalefactor3;
+                filter1.input_sample(sample, subbandnumber);
+           }
+         
+           if (++samplenumber == 3)
+                return true;
+           else
+                return false;
+         }
+       };
+       
+        /**
+         * Class for layer II subbands in joint stereo mode.
+         */
+       static class SubbandLayer2IntensityStereo extends SubbandLayer2
+       {
+         protected int          channel2_scfsi;
+         protected float        channel2_scalefactor1, channel2_scalefactor2, channel2_scalefactor3;
+
+         /**
+          * Constructor
+          */
+         public SubbandLayer2IntensityStereo (int subbandnumber)
+         {
+               super(subbandnumber);
+         }
+
+         /**
+          *
+          */
+         public void read_allocation(Bitstream stream, Header header, Crc16 crc)
+         {
+           super.read_allocation (stream, header, crc);
+         }
+         
+         /**
+          *
+          */
+         public void read_scalefactor_selection(Bitstream stream, Crc16 crc)
+         {
+           if (allocation != 0)
+           {
+                scfsi = stream.get_bits(2);
+                channel2_scfsi = stream.get_bits(2);
+                if (crc != null)
+                {
+                       crc.add_bits(scfsi, 2);
+                       crc.add_bits(channel2_scfsi, 2);
+                }
+           }  
+         }
+         
+         /**
+          *
+          */
+         public void read_scalefactor(Bitstream stream, Header header)
+         {
+           if (allocation != 0)
+           {
+                super.read_scalefactor(stream, header);
+                switch (channel2_scfsi)
+                {
+                       case 0:
+                       channel2_scalefactor1 = scalefactors[stream.get_bits(6)];
+                       channel2_scalefactor2 = scalefactors[stream.get_bits(6)];
+                       channel2_scalefactor3 = scalefactors[stream.get_bits(6)];
+                       break;
+         
+                       case 1:
+                       channel2_scalefactor1 = channel2_scalefactor2 = scalefactors[stream.get_bits (6)];
+                       channel2_scalefactor3 = scalefactors[stream.get_bits(6)];
+                       break;
+         
+                       case 2:
+                       channel2_scalefactor1 = channel2_scalefactor2 =
+                       channel2_scalefactor3 = scalefactors[stream.get_bits(6)];
+                       break;
+         
+                       case 3:
+                       channel2_scalefactor1 = scalefactors[stream.get_bits(6)];
+                       channel2_scalefactor2 = channel2_scalefactor3 = scalefactors[stream.get_bits (6)];
+                       break;
+                }
+           }
+         
+         }
+         
+         /**
+          *
+          */
+         public boolean read_sampledata(Bitstream stream)
+         {
+                return super.read_sampledata (stream);
+         }
+         
+         /**
+          *
+          */
+         public boolean put_next_sample(int channels, SynthesisFilter filter1, SynthesisFilter filter2)
+         {
+                 if (allocation != 0)
+                 {
+                        float sample = samples[samplenumber];
+               
+                        if (groupingtable[0] == null)
+                               sample = (sample + d[0]) * c[0];
+                      if (channels == OutputChannels.BOTH_CHANNELS)
+                          {
+                                 float sample2 = sample;
+                             if (groupnumber <= 4)
+                             {
+                                       sample *= scalefactor1;
+                                       sample2 *= channel2_scalefactor1;
+                                 }
+                                 else if (groupnumber <= 8)
+                                 {
+                                       sample *= scalefactor2;
+                                       sample2 *= channel2_scalefactor2;
+                                 }
+                                 else
+                                 {
+                                       sample *= scalefactor3;
+                                       sample2 *= channel2_scalefactor3;
+                                 }
+                                 filter1.input_sample(sample, subbandnumber);
+                             filter2.input_sample(sample2, subbandnumber);
+                           }
+                               else if (channels == OutputChannels.LEFT_CHANNEL)
+                               {
+                                       if (groupnumber <= 4)
+                                               sample *= scalefactor1;
+                               else if (groupnumber <= 8)
+                                               sample *= scalefactor2;
+                                       else
+                                               sample *= scalefactor3;
+                                       filter1.input_sample(sample, subbandnumber);
+                                }
+                                else
+                                {
+                                       if (groupnumber <= 4)
+                                       sample *= channel2_scalefactor1;
+                                       else if (groupnumber <= 8)
+                                               sample *= channel2_scalefactor2;
+                                       else
+                                               sample *= channel2_scalefactor3;
+                                       filter1.input_sample(sample, subbandnumber);
+                               }
+                       }
+               
+                 if (++samplenumber == 3)
+                        return true;
+                 else
+                return false;
+         }
+       };
+
+        /**
+         * Class for layer II subbands in stereo mode.
+         */
+       static class SubbandLayer2Stereo extends SubbandLayer2
+       {
+         protected int                 channel2_allocation;
+         protected int                 channel2_scfsi;
+         protected float               channel2_scalefactor1, channel2_scalefactor2, channel2_scalefactor3;
+         //protected boolean           channel2_grouping;  ???? Never used!
+         protected int[]               channel2_codelength = {0};
+         //protected float[][]         channel2_groupingtable = {{0},{0}};
+         protected float[]             channel2_factor = {0};
+         protected float[]     channel2_samples;
+         protected float[]             channel2_c = {0};
+         protected float[]             channel2_d = {0};
+         
+         /**
+          * Constructor
+          */
+         public SubbandLayer2Stereo(int subbandnumber)
+         {
+               super(subbandnumber);
+               channel2_samples = new float[3];
+         }
+         
+         /**
+          *
+          */
+         public void read_allocation (Bitstream stream, Header header, Crc16 crc)
+         {
+           int length = get_allocationlength(header);
+           allocation = stream.get_bits(length);
+           channel2_allocation = stream.get_bits(length);
+           if (crc != null)
+           {
+                crc.add_bits(allocation, length);
+                crc.add_bits(channel2_allocation, length);
+           }
+         }
+
+         /**
+          *
+          */
+         public void read_scalefactor_selection(Bitstream stream, Crc16 crc)
+         {
+                 if (allocation != 0)
+                 {
+                        scfsi = stream.get_bits(2);
+                        if (crc != null)
+                               crc.add_bits(scfsi, 2);
+                 }
+                 if (channel2_allocation != 0)
+                 {
+                        channel2_scfsi = stream.get_bits(2);
+                        if (crc != null)
+                               crc.add_bits(channel2_scfsi, 2);
+                 }
+         }
+
+         /**
+          *
+          */
+         public void read_scalefactor(Bitstream stream, Header header)
+         {
+           super.read_scalefactor(stream, header);
+           if (channel2_allocation != 0)
+           {
+                switch (channel2_scfsi)
+                {
+                       case 0:
+                  channel2_scalefactor1 = scalefactors[stream.get_bits(6)];
+                          channel2_scalefactor2 = scalefactors[stream.get_bits(6)];
+                      channel2_scalefactor3 = scalefactors[stream.get_bits(6)];
+                      break;
+         
+                       case 1:
+                          channel2_scalefactor1 = channel2_scalefactor2 =
+                                                                     scalefactors[stream.get_bits(6)];
+                      channel2_scalefactor3 = scalefactors[stream.get_bits(6)];
+                      break;
+         
+                       case 2:
+                          channel2_scalefactor1 = channel2_scalefactor2 =
+                      channel2_scalefactor3 = scalefactors[stream.get_bits(6)];
+                      break;
+         
+                       case 3:
+                          channel2_scalefactor1 = scalefactors[stream.get_bits(6)];
+                      channel2_scalefactor2 = channel2_scalefactor3 =
+                                                                          scalefactors[stream.get_bits(6)];
+                  break;
+                }
+                prepare_sample_reading(header, channel2_allocation, 1,
+                                    channel2_factor, channel2_codelength, channel2_c,
+                                    channel2_d);
+          }
+         }
+
+         /**
+          *
+          */
+         public boolean read_sampledata (Bitstream stream)
+         {
+           boolean returnvalue = super.read_sampledata(stream);
+         
+           if (channel2_allocation != 0)
+                if (groupingtable[1] != null)
+                {
+                       int samplecode = stream.get_bits(channel2_codelength[0]);
+                       // create requantized samples:
+                       samplecode += samplecode << 1;
+               /*
+                       float[] target = channel2_samples;
+                       float[] source = channel2_groupingtable[0];
+                       int tmp = 0;
+                       int temp = 0;
+                       target[tmp++] = source[samplecode + temp];
+                       temp++;
+                       target[tmp++] = source[samplecode + temp];
+                       temp++;
+                       target[tmp] = source[samplecode + temp];
+                       // memcpy (channel2_samples, channel2_groupingtable + samplecode, 3 * sizeof (real));
+               */
+               float[] target = channel2_samples;
+           float[] source = groupingtable[1];
+                       int tmp = 0;
+                       int temp = samplecode;
+               target[tmp] = source[temp];
+                       temp++;tmp++;
+               target[tmp] = source[temp];
+                       temp++;tmp++;
+               target[tmp] = source[temp];
+               
+             } 
+                 else 
+                 {
+                       channel2_samples[0] = (float) ((stream.get_bits(channel2_codelength[0])) *
+                                                                        channel2_factor[0] - 1.0);
+                       channel2_samples[1] = (float) ((stream.get_bits(channel2_codelength[0])) *
+                                                                        channel2_factor[0] - 1.0);
+                       channel2_samples[2] = (float) ((stream.get_bits(channel2_codelength[0])) *
+                                     channel2_factor[0] - 1.0);
+                }
+            return returnvalue;
+         }
+
+         /**
+          *
+          */
+         public boolean put_next_sample(int channels, SynthesisFilter filter1, SynthesisFilter filter2)
+         {
+           boolean returnvalue = super.put_next_sample(channels, filter1, filter2);
+           if ((channel2_allocation != 0) && (channels != OutputChannels.LEFT_CHANNEL))
+           {
+                float sample = channel2_samples[samplenumber - 1];
+         
+                if (groupingtable[1] == null)
+                       sample = (sample + channel2_d[0]) * channel2_c[0];
+         
+                if (groupnumber <= 4)
+                       sample *= channel2_scalefactor1;
+                else if (groupnumber <= 8)
+                       sample *= channel2_scalefactor2;
+                else
+                       sample *= channel2_scalefactor3;
+                if (channels == OutputChannels.BOTH_CHANNELS)
+                       filter2.input_sample(sample, subbandnumber);
+                else
+                       filter1.input_sample(sample, subbandnumber);
+           }
+               return returnvalue;
+         }
+       }
+}
diff --git a/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java b/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java
new file mode 100644 (file)
index 0000000..9e66a93
--- /dev/null
@@ -0,0 +1,2454 @@
+/*\r
+ * 11/19/04     1.0 moved to LGPL.\r
+ * \r
+ * 18/06/01  Michael Scheerer,  Fixed bugs which causes\r
+ *           negative indexes in method huffmann_decode and in method \r
+ *           dequanisize_sample.\r
+ *\r
+ * 16/07/01  Michael Scheerer, Catched a bug in method\r
+ *           huffmann_decode, which causes an outOfIndexException.\r
+ *           Cause : Indexnumber of 24 at SfBandIndex,\r
+ *           which has only a length of 22. I have simply and dirty \r
+ *           fixed the index to <= 22, because I'm not really be able\r
+ *           to fix the bug. The Indexnumber is taken from the MP3 \r
+ *           file and the origin Ma-Player with the same code works \r
+ *           well.      \r
+ * \r
+ * 02/19/99  Java Conversion by E.B, javalayer@javazoom.net\r
+ *-----------------------------------------------------------------------\r
+ *   This program is free software; you can redistribute it and/or modify\r
+ *   it under the terms of the GNU Library General Public License as published\r
+ *   by the Free Software Foundation; either version 2 of the License, or\r
+ *   (at your option) any later version.\r
+ *\r
+ *   This program is distributed in the hope that it will be useful,\r
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *   GNU Library General Public License for more details.\r
+ *\r
+ *   You should have received a copy of the GNU Library General Public\r
+ *   License along with this program; if not, write to the Free Software\r
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ *----------------------------------------------------------------------\r
+ */\r
+\r
+package javazoom.jl.decoder;\r
+\r
+/**\r
+ * Class Implementing Layer 3 Decoder.\r
+ * \r
+ * @since 0.0\r
+ */\r
+final class LayerIIIDecoder implements FrameDecoder {\r
+  final double d43 = (4.0 / 3.0);\r
+\r
+  public int[] scalefac_buffer;\r
+\r
+  // MDM: removed, as this wasn't being used.\r
+  // private float CheckSumOut1d = 0.0f;\r
+  private int CheckSumHuff = 0;\r
+  private int[] is_1d;\r
+  private float[][][] ro;\r
+  private float[][][] lr;\r
+  private float[] out_1d;\r
+  private float[][] prevblck;\r
+  private float[][] k;\r
+  private int[] nonzero;\r
+  private Bitstream stream;\r
+  @HEADER private Header header;\r
+  private SynthesisFilter filter1, filter2;\r
+  private Obuffer buffer;\r
+  private int which_channels;\r
+  private BitReserve br;\r
+  private III_side_info_t si;\r
+\r
+  private temporaire2[] III_scalefac_t;\r
+  private temporaire2[] scalefac;\r
+  // private III_scalefac_t scalefac;\r
+\r
+  private int max_gr;\r
+  private int frame_start;\r
+  private int part2_start;\r
+  private int channels;\r
+  private int first_channel;\r
+  private int last_channel;\r
+  private int sfreq;\r
+\r
+  /**\r
+   * Constructor.\r
+   */\r
+  // REVIEW: these constructor arguments should be moved to the\r
+  // decodeFrame() method, where possible, so that one\r
+  public LayerIIIDecoder(Bitstream stream0, Header header0, SynthesisFilter filtera,\r
+      SynthesisFilter filterb, Obuffer buffer0, int which_ch0) {\r
+    huffcodetab.inithuff();\r
+    is_1d = new int[SBLIMIT * SSLIMIT + 4];\r
+    ro = new float[2][SBLIMIT][SSLIMIT];\r
+    lr = new float[2][SBLIMIT][SSLIMIT];\r
+    out_1d = new float[SBLIMIT * SSLIMIT];\r
+    prevblck = new float[2][SBLIMIT * SSLIMIT];\r
+    k = new float[2][SBLIMIT * SSLIMIT];\r
+    nonzero = new int[2];\r
+\r
+    // III_scalefact_t\r
+    III_scalefac_t = new temporaire2[2];\r
+    III_scalefac_t[0] = new temporaire2();\r
+    III_scalefac_t[1] = new temporaire2();\r
+    scalefac = III_scalefac_t;\r
+    // L3TABLE INIT\r
+\r
+    sfBandIndex = new SBI[9]; // SZD: MPEG2.5 +3 indices\r
+    int[] l0 =\r
+        { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396,\r
+            464, 522, 576 };\r
+    int[] s0 = { 0, 4, 8, 12, 18, 24, 32, 42, 56, 74, 100, 132, 174, 192 };\r
+    int[] l1 =\r
+        { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 114, 136, 162, 194, 232, 278, 330, 394,\r
+            464, 540, 576 };\r
+    int[] s1 = { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 136, 180, 192 };\r
+    int[] l2 =\r
+        { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396,\r
+            464, 522, 576 };\r
+    int[] s2 = { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192 };\r
+\r
+    int[] l3 =\r
+        { 0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 52, 62, 74, 90, 110, 134, 162, 196, 238, 288, 342,\r
+            418, 576 };\r
+    int[] s3 = { 0, 4, 8, 12, 16, 22, 30, 40, 52, 66, 84, 106, 136, 192 };\r
+    int[] l4 =\r
+        { 0, 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 60, 72, 88, 106, 128, 156, 190, 230, 276, 330,\r
+            384, 576 };\r
+    int[] s4 = { 0, 4, 8, 12, 16, 22, 28, 38, 50, 64, 80, 100, 126, 192 };\r
+    int[] l5 =\r
+        { 0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 54, 66, 82, 102, 126, 156, 194, 240, 296, 364, 448,\r
+            550, 576 };\r
+    int[] s5 = { 0, 4, 8, 12, 16, 22, 30, 42, 58, 78, 104, 138, 180, 192 };\r
+    // SZD: MPEG2.5\r
+    int[] l6 =\r
+        { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396,\r
+            464, 522, 576 };\r
+    int[] s6 = { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192 };\r
+    int[] l7 =\r
+        { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396,\r
+            464, 522, 576 };\r
+    int[] s7 = { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192 };\r
+    int[] l8 =\r
+        { 0, 12, 24, 36, 48, 60, 72, 88, 108, 132, 160, 192, 232, 280, 336, 400, 476, 566, 568,\r
+            570, 572, 574, 576 };\r
+    int[] s8 = { 0, 8, 16, 24, 36, 52, 72, 96, 124, 160, 162, 164, 166, 192 };\r
+\r
+    sfBandIndex[0] = new SBI(l0, s0);\r
+    sfBandIndex[1] = new SBI(l1, s1);\r
+    sfBandIndex[2] = new SBI(l2, s2);\r
+\r
+    sfBandIndex[3] = new SBI(l3, s3);\r
+    sfBandIndex[4] = new SBI(l4, s4);\r
+    sfBandIndex[5] = new SBI(l5, s5);\r
+    // SZD: MPEG2.5\r
+    sfBandIndex[6] = new SBI(l6, s6);\r
+    sfBandIndex[7] = new SBI(l7, s7);\r
+    sfBandIndex[8] = new SBI(l8, s8);\r
+    // END OF L3TABLE INIT\r
+\r
+    if (reorder_table == null) { // SZD: generate LUT\r
+      reorder_table = new int[9][];\r
+      for (int i = 0; i < 9; i++)\r
+        reorder_table[i] = reorder(sfBandIndex[i].s);\r
+    }\r
+\r
+    // Sftable\r
+    int[] ll0 = { 0, 6, 11, 16, 21 };\r
+    int[] ss0 = { 0, 6, 12 };\r
+    sftable = new Sftable(ll0, ss0);\r
+    // END OF Sftable\r
+\r
+    // scalefac_buffer\r
+    scalefac_buffer = new int[54];\r
+    // END OF scalefac_buffer\r
+\r
+    stream = stream0;\r
+    header = header0;\r
+    filter1 = filtera;\r
+    filter2 = filterb;\r
+    buffer = buffer0;\r
+    which_channels = which_ch0;\r
+\r
+    frame_start = 0;\r
+    channels = (header.mode() == Header.SINGLE_CHANNEL) ? 1 : 2;\r
+    max_gr = (header.version() == Header.MPEG1) ? 2 : 1;\r
+\r
+    sfreq =\r
+        header.sample_frequency()\r
+            + ((header.version() == Header.MPEG1) ? 3 : (header.version() == Header.MPEG25_LSF) ? 6\r
+                : 0); // SZD\r
+\r
+    if (channels == 2) {\r
+      switch (which_channels) {\r
+      case OutputChannels.LEFT_CHANNEL:\r
+      case OutputChannels.DOWNMIX_CHANNELS:\r
+        first_channel = last_channel = 0;\r
+        break;\r
+\r
+      case OutputChannels.RIGHT_CHANNEL:\r
+        first_channel = last_channel = 1;\r
+        break;\r
+\r
+      case OutputChannels.BOTH_CHANNELS:\r
+      default:\r
+        first_channel = 0;\r
+        last_channel = 1;\r
+        break;\r
+      }\r
+    } else {\r
+      first_channel = last_channel = 0;\r
+    }\r
+\r
+    for (int ch = 0; ch < 2; ch++)\r
+      for (int j = 0; j < 576; j++)\r
+        prevblck[ch][j] = 0.0f;\r
+\r
+    nonzero[0] = nonzero[1] = 576;\r
+\r
+    br = new BitReserve();\r
+    si = new III_side_info_t();\r
+  }\r
+\r
+  /**\r
+   * Notify decoder that a seek is being made.\r
+   */\r
+  public void seek_notify() {\r
+    frame_start = 0;\r
+    for (int ch = 0; ch < 2; ch++)\r
+      for (int j = 0; j < 576; j++)\r
+        prevblck[ch][j] = 0.0f;\r
+    br = new BitReserve();\r
+  }\r
+\r
+  public void decodeFrame() {\r
+    decode();\r
+  }\r
+\r
+  /**\r
+   * Decode one frame, filling the buffer with the output samples.\r
+   */\r
+\r
+  // subband samples are buffered and passed to the\r
+  // SynthesisFilter in one go.\r
+  private float[] samples1 = new float[32];\r
+  private float[] samples2 = new float[32];\r
+\r
+  /* location hierarchy of decode()\r
+{header} {stream} {si}\r
+{br, flush_main, main_data_end,frame_start,nSlots,bytes_to_discard}* \r
+{gr,max_gr} // granule\r
+{ch,channels,first_channel, last_channel, which_channels} // channel\r
+{part2_start} \r
+{sb18, ss}\r
+{out_1d}*\r
+{sb}*\r
+{samples1,sample2} {filter1,filter2}\r
+   */\r
+  public void decode() {\r
+    int nSlots = header.slots();\r
+    int flush_main;\r
+    int gr, ch, ss, sb, sb18;\r
+    int main_data_end;\r
+    int bytes_to_discard;\r
+    int i;\r
+\r
+    get_side_info();\r
+\r
+    for (i = 0; i < nSlots; i++)\r
+      br.hputbuf(stream.get_bits(8)); // br < stream\r
+\r
+    // br < main_data_end\r
+    main_data_end = br.hsstell() >>> 3; // of previous frame  \r
+     \r
+\r
+    if ((flush_main = (br.hsstell() & 7)) != 0) { // flush_main < br\r
+      br.hgetbits(8 - flush_main); // br < flush_main\r
+      main_data_end++;  // main_data_end*\r
+    }\r
+\r
+    // bytes_to_discard < GLB(frame_start,main_data_end,si)\r
+    // TODO does bytes_to_discard need to go back to si??? \r
+    bytes_to_discard = frame_start - main_data_end - si.main_data_begin;\r
+\r
+    // frame_start should be *\r
+    frame_start += nSlots;\r
+\r
+    if (bytes_to_discard < 0)\r
+      return;\r
+\r
+    if (main_data_end > 4096) { // main_data_end should be > than 'frame_start' and 'br'\r
+      frame_start -= 4096;\r
+      br.rewindNbytes(4096);\r
+    }\r
+\r
+    for (; bytes_to_discard > 0; bytes_to_discard--) // bytes_to_discard > br\r
+      br.hgetbits(8);\r
+    \r
+    // here 'gr' and 'max_gr' should be higher than 'ch','channels', and more\r
+    for (gr = 0; gr < max_gr; gr++) { \r
+      // in the loop body, access set={part2_start}      \r
+      \r
+      // 'ch', 'channels' should be higher than all locs in the below body\r
+      for (ch = 0; ch < channels; ch++) { \r
+        part2_start = br.hsstell(); // part2_start < br\r
+\r
+        if (header.version() == Header.MPEG1)\r
+          get_scale_factors(ch, gr); // no need to care from this side\r
+        else\r
+          // MPEG-2 LSF, SZD: MPEG-2.5 LSF\r
+          get_LSF_scale_factors(ch, gr); // no need to care from this side\r
+\r
+        huffman_decode(ch, gr); // no need to care from this side\r
+        // System.out.println("CheckSum HuffMan = " + CheckSumHuff);\r
+        dequantize_sample(ro[ch], ch, gr); // no need to care from this side\r
+      }\r
+\r
+      stereo(gr); // no need to care from this side\r
+\r
+      if ((which_channels == OutputChannels.DOWNMIX_CHANNELS) && (channels > 1))\r
+        do_downmix();\r
+\r
+      for (ch = first_channel; ch <= last_channel; ch++) { // 'ch' and 'first_channel' > the body\r
+\r
+        // in the body\r
+        // read set= lr,ch,gr,out_1d, sb18, ss, SSLIMIT, out_1d\r
+        // write set= out_1d\r
+        \r
+        reorder(lr[ch], ch, gr); \r
+        antialias(ch, gr);\r
+        // for (int hb = 0;hb<576;hb++) CheckSumOut1d = CheckSumOut1d +\r
+        // out_1d[hb];\r
+        // System.out.println("CheckSumOut1d = "+CheckSumOut1d);\r
+\r
+        hybrid(ch, gr);\r
+\r
+        // for (int hb = 0;hb<576;hb++) CheckSumOut1d = CheckSumOut1d +\r
+        // out_1d[hb];\r
+        // System.out.println("CheckSumOut1d = "+CheckSumOut1d);\r
+\r
+        for (sb18 = 18; sb18 < 576; sb18 += 36) // sb18 > ss, SSLIMIT, out1d\r
+          // Frequency inversion\r
+          for (ss = 1; ss < SSLIMIT; ss += 2) // 'ss','SSLIMIT' > out_1d\r
+            out_1d[sb18 + ss] = -out_1d[sb18 + ss]; // out1d*\r
+\r
+        // 'ch', 'which_channels' should be higher than if/else body!\r
+        // location set written by if/else body \r
+        // = {samples1, samples2, filter1, filter2}    \r
+        if ((ch == 0) || (which_channels == OutputChannels.RIGHT_CHANNEL)) {\r
+          for (ss = 0; ss < SSLIMIT; ss++) { // Polyphase synthesis\r
+            sb = 0;\r
+            for (sb18 = 0; sb18 < 576; sb18 += 18) {\r
+              samples1[sb] = out_1d[sb18 + ss]; // out_1d > samples1\r
+              // filter1.input_sample(out_1d[sb18+ss], sb);\r
+              sb++; // sb should be loc*\r
+            }\r
+            filter1.input_samples(samples1);\r
+            filter1.calculate_pcm_samples(buffer);\r
+          }\r
+        } else {\r
+          for (ss = 0; ss < SSLIMIT; ss++) { // Polyphase synthesis\r
+            sb = 0;\r
+            for (sb18 = 0; sb18 < 576; sb18 += 18) {\r
+              samples2[sb] = out_1d[sb18 + ss]; // out_1d > samples2\r
+              // filter2.input_sample(out_1d[sb18+ss], sb);\r
+              sb++;\r
+            }\r
+            filter2.input_samples(samples2);\r
+            filter2.calculate_pcm_samples(buffer);\r
+          }\r
+\r
+        }\r
+      } // channels\r
+    } // granule\r
+\r
+    // System.out.println("Counter = ................................."+counter);\r
+    // if (counter < 609)\r
+    // {\r
+    counter++; // count should be loc*\r
+    buffer.write_buffer(1); // buffer!!!\r
+    // }\r
+    // else if (counter == 609)\r
+    // {\r
+    // buffer.close();\r
+    // counter++;\r
+    // }\r
+    // else\r
+    // {\r
+    // }\r
+\r
+  }\r
+\r
+  /**\r
+   * Reads the side info from the stream, assuming the entire. frame has been\r
+   * read already. Mono : 136 bits (= 17 bytes) Stereo : 256 bits (= 32 bytes)\r
+   */\r
+  private boolean get_side_info() {\r
+    int ch, gr;\r
+    if (header.version() == Header.MPEG1) {\r
+\r
+      si.main_data_begin = stream.get_bits(9);\r
+      if (channels == 1)\r
+        si.private_bits = stream.get_bits(5);\r
+      else\r
+        si.private_bits = stream.get_bits(3);\r
+\r
+      for (ch = 0; ch < channels; ch++) {\r
+        si.ch[ch].scfsi[0] = stream.get_bits(1);\r
+        si.ch[ch].scfsi[1] = stream.get_bits(1);\r
+        si.ch[ch].scfsi[2] = stream.get_bits(1);\r
+        si.ch[ch].scfsi[3] = stream.get_bits(1);\r
+      }\r
+\r
+      for (gr = 0; gr < 2; gr++) {\r
+        for (ch = 0; ch < channels; ch++) {\r
+          si.ch[ch].gr[gr].part2_3_length = stream.get_bits(12);\r
+          si.ch[ch].gr[gr].big_values = stream.get_bits(9);\r
+          si.ch[ch].gr[gr].global_gain = stream.get_bits(8);\r
+          si.ch[ch].gr[gr].scalefac_compress = stream.get_bits(4);\r
+          si.ch[ch].gr[gr].window_switching_flag = stream.get_bits(1);\r
+          if ((si.ch[ch].gr[gr].window_switching_flag) != 0) {\r
+            si.ch[ch].gr[gr].block_type = stream.get_bits(2);\r
+            si.ch[ch].gr[gr].mixed_block_flag = stream.get_bits(1);\r
+\r
+            si.ch[ch].gr[gr].table_select[0] = stream.get_bits(5);\r
+            si.ch[ch].gr[gr].table_select[1] = stream.get_bits(5);\r
+\r
+            si.ch[ch].gr[gr].subblock_gain[0] = stream.get_bits(3);\r
+            si.ch[ch].gr[gr].subblock_gain[1] = stream.get_bits(3);\r
+            si.ch[ch].gr[gr].subblock_gain[2] = stream.get_bits(3);\r
+\r
+            // Set region_count parameters since they are implicit in this case.\r
+\r
+            if (si.ch[ch].gr[gr].block_type == 0) {\r
+              // Side info bad: block_type == 0 in split block\r
+              return false;\r
+            } else if (si.ch[ch].gr[gr].block_type == 2 && si.ch[ch].gr[gr].mixed_block_flag == 0) {\r
+              si.ch[ch].gr[gr].region0_count = 8;\r
+            } else {\r
+              si.ch[ch].gr[gr].region0_count = 7;\r
+            }\r
+            si.ch[ch].gr[gr].region1_count = 20 - si.ch[ch].gr[gr].region0_count;\r
+          } else {\r
+            si.ch[ch].gr[gr].table_select[0] = stream.get_bits(5);\r
+            si.ch[ch].gr[gr].table_select[1] = stream.get_bits(5);\r
+            si.ch[ch].gr[gr].table_select[2] = stream.get_bits(5);\r
+            si.ch[ch].gr[gr].region0_count = stream.get_bits(4);\r
+            si.ch[ch].gr[gr].region1_count = stream.get_bits(3);\r
+            si.ch[ch].gr[gr].block_type = 0;\r
+          }\r
+          si.ch[ch].gr[gr].preflag = stream.get_bits(1);\r
+          si.ch[ch].gr[gr].scalefac_scale = stream.get_bits(1);\r
+          si.ch[ch].gr[gr].count1table_select = stream.get_bits(1);\r
+        }\r
+      }\r
+\r
+    } else { // MPEG-2 LSF, SZD: MPEG-2.5 LSF\r
+\r
+      si.main_data_begin = stream.get_bits(8);\r
+      if (channels == 1)\r
+        si.private_bits = stream.get_bits(1);\r
+      else\r
+        si.private_bits = stream.get_bits(2);\r
+\r
+      for (ch = 0; ch < channels; ch++) {\r
+\r
+        si.ch[ch].gr[0].part2_3_length = stream.get_bits(12);\r
+        si.ch[ch].gr[0].big_values = stream.get_bits(9);\r
+        si.ch[ch].gr[0].global_gain = stream.get_bits(8);\r
+        si.ch[ch].gr[0].scalefac_compress = stream.get_bits(9);\r
+        si.ch[ch].gr[0].window_switching_flag = stream.get_bits(1);\r
+\r
+        if ((si.ch[ch].gr[0].window_switching_flag) != 0) {\r
+\r
+          si.ch[ch].gr[0].block_type = stream.get_bits(2);\r
+          si.ch[ch].gr[0].mixed_block_flag = stream.get_bits(1);\r
+          si.ch[ch].gr[0].table_select[0] = stream.get_bits(5);\r
+          si.ch[ch].gr[0].table_select[1] = stream.get_bits(5);\r
+\r
+          si.ch[ch].gr[0].subblock_gain[0] = stream.get_bits(3);\r
+          si.ch[ch].gr[0].subblock_gain[1] = stream.get_bits(3);\r
+          si.ch[ch].gr[0].subblock_gain[2] = stream.get_bits(3);\r
+\r
+          // Set region_count parameters since they are implicit in this case.\r
+\r
+          if (si.ch[ch].gr[0].block_type == 0) {\r
+            // Side info bad: block_type == 0 in split block\r
+            return false;\r
+          } else if (si.ch[ch].gr[0].block_type == 2 && si.ch[ch].gr[0].mixed_block_flag == 0) {\r
+            si.ch[ch].gr[0].region0_count = 8;\r
+          } else {\r
+            si.ch[ch].gr[0].region0_count = 7;\r
+            si.ch[ch].gr[0].region1_count = 20 - si.ch[ch].gr[0].region0_count;\r
+          }\r
+\r
+        } else {\r
+          si.ch[ch].gr[0].table_select[0] = stream.get_bits(5);\r
+          si.ch[ch].gr[0].table_select[1] = stream.get_bits(5);\r
+          si.ch[ch].gr[0].table_select[2] = stream.get_bits(5);\r
+          si.ch[ch].gr[0].region0_count = stream.get_bits(4);\r
+          si.ch[ch].gr[0].region1_count = stream.get_bits(3);\r
+          si.ch[ch].gr[0].block_type = 0;\r
+        }\r
+\r
+        si.ch[ch].gr[0].scalefac_scale = stream.get_bits(1);\r
+        si.ch[ch].gr[0].count1table_select = stream.get_bits(1);\r
+      } // for(ch=0; ch<channels; ch++)\r
+    } // if (header.version() == MPEG1)\r
+    return true;\r
+  }\r
+\r
+  /**\r
+        *\r
+        */\r
+  private void get_scale_factors(int ch, int gr) {\r
+    int sfb, window;\r
+    gr_info_s gr_info = (si.ch[ch].gr[gr]);\r
+    int scale_comp = gr_info.scalefac_compress;\r
+    int length0 = slen[0][scale_comp];\r
+    int length1 = slen[1][scale_comp];\r
+\r
+    if ((gr_info.window_switching_flag != 0) && (gr_info.block_type == 2)) {\r
+      if ((gr_info.mixed_block_flag) != 0) { // MIXED\r
+        for (sfb = 0; sfb < 8; sfb++)\r
+          scalefac[ch].l[sfb] = br.hgetbits(slen[0][gr_info.scalefac_compress]);\r
+        for (sfb = 3; sfb < 6; sfb++)\r
+          for (window = 0; window < 3; window++)\r
+            scalefac[ch].s[window][sfb] = br.hgetbits(slen[0][gr_info.scalefac_compress]);\r
+        for (sfb = 6; sfb < 12; sfb++)\r
+          for (window = 0; window < 3; window++)\r
+            scalefac[ch].s[window][sfb] = br.hgetbits(slen[1][gr_info.scalefac_compress]);\r
+        for (sfb = 12, window = 0; window < 3; window++)\r
+          scalefac[ch].s[window][sfb] = 0;\r
+\r
+      } else { // SHORT\r
+\r
+        scalefac[ch].s[0][0] = br.hgetbits(length0);\r
+        scalefac[ch].s[1][0] = br.hgetbits(length0);\r
+        scalefac[ch].s[2][0] = br.hgetbits(length0);\r
+        scalefac[ch].s[0][1] = br.hgetbits(length0);\r
+        scalefac[ch].s[1][1] = br.hgetbits(length0);\r
+        scalefac[ch].s[2][1] = br.hgetbits(length0);\r
+        scalefac[ch].s[0][2] = br.hgetbits(length0);\r
+        scalefac[ch].s[1][2] = br.hgetbits(length0);\r
+        scalefac[ch].s[2][2] = br.hgetbits(length0);\r
+        scalefac[ch].s[0][3] = br.hgetbits(length0);\r
+        scalefac[ch].s[1][3] = br.hgetbits(length0);\r
+        scalefac[ch].s[2][3] = br.hgetbits(length0);\r
+        scalefac[ch].s[0][4] = br.hgetbits(length0);\r
+        scalefac[ch].s[1][4] = br.hgetbits(length0);\r
+        scalefac[ch].s[2][4] = br.hgetbits(length0);\r
+        scalefac[ch].s[0][5] = br.hgetbits(length0);\r
+        scalefac[ch].s[1][5] = br.hgetbits(length0);\r
+        scalefac[ch].s[2][5] = br.hgetbits(length0);\r
+        scalefac[ch].s[0][6] = br.hgetbits(length1);\r
+        scalefac[ch].s[1][6] = br.hgetbits(length1);\r
+        scalefac[ch].s[2][6] = br.hgetbits(length1);\r
+        scalefac[ch].s[0][7] = br.hgetbits(length1);\r
+        scalefac[ch].s[1][7] = br.hgetbits(length1);\r
+        scalefac[ch].s[2][7] = br.hgetbits(length1);\r
+        scalefac[ch].s[0][8] = br.hgetbits(length1);\r
+        scalefac[ch].s[1][8] = br.hgetbits(length1);\r
+        scalefac[ch].s[2][8] = br.hgetbits(length1);\r
+        scalefac[ch].s[0][9] = br.hgetbits(length1);\r
+        scalefac[ch].s[1][9] = br.hgetbits(length1);\r
+        scalefac[ch].s[2][9] = br.hgetbits(length1);\r
+        scalefac[ch].s[0][10] = br.hgetbits(length1);\r
+        scalefac[ch].s[1][10] = br.hgetbits(length1);\r
+        scalefac[ch].s[2][10] = br.hgetbits(length1);\r
+        scalefac[ch].s[0][11] = br.hgetbits(length1);\r
+        scalefac[ch].s[1][11] = br.hgetbits(length1);\r
+        scalefac[ch].s[2][11] = br.hgetbits(length1);\r
+        scalefac[ch].s[0][12] = 0;\r
+        scalefac[ch].s[1][12] = 0;\r
+        scalefac[ch].s[2][12] = 0;\r
+      } // SHORT\r
+\r
+    } else { // LONG types 0,1,3\r
+\r
+      if ((si.ch[ch].scfsi[0] == 0) || (gr == 0)) {\r
+        scalefac[ch].l[0] = br.hgetbits(length0);\r
+        scalefac[ch].l[1] = br.hgetbits(length0);\r
+        scalefac[ch].l[2] = br.hgetbits(length0);\r
+        scalefac[ch].l[3] = br.hgetbits(length0);\r
+        scalefac[ch].l[4] = br.hgetbits(length0);\r
+        scalefac[ch].l[5] = br.hgetbits(length0);\r
+      }\r
+      if ((si.ch[ch].scfsi[1] == 0) || (gr == 0)) {\r
+        scalefac[ch].l[6] = br.hgetbits(length0);\r
+        scalefac[ch].l[7] = br.hgetbits(length0);\r
+        scalefac[ch].l[8] = br.hgetbits(length0);\r
+        scalefac[ch].l[9] = br.hgetbits(length0);\r
+        scalefac[ch].l[10] = br.hgetbits(length0);\r
+      }\r
+      if ((si.ch[ch].scfsi[2] == 0) || (gr == 0)) {\r
+        scalefac[ch].l[11] = br.hgetbits(length1);\r
+        scalefac[ch].l[12] = br.hgetbits(length1);\r
+        scalefac[ch].l[13] = br.hgetbits(length1);\r
+        scalefac[ch].l[14] = br.hgetbits(length1);\r
+        scalefac[ch].l[15] = br.hgetbits(length1);\r
+      }\r
+      if ((si.ch[ch].scfsi[3] == 0) || (gr == 0)) {\r
+        scalefac[ch].l[16] = br.hgetbits(length1);\r
+        scalefac[ch].l[17] = br.hgetbits(length1);\r
+        scalefac[ch].l[18] = br.hgetbits(length1);\r
+        scalefac[ch].l[19] = br.hgetbits(length1);\r
+        scalefac[ch].l[20] = br.hgetbits(length1);\r
+      }\r
+\r
+      scalefac[ch].l[21] = 0;\r
+      scalefac[ch].l[22] = 0;\r
+    }\r
+  }\r
+\r
+  /**\r
+        *\r
+        */\r
+  // MDM: new_slen is fully initialized before use, no need\r
+  // to reallocate array.\r
+  private final int[] new_slen = new int[4];\r
+\r
+  private void get_LSF_scale_data(int ch, int gr) {\r
+\r
+    int scalefac_comp, int_scalefac_comp;\r
+    int mode_ext = header.mode_extension();\r
+    int m;\r
+    int blocktypenumber;\r
+    int blocknumber = 0;\r
+\r
+    gr_info_s gr_info = (si.ch[ch].gr[gr]);\r
+\r
+    scalefac_comp = gr_info.scalefac_compress;\r
+\r
+    if (gr_info.block_type == 2) {\r
+      if (gr_info.mixed_block_flag == 0)\r
+        blocktypenumber = 1;\r
+      else if (gr_info.mixed_block_flag == 1)\r
+        blocktypenumber = 2;\r
+      else\r
+        blocktypenumber = 0;\r
+    } else {\r
+      blocktypenumber = 0;\r
+    }\r
+\r
+    if (!(((mode_ext == 1) || (mode_ext == 3)) && (ch == 1))) {\r
+\r
+      if (scalefac_comp < 400) {\r
+\r
+        new_slen[0] = (scalefac_comp >>> 4) / 5;\r
+        new_slen[1] = (scalefac_comp >>> 4) % 5;\r
+        new_slen[2] = (scalefac_comp & 0xF) >>> 2;\r
+        new_slen[3] = (scalefac_comp & 3);\r
+        si.ch[ch].gr[gr].preflag = 0;\r
+        blocknumber = 0;\r
+\r
+      } else if (scalefac_comp < 500) {\r
+\r
+        new_slen[0] = ((scalefac_comp - 400) >>> 2) / 5;\r
+        new_slen[1] = ((scalefac_comp - 400) >>> 2) % 5;\r
+        new_slen[2] = (scalefac_comp - 400) & 3;\r
+        new_slen[3] = 0;\r
+        si.ch[ch].gr[gr].preflag = 0;\r
+        blocknumber = 1;\r
+\r
+      } else if (scalefac_comp < 512) {\r
+\r
+        new_slen[0] = (scalefac_comp - 500) / 3;\r
+        new_slen[1] = (scalefac_comp - 500) % 3;\r
+        new_slen[2] = 0;\r
+        new_slen[3] = 0;\r
+        si.ch[ch].gr[gr].preflag = 1;\r
+        blocknumber = 2;\r
+      }\r
+    }\r
+\r
+    if ((((mode_ext == 1) || (mode_ext == 3)) && (ch == 1))) {\r
+      int_scalefac_comp = scalefac_comp >>> 1;\r
+\r
+      if (int_scalefac_comp < 180) {\r
+        new_slen[0] = int_scalefac_comp / 36;\r
+        new_slen[1] = (int_scalefac_comp % 36) / 6;\r
+        new_slen[2] = (int_scalefac_comp % 36) % 6;\r
+        new_slen[3] = 0;\r
+        si.ch[ch].gr[gr].preflag = 0;\r
+        blocknumber = 3;\r
+      } else if (int_scalefac_comp < 244) {\r
+        new_slen[0] = ((int_scalefac_comp - 180) & 0x3F) >>> 4;\r
+        new_slen[1] = ((int_scalefac_comp - 180) & 0xF) >>> 2;\r
+        new_slen[2] = (int_scalefac_comp - 180) & 3;\r
+        new_slen[3] = 0;\r
+        si.ch[ch].gr[gr].preflag = 0;\r
+        blocknumber = 4;\r
+      } else if (int_scalefac_comp < 255) {\r
+        new_slen[0] = (int_scalefac_comp - 244) / 3;\r
+        new_slen[1] = (int_scalefac_comp - 244) % 3;\r
+        new_slen[2] = 0;\r
+        new_slen[3] = 0;\r
+        si.ch[ch].gr[gr].preflag = 0;\r
+        blocknumber = 5;\r
+      }\r
+    }\r
+\r
+    for (int x = 0; x < 45; x++)\r
+      // why 45, not 54?\r
+      scalefac_buffer[x] = 0;\r
+\r
+    m = 0;\r
+    for (int i = 0; i < 4; i++) {\r
+      for (int j = 0; j < nr_of_sfb_block[blocknumber][blocktypenumber][i]; j++) {\r
+        scalefac_buffer[m] = (new_slen[i] == 0) ? 0 : br.hgetbits(new_slen[i]);\r
+        m++;\r
+\r
+      } // for (unint32 j ...\r
+    } // for (uint32 i ...\r
+  }\r
+\r
+  /**\r
+        *\r
+        */\r
+  private void get_LSF_scale_factors(int ch, int gr) {\r
+    int m = 0;\r
+    int sfb, window;\r
+    gr_info_s gr_info = (si.ch[ch].gr[gr]);\r
+\r
+    get_LSF_scale_data(ch, gr);\r
+\r
+    if ((gr_info.window_switching_flag != 0) && (gr_info.block_type == 2)) {\r
+      if (gr_info.mixed_block_flag != 0) { // MIXED\r
+        for (sfb = 0; sfb < 8; sfb++) {\r
+          scalefac[ch].l[sfb] = scalefac_buffer[m];\r
+          m++;\r
+        }\r
+        for (sfb = 3; sfb < 12; sfb++) {\r
+          for (window = 0; window < 3; window++) {\r
+            scalefac[ch].s[window][sfb] = scalefac_buffer[m];\r
+            m++;\r
+          }\r
+        }\r
+        for (window = 0; window < 3; window++)\r
+          scalefac[ch].s[window][12] = 0;\r
+\r
+      } else { // SHORT\r
+\r
+        for (sfb = 0; sfb < 12; sfb++) {\r
+          for (window = 0; window < 3; window++) {\r
+            scalefac[ch].s[window][sfb] = scalefac_buffer[m];\r
+            m++;\r
+          }\r
+        }\r
+\r
+        for (window = 0; window < 3; window++)\r
+          scalefac[ch].s[window][12] = 0;\r
+      }\r
+    } else { // LONG types 0,1,3\r
+\r
+      for (sfb = 0; sfb < 21; sfb++) {\r
+        scalefac[ch].l[sfb] = scalefac_buffer[m];\r
+        m++;\r
+      }\r
+      scalefac[ch].l[21] = 0; // Jeff\r
+      scalefac[ch].l[22] = 0;\r
+    }\r
+  }\r
+\r
+  /**\r
+        *\r
+        */\r
+  int[] x = { 0 };\r
+  int[] y = { 0 };\r
+  int[] v = { 0 };\r
+  int[] w = { 0 };\r
+\r
+  private void huffman_decode(int ch, int gr) {\r
+    x[0] = 0;\r
+    y[0] = 0;\r
+    v[0] = 0;\r
+    w[0] = 0;\r
+\r
+    int part2_3_end = part2_start + si.ch[ch].gr[gr].part2_3_length;\r
+    int num_bits;\r
+    int region1Start;\r
+    int region2Start;\r
+    int index;\r
+\r
+    int buf, buf1;\r
+\r
+    huffcodetab h;\r
+\r
+    // Find region boundary for short block case\r
+\r
+    if (((si.ch[ch].gr[gr].window_switching_flag) != 0) && (si.ch[ch].gr[gr].block_type == 2)) {\r
+\r
+      // Region2.\r
+      // MS: Extrahandling for 8KHZ\r
+      region1Start = (sfreq == 8) ? 72 : 36; // sfb[9/3]*3=36 or in case 8KHZ =\r
+                                             // 72\r
+      region2Start = 576; // No Region2 for short block case\r
+\r
+    } else { // Find region boundary for long block case\r
+\r
+      buf = si.ch[ch].gr[gr].region0_count + 1;\r
+      buf1 = buf + si.ch[ch].gr[gr].region1_count + 1;\r
+\r
+      if (buf1 > sfBandIndex[sfreq].l.length - 1)\r
+        buf1 = sfBandIndex[sfreq].l.length - 1;\r
+\r
+      region1Start = sfBandIndex[sfreq].l[buf];\r
+      region2Start = sfBandIndex[sfreq].l[buf1]; /* MI */\r
+    }\r
+\r
+    index = 0;\r
+    // Read bigvalues area\r
+    for (int i = 0; i < (si.ch[ch].gr[gr].big_values << 1); i += 2) {\r
+      if (i < region1Start)\r
+        h = huffcodetab.ht[si.ch[ch].gr[gr].table_select[0]];\r
+      else if (i < region2Start)\r
+        h = huffcodetab.ht[si.ch[ch].gr[gr].table_select[1]];\r
+      else\r
+        h = huffcodetab.ht[si.ch[ch].gr[gr].table_select[2]];\r
+\r
+      huffcodetab.huffman_decoder(h, x, y, v, w, br);\r
+      // if (index >= is_1d.length)\r
+      // System.out.println("i0="+i+"/"+(si.ch[ch].gr[gr].big_values<<1)+" Index="+index+" is_1d="+is_1d.length);\r
+\r
+      is_1d[index++] = x[0];\r
+      is_1d[index++] = y[0];\r
+\r
+      CheckSumHuff = CheckSumHuff + x[0] + y[0];\r
+      // System.out.println("x = "+x[0]+" y = "+y[0]);\r
+    }\r
+\r
+    // Read count1 area\r
+    h = huffcodetab.ht[si.ch[ch].gr[gr].count1table_select + 32];\r
+    num_bits = br.hsstell();\r
+\r
+    while ((num_bits < part2_3_end) && (index < 576)) {\r
+\r
+      huffcodetab.huffman_decoder(h, x, y, v, w, br);\r
+\r
+      is_1d[index++] = v[0];\r
+      is_1d[index++] = w[0];\r
+      is_1d[index++] = x[0];\r
+      is_1d[index++] = y[0];\r
+      CheckSumHuff = CheckSumHuff + v[0] + w[0] + x[0] + y[0];\r
+      // System.out.println("v = "+v[0]+" w = "+w[0]);\r
+      // System.out.println("x = "+x[0]+" y = "+y[0]);\r
+      num_bits = br.hsstell();\r
+    }\r
+\r
+    if (num_bits > part2_3_end) {\r
+      br.rewindNbits(num_bits - part2_3_end);\r
+      index -= 4;\r
+    }\r
+\r
+    num_bits = br.hsstell();\r
+\r
+    // Dismiss stuffing bits\r
+    if (num_bits < part2_3_end)\r
+      br.hgetbits(part2_3_end - num_bits);\r
+\r
+    // Zero out rest\r
+\r
+    if (index < 576)\r
+      nonzero[ch] = index;\r
+    else\r
+      nonzero[ch] = 576;\r
+\r
+    if (index < 0)\r
+      index = 0;\r
+\r
+    // may not be necessary\r
+    for (; index < 576; index++)\r
+      is_1d[index] = 0;\r
+  }\r
+\r
+  /**\r
+        *\r
+        */\r
+  private void i_stereo_k_values(int is_pos, int io_type, int i) {\r
+    if (is_pos == 0) {\r
+      k[0][i] = 1.0f;\r
+      k[1][i] = 1.0f;\r
+    } else if ((is_pos & 1) != 0) {\r
+      k[0][i] = io[io_type][(is_pos + 1) >>> 1];\r
+      k[1][i] = 1.0f;\r
+    } else {\r
+      k[0][i] = 1.0f;\r
+      k[1][i] = io[io_type][is_pos >>> 1];\r
+    }\r
+  }\r
+\r
+  /**\r
+        *\r
+        */\r
+  private void dequantize_sample(float xr[][], int ch, int gr) {\r
+    gr_info_s gr_info = (si.ch[ch].gr[gr]);\r
+    int cb = 0;\r
+    int next_cb_boundary;\r
+    int cb_begin = 0;\r
+    int cb_width = 0;\r
+    int index = 0, t_index, j;\r
+    float g_gain;\r
+    float[][] xr_1d = xr;\r
+\r
+    // choose correct scalefactor band per block type, initalize boundary\r
+\r
+    if ((gr_info.window_switching_flag != 0) && (gr_info.block_type == 2)) {\r
+      if (gr_info.mixed_block_flag != 0)\r
+        next_cb_boundary = sfBandIndex[sfreq].l[1]; // LONG blocks: 0,1,3\r
+      else {\r
+        cb_width = sfBandIndex[sfreq].s[1];\r
+        next_cb_boundary = (cb_width << 2) - cb_width;\r
+        cb_begin = 0;\r
+      }\r
+    } else {\r
+      next_cb_boundary = sfBandIndex[sfreq].l[1]; // LONG blocks: 0,1,3\r
+    }\r
+\r
+    // Compute overall (global) scaling.\r
+\r
+    g_gain = (float) Math.pow(2.0, (0.25 * (gr_info.global_gain - 210.0)));\r
+\r
+    for (j = 0; j < nonzero[ch]; j++) {\r
+      // Modif E.B 02/22/99\r
+      int reste = j % SSLIMIT;\r
+      int quotien = (int) ((j - reste) / SSLIMIT);\r
+      if (is_1d[j] == 0)\r
+        xr_1d[quotien][reste] = 0.0f;\r
+      else {\r
+        int abv = is_1d[j];\r
+        // Pow Array fix (11/17/04)\r
+        if (abv < t_43.length) {\r
+          if (is_1d[j] > 0)\r
+            xr_1d[quotien][reste] = g_gain * t_43[abv];\r
+          else {\r
+            if (-abv < t_43.length)\r
+              xr_1d[quotien][reste] = -g_gain * t_43[-abv];\r
+            else\r
+              xr_1d[quotien][reste] = -g_gain * (float) Math.pow(-abv, d43);\r
+          }\r
+        } else {\r
+          if (is_1d[j] > 0)\r
+            xr_1d[quotien][reste] = g_gain * (float) Math.pow(abv, d43);\r
+          else\r
+            xr_1d[quotien][reste] = -g_gain * (float) Math.pow(-abv, d43);\r
+        }\r
+      }\r
+    }\r
+\r
+    // apply formula per block type\r
+    for (j = 0; j < nonzero[ch]; j++) {\r
+      // Modif E.B 02/22/99\r
+      int reste = j % SSLIMIT;\r
+      int quotien = (int) ((j - reste) / SSLIMIT);\r
+\r
+      if (index == next_cb_boundary) { /* Adjust critical band boundary */\r
+        if ((gr_info.window_switching_flag != 0) && (gr_info.block_type == 2)) {\r
+          if (gr_info.mixed_block_flag != 0) {\r
+\r
+            if (index == sfBandIndex[sfreq].l[8]) {\r
+              next_cb_boundary = sfBandIndex[sfreq].s[4];\r
+              next_cb_boundary = (next_cb_boundary << 2) - next_cb_boundary;\r
+              cb = 3;\r
+              cb_width = sfBandIndex[sfreq].s[4] - sfBandIndex[sfreq].s[3];\r
+\r
+              cb_begin = sfBandIndex[sfreq].s[3];\r
+              cb_begin = (cb_begin << 2) - cb_begin;\r
+\r
+            } else if (index < sfBandIndex[sfreq].l[8]) {\r
+\r
+              next_cb_boundary = sfBandIndex[sfreq].l[(++cb) + 1];\r
+\r
+            } else {\r
+\r
+              next_cb_boundary = sfBandIndex[sfreq].s[(++cb) + 1];\r
+              next_cb_boundary = (next_cb_boundary << 2) - next_cb_boundary;\r
+\r
+              cb_begin = sfBandIndex[sfreq].s[cb];\r
+              cb_width = sfBandIndex[sfreq].s[cb + 1] - cb_begin;\r
+              cb_begin = (cb_begin << 2) - cb_begin;\r
+            }\r
+\r
+          } else {\r
+\r
+            next_cb_boundary = sfBandIndex[sfreq].s[(++cb) + 1];\r
+            next_cb_boundary = (next_cb_boundary << 2) - next_cb_boundary;\r
+\r
+            cb_begin = sfBandIndex[sfreq].s[cb];\r
+            cb_width = sfBandIndex[sfreq].s[cb + 1] - cb_begin;\r
+            cb_begin = (cb_begin << 2) - cb_begin;\r
+          }\r
+\r
+        } else { // long blocks\r
+\r
+          next_cb_boundary = sfBandIndex[sfreq].l[(++cb) + 1];\r
+\r
+        }\r
+      }\r
+\r
+      // Do long/short dependent scaling operations\r
+\r
+      if ((gr_info.window_switching_flag != 0)\r
+          && (((gr_info.block_type == 2) && (gr_info.mixed_block_flag == 0)) || ((gr_info.block_type == 2)\r
+              && (gr_info.mixed_block_flag != 0) && (j >= 36)))) {\r
+\r
+        t_index = (index - cb_begin) / cb_width;\r
+        /*\r
+         * xr[sb][ss] *= pow(2.0, ((-2.0 * gr_info.subblock_gain[t_index]) -(0.5\r
+         * * (1.0 + gr_info.scalefac_scale) scalefac[ch].s[t_index][cb])));\r
+         */\r
+        int idx = scalefac[ch].s[t_index][cb] << gr_info.scalefac_scale;\r
+        idx += (gr_info.subblock_gain[t_index] << 2);\r
+\r
+        xr_1d[quotien][reste] *= two_to_negative_half_pow[idx];\r
+\r
+      } else { // LONG block types 0,1,3 & 1st 2 subbands of switched blocks\r
+        /*\r
+         * xr[sb][ss] *= pow(2.0, -0.5 * (1.0+gr_info.scalefac_scale)\r
+         * (scalefac[ch].l[cb] + gr_info.preflag * pretab[cb]));\r
+         */\r
+        int idx = scalefac[ch].l[cb];\r
+\r
+        if (gr_info.preflag != 0)\r
+          idx += pretab[cb];\r
+\r
+        idx = idx << gr_info.scalefac_scale;\r
+        xr_1d[quotien][reste] *= two_to_negative_half_pow[idx];\r
+      }\r
+      index++;\r
+    }\r
+\r
+    for (j = nonzero[ch]; j < 576; j++) {\r
+      // Modif E.B 02/22/99\r
+      int reste = j % SSLIMIT;\r
+      int quotien = (int) ((j - reste) / SSLIMIT);\r
+      if (reste < 0)\r
+        reste = 0;\r
+      if (quotien < 0)\r
+        quotien = 0;\r
+      xr_1d[quotien][reste] = 0.0f;\r
+    }\r
+\r
+    return;\r
+  }\r
+\r
+  /**\r
+        *\r
+        */\r
+  private void reorder(float xr[][], int ch, int gr) {\r
+    gr_info_s gr_info = (si.ch[ch].gr[gr]);\r
+    int freq, freq3;\r
+    int index;\r
+    int sfb, sfb_start, sfb_lines;\r
+    int src_line, des_line;\r
+    float[][] xr_1d = xr;\r
+\r
+    if ((gr_info.window_switching_flag != 0) && (gr_info.block_type == 2)) {\r
+\r
+      for (index = 0; index < 576; index++)\r
+        out_1d[index] = 0.0f;\r
+\r
+      if (gr_info.mixed_block_flag != 0) {\r
+        // NO REORDER FOR LOW 2 SUBBANDS\r
+        for (index = 0; index < 36; index++) {\r
+          // Modif E.B 02/22/99\r
+          int reste = index % SSLIMIT;\r
+          int quotien = (int) ((index - reste) / SSLIMIT);\r
+          out_1d[index] = xr_1d[quotien][reste];\r
+        }\r
+        // REORDERING FOR REST SWITCHED SHORT\r
+        /*\r
+         * for( sfb=3,sfb_start=sfBandIndex[sfreq].s[3],\r
+         * sfb_lines=sfBandIndex[sfreq].s[4] - sfb_start; sfb < 13;\r
+         * sfb++,sfb_start = sfBandIndex[sfreq].s[sfb], sfb_lines =\r
+         * sfBandIndex[sfreq].s[sfb+1] - sfb_start ) {\r
+         */\r
+        for (sfb = 3; sfb < 13; sfb++) {\r
+          // System.out.println("sfreq="+sfreq+" sfb="+sfb+" sfBandIndex="+sfBandIndex.length+" sfBandIndex[sfreq].s="+sfBandIndex[sfreq].s.length);\r
+          sfb_start = sfBandIndex[sfreq].s[sfb];\r
+          sfb_lines = sfBandIndex[sfreq].s[sfb + 1] - sfb_start;\r
+\r
+          int sfb_start3 = (sfb_start << 2) - sfb_start;\r
+\r
+          for (freq = 0, freq3 = 0; freq < sfb_lines; freq++, freq3 += 3) {\r
+\r
+            src_line = sfb_start3 + freq;\r
+            des_line = sfb_start3 + freq3;\r
+            // Modif E.B 02/22/99\r
+            int reste = src_line % SSLIMIT;\r
+            int quotien = (int) ((src_line - reste) / SSLIMIT);\r
+\r
+            out_1d[des_line] = xr_1d[quotien][reste];\r
+            src_line += sfb_lines;\r
+            des_line++;\r
+\r
+            reste = src_line % SSLIMIT;\r
+            quotien = (int) ((src_line - reste) / SSLIMIT);\r
+\r
+            out_1d[des_line] = xr_1d[quotien][reste];\r
+            src_line += sfb_lines;\r
+            des_line++;\r
+\r
+            reste = src_line % SSLIMIT;\r
+            quotien = (int) ((src_line - reste) / SSLIMIT);\r
+\r
+            out_1d[des_line] = xr_1d[quotien][reste];\r
+          }\r
+        }\r
+\r
+      } else { // pure short\r
+        for (index = 0; index < 576; index++) {\r
+          int j = reorder_table[sfreq][index];\r
+          int reste = j % SSLIMIT;\r
+          int quotien = (int) ((j - reste) / SSLIMIT);\r
+          out_1d[index] = xr_1d[quotien][reste];\r
+        }\r
+      }\r
+    } else { // long blocks\r
+      for (index = 0; index < 576; index++) {\r
+        // Modif E.B 02/22/99\r
+        int reste = index % SSLIMIT;\r
+        int quotien = (int) ((index - reste) / SSLIMIT);\r
+        out_1d[index] = xr_1d[quotien][reste];\r
+      }\r
+    }\r
+  }\r
+\r
+  /**\r
+        *\r
+        */\r
+\r
+  int[] is_pos = new int[576];\r
+  float[] is_ratio = new float[576];\r
+\r
+  private void stereo(int gr) {\r
+    int sb, ss;\r
+\r
+    if (channels == 1) { // mono , bypass xr[0][][] to lr[0][][]\r
+\r
+      for (sb = 0; sb < SBLIMIT; sb++)\r
+        for (ss = 0; ss < SSLIMIT; ss += 3) {\r
+          lr[0][sb][ss] = ro[0][sb][ss];\r
+          lr[0][sb][ss + 1] = ro[0][sb][ss + 1];\r
+          lr[0][sb][ss + 2] = ro[0][sb][ss + 2];\r
+        }\r
+\r
+    } else {\r
+\r
+      gr_info_s gr_info = (si.ch[0].gr[gr]);\r
+      int mode_ext = header.mode_extension();\r
+      int sfb;\r
+      int i;\r
+      int lines, temp, temp2;\r
+\r
+      boolean ms_stereo = ((header.mode() == Header.JOINT_STEREO) && ((mode_ext & 0x2) != 0));\r
+      boolean i_stereo = ((header.mode() == Header.JOINT_STEREO) && ((mode_ext & 0x1) != 0));\r
+      boolean lsf =\r
+          ((header.version() == Header.MPEG2_LSF || header.version() == Header.MPEG25_LSF)); // SZD\r
+\r
+      int io_type = (gr_info.scalefac_compress & 1);\r
+\r
+      // initialization\r
+\r
+      for (i = 0; i < 576; i++) {\r
+        is_pos[i] = 7;\r
+\r
+        is_ratio[i] = 0.0f;\r
+      }\r
+\r
+      if (i_stereo) {\r
+        if ((gr_info.window_switching_flag != 0) && (gr_info.block_type == 2)) {\r
+          if (gr_info.mixed_block_flag != 0) {\r
+\r
+            int max_sfb = 0;\r
+\r
+            for (int j = 0; j < 3; j++) {\r
+              int sfbcnt;\r
+              sfbcnt = 2;\r
+              for (sfb = 12; sfb >= 3; sfb--) {\r
+                i = sfBandIndex[sfreq].s[sfb];\r
+                lines = sfBandIndex[sfreq].s[sfb + 1] - i;\r
+                i = (i << 2) - i + (j + 1) * lines - 1;\r
+\r
+                while (lines > 0) {\r
+                  if (ro[1][i / 18][i % 18] != 0.0f) {\r
+                    // MDM: in java, array access is very slow.\r
+                    // Is quicker to compute div and mod values.\r
+                    // if (ro[1][ss_div[i]][ss_mod[i]] != 0.0f) {\r
+                    sfbcnt = sfb;\r
+                    sfb = -10;\r
+                    lines = -10;\r
+                  }\r
+\r
+                  lines--;\r
+                  i--;\r
+\r
+                } // while (lines > 0)\r
+\r
+              } // for (sfb=12 ...\r
+              sfb = sfbcnt + 1;\r
+\r
+              if (sfb > max_sfb)\r
+                max_sfb = sfb;\r
+\r
+              while (sfb < 12) {\r
+                temp = sfBandIndex[sfreq].s[sfb];\r
+                sb = sfBandIndex[sfreq].s[sfb + 1] - temp;\r
+                i = (temp << 2) - temp + j * sb;\r
+\r
+                for (; sb > 0; sb--) {\r
+                  is_pos[i] = scalefac[1].s[j][sfb];\r
+                  if (is_pos[i] != 7)\r
+                    if (lsf)\r
+                      i_stereo_k_values(is_pos[i], io_type, i);\r
+                    else\r
+                      is_ratio[i] = TAN12[is_pos[i]];\r
+\r
+                  i++;\r
+                } // for (; sb>0...\r
+                sfb++;\r
+              } // while (sfb < 12)\r
+              sfb = sfBandIndex[sfreq].s[10];\r
+              sb = sfBandIndex[sfreq].s[11] - sfb;\r
+              sfb = (sfb << 2) - sfb + j * sb;\r
+              temp = sfBandIndex[sfreq].s[11];\r
+              sb = sfBandIndex[sfreq].s[12] - temp;\r
+              i = (temp << 2) - temp + j * sb;\r
+\r
+              for (; sb > 0; sb--) {\r
+                is_pos[i] = is_pos[sfb];\r
+\r
+                if (lsf) {\r
+                  k[0][i] = k[0][sfb];\r
+                  k[1][i] = k[1][sfb];\r
+                } else {\r
+                  is_ratio[i] = is_ratio[sfb];\r
+                }\r
+                i++;\r
+              } // for (; sb > 0 ...\r
+            }\r
+            if (max_sfb <= 3) {\r
+              i = 2;\r
+              ss = 17;\r
+              sb = -1;\r
+              while (i >= 0) {\r
+                if (ro[1][i][ss] != 0.0f) {\r
+                  sb = (i << 4) + (i << 1) + ss;\r
+                  i = -1;\r
+                } else {\r
+                  ss--;\r
+                  if (ss < 0) {\r
+                    i--;\r
+                    ss = 17;\r
+                  }\r
+                } // if (ro ...\r
+              } // while (i>=0)\r
+              i = 0;\r
+              while (sfBandIndex[sfreq].l[i] <= sb)\r
+                i++;\r
+              sfb = i;\r
+              i = sfBandIndex[sfreq].l[i];\r
+              for (; sfb < 8; sfb++) {\r
+                sb = sfBandIndex[sfreq].l[sfb + 1] - sfBandIndex[sfreq].l[sfb];\r
+                for (; sb > 0; sb--) {\r
+                  is_pos[i] = scalefac[1].l[sfb];\r
+                  if (is_pos[i] != 7)\r
+                    if (lsf)\r
+                      i_stereo_k_values(is_pos[i], io_type, i);\r
+                    else\r
+                      is_ratio[i] = TAN12[is_pos[i]];\r
+                  i++;\r
+                } // for (; sb>0 ...\r
+              } // for (; sfb<8 ...\r
+            } // for (j=0 ...\r
+          } else { // if (gr_info.mixed_block_flag)\r
+            for (int j = 0; j < 3; j++) {\r
+              int sfbcnt;\r
+              sfbcnt = -1;\r
+              for (sfb = 12; sfb >= 0; sfb--) {\r
+                temp = sfBandIndex[sfreq].s[sfb];\r
+                lines = sfBandIndex[sfreq].s[sfb + 1] - temp;\r
+                i = (temp << 2) - temp + (j + 1) * lines - 1;\r
+\r
+                while (lines > 0) {\r
+                  if (ro[1][i / 18][i % 18] != 0.0f) {\r
+                    // MDM: in java, array access is very slow.\r
+                    // Is quicker to compute div and mod values.\r
+                    // if (ro[1][ss_div[i]][ss_mod[i]] != 0.0f) {\r
+                    sfbcnt = sfb;\r
+                    sfb = -10;\r
+                    lines = -10;\r
+                  }\r
+                  lines--;\r
+                  i--;\r
+                } // while (lines > 0) */\r
+\r
+              } // for (sfb=12 ...\r
+              sfb = sfbcnt + 1;\r
+              while (sfb < 12) {\r
+                temp = sfBandIndex[sfreq].s[sfb];\r
+                sb = sfBandIndex[sfreq].s[sfb + 1] - temp;\r
+                i = (temp << 2) - temp + j * sb;\r
+                for (; sb > 0; sb--) {\r
+                  is_pos[i] = scalefac[1].s[j][sfb];\r
+                  if (is_pos[i] != 7)\r
+                    if (lsf)\r
+                      i_stereo_k_values(is_pos[i], io_type, i);\r
+                    else\r
+                      is_ratio[i] = TAN12[is_pos[i]];\r
+                  i++;\r
+                } // for (; sb>0 ...\r
+                sfb++;\r
+              } // while (sfb<12)\r
+\r
+              temp = sfBandIndex[sfreq].s[10];\r
+              temp2 = sfBandIndex[sfreq].s[11];\r
+              sb = temp2 - temp;\r
+              sfb = (temp << 2) - temp + j * sb;\r
+              sb = sfBandIndex[sfreq].s[12] - temp2;\r
+              i = (temp2 << 2) - temp2 + j * sb;\r
+\r
+              for (; sb > 0; sb--) {\r
+                is_pos[i] = is_pos[sfb];\r
+\r
+                if (lsf) {\r
+                  k[0][i] = k[0][sfb];\r
+                  k[1][i] = k[1][sfb];\r
+                } else {\r
+                  is_ratio[i] = is_ratio[sfb];\r
+                }\r
+                i++;\r
+              } // for (; sb>0 ...\r
+            } // for (sfb=12\r
+          } // for (j=0 ...\r
+        } else { // if (gr_info.window_switching_flag ...\r
+          i = 31;\r
+          ss = 17;\r
+          sb = 0;\r
+          while (i >= 0) {\r
+            if (ro[1][i][ss] != 0.0f) {\r
+              sb = (i << 4) + (i << 1) + ss;\r
+              i = -1;\r
+            } else {\r
+              ss--;\r
+              if (ss < 0) {\r
+                i--;\r
+                ss = 17;\r
+              }\r
+            }\r
+          }\r
+          i = 0;\r
+          while (sfBandIndex[sfreq].l[i] <= sb)\r
+            i++;\r
+\r
+          sfb = i;\r
+          i = sfBandIndex[sfreq].l[i];\r
+          for (; sfb < 21; sfb++) {\r
+            sb = sfBandIndex[sfreq].l[sfb + 1] - sfBandIndex[sfreq].l[sfb];\r
+            for (; sb > 0; sb--) {\r
+              is_pos[i] = scalefac[1].l[sfb];\r
+              if (is_pos[i] != 7)\r
+                if (lsf)\r
+                  i_stereo_k_values(is_pos[i], io_type, i);\r
+                else\r
+                  is_ratio[i] = TAN12[is_pos[i]];\r
+              i++;\r
+            }\r
+          }\r
+          sfb = sfBandIndex[sfreq].l[20];\r
+          for (sb = 576 - sfBandIndex[sfreq].l[21]; (sb > 0) && (i < 576); sb--) {\r
+            is_pos[i] = is_pos[sfb]; // error here : i >=576\r
+\r
+            if (lsf) {\r
+              k[0][i] = k[0][sfb];\r
+              k[1][i] = k[1][sfb];\r
+            } else {\r
+              is_ratio[i] = is_ratio[sfb];\r
+            }\r
+            i++;\r
+          } // if (gr_info.mixed_block_flag)\r
+        } // if (gr_info.window_switching_flag ...\r
+      } // if (i_stereo)\r
+\r
+      i = 0;\r
+      for (sb = 0; sb < SBLIMIT; sb++)\r
+        for (ss = 0; ss < SSLIMIT; ss++) {\r
+          if (is_pos[i] == 7) {\r
+            if (ms_stereo) {\r
+              lr[0][sb][ss] = (ro[0][sb][ss] + ro[1][sb][ss]) * 0.707106781f;\r
+              lr[1][sb][ss] = (ro[0][sb][ss] - ro[1][sb][ss]) * 0.707106781f;\r
+            } else {\r
+              lr[0][sb][ss] = ro[0][sb][ss];\r
+              lr[1][sb][ss] = ro[1][sb][ss];\r
+            }\r
+          } else if (i_stereo) {\r
+\r
+            if (lsf) {\r
+              lr[0][sb][ss] = ro[0][sb][ss] * k[0][i];\r
+              lr[1][sb][ss] = ro[0][sb][ss] * k[1][i];\r
+            } else {\r
+              lr[1][sb][ss] = ro[0][sb][ss] / (float) (1 + is_ratio[i]);\r
+              lr[0][sb][ss] = lr[1][sb][ss] * is_ratio[i];\r
+            }\r
+          }\r
+          /*\r
+           * else { System.out.println("Error in stereo processing\n"); }\r
+           */\r
+          i++;\r
+        }\r
+\r
+    } // channels == 2\r
+\r
+  }\r
+\r
+  /**\r
+        *\r
+        */\r
+  private void antialias(int ch, int gr) {\r
+    int sb18, ss, sb18lim;\r
+    gr_info_s gr_info = (si.ch[ch].gr[gr]);\r
+    // 31 alias-reduction operations between each pair of sub-bands\r
+    // with 8 butterflies between each pair\r
+\r
+    if ((gr_info.window_switching_flag != 0) && (gr_info.block_type == 2)\r
+        && !(gr_info.mixed_block_flag != 0))\r
+      return;\r
+\r
+    if ((gr_info.window_switching_flag != 0) && (gr_info.mixed_block_flag != 0)\r
+        && (gr_info.block_type == 2)) {\r
+      sb18lim = 18;\r
+    } else {\r
+      sb18lim = 558;\r
+    }\r
+\r
+    for (sb18 = 0; sb18 < sb18lim; sb18 += 18) {\r
+      for (ss = 0; ss < 8; ss++) {\r
+        int src_idx1 = sb18 + 17 - ss;\r
+        int src_idx2 = sb18 + 18 + ss;\r
+        float bu = out_1d[src_idx1];\r
+        float bd = out_1d[src_idx2];\r
+        out_1d[src_idx1] = (bu * cs[ss]) - (bd * ca[ss]);\r
+        out_1d[src_idx2] = (bd * cs[ss]) + (bu * ca[ss]);\r
+      }\r
+    }\r
+  }\r
+\r
+  /**\r
+        *\r
+        */\r
+\r
+  // MDM: tsOutCopy and rawout do not need initializing, so the arrays\r
+  // can be reused.\r
+  float[] tsOutCopy = new float[18];\r
+  float[] rawout = new float[36];\r