From: yeom Date: Fri, 21 Oct 2011 17:32:10 +0000 (+0000) Subject: moves MP3Decoder codes to Benchmark directory X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3b010fe8985ad3bbf5c2796620d5684013c770fb;p=IRC.git moves MP3Decoder codes to Benchmark directory --- diff --git a/Robust/src/Analysis/SSJava/DefinitelyWrittenCheck.java b/Robust/src/Analysis/SSJava/DefinitelyWrittenCheck.java index f23e0f0c..aa7a697f 100644 --- a/Robust/src/Analysis/SSJava/DefinitelyWrittenCheck.java +++ b/Robust/src/Analysis/SSJava/DefinitelyWrittenCheck.java @@ -1422,7 +1422,6 @@ public class DefinitelyWrittenCheck { case FKind.FlatFieldNode: case FKind.FlatElementNode: { - if (fn.kind() == FKind.FlatFieldNode) { FlatFieldNode ffn = (FlatFieldNode) fn; lhs = ffn.getDst(); @@ -1443,13 +1442,16 @@ public class DefinitelyWrittenCheck { // read field NTuple srcHeapPath = mapHeapPath.get(rhs); - System.out.println("rhs=" + rhs); + NTuple fldHeapPath; if (srcHeapPath != null) { fldHeapPath = new NTuple(srcHeapPath.getList()); } else { // if srcHeapPath is null, it is static reference + System.out.println("##"); + System.out.println("rhs=" + rhs + " fd=" + fld); fldHeapPath = new NTuple(); + fldHeapPath.add(rhs); } fldHeapPath.add(fld); diff --git a/Robust/src/Benchmarks/SSJava/JavaNator/RobotMain.java b/Robust/src/Benchmarks/SSJava/JavaNator/RobotMain.java index dbdd0705..51d9dd45 100644 --- a/Robust/src/Benchmarks/SSJava/JavaNator/RobotMain.java +++ b/Robust/src/Benchmarks/SSJava/JavaNator/RobotMain.java @@ -199,6 +199,7 @@ public class RobotMain { } break; default: + strategyMgr.stop(); System.out.println("processIOCommand: Default: opCode = " + Integer.toString((int) opCode) + " data = " + Integer.toString((int) data)); } diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/AudioDevice.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/AudioDevice.java new file mode 100644 index 00000000..17dc9036 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/AudioDevice.java @@ -0,0 +1,79 @@ +// dummy audio device +/** + * The JavaSoundAudioDevice implements an audio device by using the + * JavaSound API. + * + * @since 0.0.8 + * @author Mat McGowan + */ +public class AudioDevice { + + /** + * Prepares the AudioDevice for playback of audio samples. + * + * @param decoder + * The decoder that will be providing the audio samples. + * + * If the audio device is already open, this method returns silently. + * + */ + public void open(Decoder decoder) throws JavaLayerException { + + } + + /** + * Retrieves the open state of this audio device. + * + * @return true if this audio device is open and playing audio + * samples, or false otherwise. + */ + public boolean isOpen() { + return true; + } + + /** + * Writes a number of samples to this AudioDevice. + * + * @param samples + * The array of signed 16-bit samples to write to the audio device. + * @param offs + * The offset of the first sample. + * @param len + * The number of samples to write. + * + * This method may return prior to the samples actually being played + * by the audio device. + */ + public void write(short[] samples, int offs, int len) throws JavaLayerException { + + } + + /** + * Closes this audio device. Any currently playing audio is stopped as soon as + * possible. Any previously written audio data that has not been heard is + * discarded. + * + * The implementation should ensure that any threads currently blocking on the + * device (e.g. during a write or flush operation + * should be unblocked by this method. + */ + public void close() { + + } + + /** + * Blocks until all audio samples previously written to this audio device have + * been heard. + */ + public void flush() { + + } + + /** + * Retrieves the current playback position in milliseconds. + */ + public int getPosition() { + return 0; + } + +} \ No newline at end of file diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/BitReserve.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/BitReserve.java new file mode 100644 index 00000000..15f4a068 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/BitReserve.java @@ -0,0 +1,172 @@ +/* + * 11/19/04 1.0 moved to LGPL. + * + * 12/12/99 0.0.7 Implementation stores single bits + * as ints for better performance. mdm@techie.com. + * + * 02/28/99 0.0 Java Conversion by E.B, javalayer@javazoom.net + * + * Adapted from the public c code by Jeff Tsay. + * + *----------------------------------------------------------------------- + * 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. + *---------------------------------------------------------------------- + */ + +/** + * Implementation of Bit Reservoir for Layer III. + *

+ * The implementation stores single bits as a word in the buffer. If a bit is + * set, the corresponding word in the buffer will be non-zero. If a bit is + * clear, the corresponding word is zero. Although this may seem waseful, this + * can be a factor of two quicker than packing 8 bits to a byte and extracting. + *

+ */ + +// REVIEW: there is no range checking, so buffer underflow or overflow +// can silently occur. +@LATTICE("BUF 0) { + val <<= 1; + val |= ((buf[pos++] != 0) ? 1 : 0); + } + } else { + TERMINATE: + while (N-- > 0) { + val <<= 1; + val |= ((buf[pos] != 0) ? 1 : 0); + pos = (pos + 1) & BUFSIZE_MASK; + } + } + + buf_byte_idx = pos; + + return val; + + } + + /** + * Returns next bit from reserve. + * + * @returns 0 if next bit is reset, or 1 if next bit is set. + */ + @RETURNLOC("THIS,BitReserve.BIT") + public int hget1bit() { + totbit++; + @LOC("THIS,BitReserve.BIT") int val = buf[buf_byte_idx]; + buf_byte_idx = (buf_byte_idx + 1) & BUFSIZE_MASK; + return val; + } + + /** + * Write 8 bits into the bit stream. + */ + @LATTICE("OUTBistream class is responsible for parsing an MPEG audio + * bitstream. + * + * REVIEW: much of the parsing currently occurs in the various decoders. + * This should be moved into this class and associated inner classes. + */ +@LATTICE("FBframebuffer where the next bits are retrieved. + */ + @LOC("WP") + private int wordpointer; + + /** + * Number (0-31, from MSB to LSB) of next bit for get_bits() + */ + @LOC("BI") + private int bitindex; + + /** + * The current specified syncword + */ + @LOC("F") + private int syncword; + + /** + * Audio header position in stream. + */ + @LOC("F") + private int header_pos = 0; + + /** + * + */ + @LOC("F") + private boolean single_ch_mode; + // private int current_frame_number; + // private int last_frame_number; + + @LOC("F") + private final int bitmask[] = { + 0, // dummy + 0x00000001, 0x00000003, 0x00000007, 0x0000000F, 0x0000001F, 0x0000003F, 0x0000007F, + 0x000000FF, 0x000001FF, 0x000003FF, 0x000007FF, 0x00000FFF, 0x00001FFF, 0x00003FFF, + 0x00007FFF, 0x0000FFFF, 0x0001FFFF }; + + @LOC("F") + private final PushbackInputStream source; + + @LOC("F") + private final Header header = new Header(); + + @LOC("F") + private final byte syncbuf[] = new byte[4]; + + @LOC("F") + private Crc16[] crc = new Crc16[1]; + + @LOC("F") + private byte[] rawid3v2 = null; + + @LOC("FF") + private boolean firstframe = true; + + private BitReserve br; + private int main_data_begin; + private int frame_start; + + /** + * Construct a IBitstream that reads data from a given InputStream. + * + * @param in + * The InputStream to read from. + */ + public Bitstream(InputStream in) { + if (in == null) + throw new NullPointerException("in"); + in = new BufferedInputStream(in); + loadID3v2(in); + firstframe = true; + // source = new PushbackInputStream(in, 1024); + source = new PushbackInputStream(in, BUFFER_INT_SIZE * 4); + + closeFrame(); + // current_frame_number = -1; + // last_frame_number = -1; + + br = new BitReserve(); + + } + + /** + * Return position of the first audio header. + * + * @return size of ID3v2 tag frames. + */ + public int header_pos() { + return header_pos; + } + + /** + * Load ID3v2 frames. + * + * @param in + * MP3 InputStream. + * @author JavaZOOM + */ + private void loadID3v2(InputStream in) { + int size = -1; + try { + // Read ID3v2 header (10 bytes). + in.mark(10); + size = readID3v2Header(in); + header_pos = size; + } catch (IOException e) { + } finally { + try { + // Unread ID3v2 header (10 bytes). + in.reset(); + } catch (IOException e) { + } + } + // Load ID3v2 tags. + try { + if (size > 0) { + rawid3v2 = new byte[size]; + in.read(rawid3v2, 0, rawid3v2.length); + } + } catch (IOException e) { + } + } + + /** + * Parse ID3v2 tag header to find out size of ID3v2 frames. + * + * @param in + * MP3 InputStream + * @return size of ID3v2 frames + header + * @throws IOException + * @author JavaZOOM + */ + private int readID3v2Header(InputStream in) throws IOException { + byte[] id3header = new byte[4]; + int size = -10; + in.read(id3header, 0, 3); + // Look for ID3v2 + if ((id3header[0] == 'I') && (id3header[1] == 'D') && (id3header[2] == '3')) { + in.read(id3header, 0, 3); + int majorVersion = id3header[0]; + int revision = id3header[1]; + in.read(id3header, 0, 4); + size = + (int) (id3header[0] << 21) + (id3header[1] << 14) + (id3header[2] << 7) + (id3header[3]); + } + return (size + 10); + } + + /** + * Return raw ID3v2 frames + header. + * + * @return ID3v2 InputStream or null if ID3v2 frames are not available. + */ + public InputStream getRawID3v2() { + if (rawid3v2 == null) + return null; + else { + ByteArrayInputStream bain = new ByteArrayInputStream(rawid3v2); + return bain; + } + } + + /** + * Close the Bitstream. + * + * @throws BitstreamException + */ + public void close() throws BitstreamException { + try { + source.close(); + } catch (IOException ex) { + throw newBitstreamException(STREAM_ERROR, ex); + } + } + + /** + * Reads and parses the next frame from the input source. + * + * @return the Header describing details of the frame read, or null if the end + * of the stream has been reached. + */ + public Header readFrame() throws BitstreamException { + + Header result = null; + try { + result = readNextFrame(); + if (result == null) { + return null; + } + // E.B, Parse VBR (if any) first frame. + if (firstframe == true) { + result.parseVBR(frame_bytes); + firstframe = false; + } + + int channels = (header.mode() == Header.SINGLE_CHANNEL) ? 1 : 2; + + result.setSideInfoBuf(getSideInfoBuffer(channels)); + result.setBitReserve(getBitReserve(result.slots())); + + closeFrame(); + + } catch (BitstreamException ex) { + if ((ex.getErrorCode() == INVALIDFRAME)) { + // Try to skip this frame. + // System.out.println("INVALIDFRAME"); + try { + closeFrame(); + result = readNextFrame(); + } catch (BitstreamException e) { + if ((e.getErrorCode() != STREAM_EOF)) { + // wrap original exception so stack trace is maintained. + throw newBitstreamException(e.getErrorCode(), e); + } + } + } else if ((ex.getErrorCode() != STREAM_EOF)) { + // wrap original exception so stack trace is maintained. + throw newBitstreamException(ex.getErrorCode(), ex); + } + } + + return result; + } + + /** + * Read next MP3 frame. + * + * @return MP3 frame header. + * @throws BitstreamException + */ + private Header readNextFrame() throws BitstreamException { + if (framesize == -1) { + if (nextFrame() == -1) { + return null; + } + } + return header; + } + + /** + * Read next MP3 frame. + * + * @throws BitstreamException + */ + private int nextFrame() throws BitstreamException { + // entire frame is read by the header class. + // header.read_header(this, crc); + return header.read_header(this, crc); + } + + /** + * Unreads the bytes read from the frame. + * + * @throws BitstreamException + */ + // REVIEW: add new error codes for this. + public void unreadFrame() throws BitstreamException { + if (wordpointer == -1 && bitindex == -1 && (framesize > 0)) { + try { + source.unread(frame_bytes, 0, framesize); + } catch (IOException ex) { + throw newBitstreamException(STREAM_ERROR); + } + } + } + + /** + * Close MP3 frame. + */ + public void closeFrame() { + framesize = -1; + wordpointer = -1; + bitindex = -1; + } + + /** + * Determines if the next 4 bytes of the stream represent a frame header. + */ + public boolean isSyncCurrentPosition(int syncmode) throws BitstreamException { + int read = readBytes(syncbuf, 0, 4); + int headerstring = + ((syncbuf[0] << 24) & 0xFF000000) | ((syncbuf[1] << 16) & 0x00FF0000) + | ((syncbuf[2] << 8) & 0x0000FF00) | ((syncbuf[3] << 0) & 0x000000FF); + + try { + source.unread(syncbuf, 0, read); + } catch (IOException ex) { + } + + boolean sync = false; + switch (read) { + case 0: + sync = true; + break; + case 4: + sync = isSyncMark(headerstring, syncmode, syncword); + break; + } + + return sync; + } + + // REVIEW: this class should provide inner classes to + // parse the frame contents. Eventually, readBits will + // be removed. + public int readBits(int n) { + return get_bits(n); + } + + public int peek_bits(int number_of_bits) { + + int peekbitindex = bitindex; + int peekPointer = wordpointer; + + int returnvalue = 0; + int sum = peekbitindex + number_of_bits; + + if (peekPointer < 0) { + peekPointer = 0; + } + + if (sum <= 32) { + // all bits contained in *wordpointer + returnvalue = (framebuffer[peekPointer] >>> (32 - sum)) & bitmask[number_of_bits]; + // returnvalue = (wordpointer[0] >> (32 - sum)) & + // bitmask[number_of_bits]; + if ((peekbitindex += number_of_bits) == 32) { + peekbitindex = 0; + peekPointer++; // added by me! + } + return returnvalue; + } + + // E.B : Check that ? + // ((short[])&returnvalue)[0] = ((short[])wordpointer + 1)[0]; + // wordpointer++; // Added by me! + // ((short[])&returnvalue + 1)[0] = ((short[])wordpointer)[0]; + int Right = (framebuffer[peekPointer] & 0x0000FFFF); + peekPointer++; + int Left = (framebuffer[peekPointer] & 0xFFFF0000); + returnvalue = ((Right << 16) & 0xFFFF0000) | ((Left >>> 16) & 0x0000FFFF); + + returnvalue >>>= 48 - sum; // returnvalue >>= 16 - (number_of_bits - (32 + // - bitindex)) + returnvalue &= bitmask[number_of_bits]; + peekbitindex = sum - 32; + return returnvalue; + + } + + public int readCheckedBits(int n) { + // REVIEW: implement CRC check. + return get_bits(n); + } + + protected BitstreamException newBitstreamException(int errorcode) { + return new BitstreamException(errorcode, null); + } + + protected BitstreamException newBitstreamException(int errorcode, Throwable throwable) { + return new BitstreamException(errorcode, throwable); + } + + /** + * Get next 32 bits from bitstream. They are stored in the headerstring. + * syncmod allows Synchro flag ID The returned value is False at the end of + * stream. + */ + + int syncHeader(byte syncmode) throws BitstreamException { + boolean sync; + int headerstring; + // read additional 2 bytes + int bytesRead = readBytes(syncbuf, 0, 3); + + if (bytesRead != 3) + throw newBitstreamException(STREAM_EOF, null); + + headerstring = + ((syncbuf[0] << 16) & 0x00FF0000) | ((syncbuf[1] << 8) & 0x0000FF00) + | ((syncbuf[2] << 0) & 0x000000FF); + + do { + headerstring <<= 8; + + if (readBytes(syncbuf, 3, 1) != 1) { + // System.out.println("THROW NEW BITSTREAM EXCEPTION"); + return -1; + throw newBitstreamException(STREAM_EOF, null); + } + + headerstring |= (syncbuf[3] & 0x000000FF); + + sync = isSyncMark(headerstring, syncmode, syncword); + } while (!sync); + + // current_frame_number++; + // if (last_frame_number < current_frame_number) last_frame_number = + // current_frame_number; + + return headerstring; + } + + public boolean isSyncMark(int headerstring, int syncmode, int word) { + boolean sync = false; + + if (syncmode == INITIAL_SYNC) { + // sync = ((headerstring & 0xFFF00000) == 0xFFF00000); + sync = ((headerstring & 0xFFE00000) == 0xFFE00000); // SZD: MPEG 2.5 + } else { + sync = + ((headerstring & 0xFFF80C00) == word) + && (((headerstring & 0x000000C0) == 0x000000C0) == single_ch_mode); + } + + // filter out invalid sample rate + if (sync) + sync = (((headerstring >>> 10) & 3) != 3); + // filter out invalid layer + if (sync) + sync = (((headerstring >>> 17) & 3) != 0); + // filter out invalid version + if (sync) + sync = (((headerstring >>> 19) & 3) != 1); + + return sync; + } + + /** + * Reads the data for the next frame. The frame is not parsed until parse + * frame is called. + */ + int read_frame_data(int bytesize) throws BitstreamException { + int numread = 0; + numread = readFully(frame_bytes, 0, bytesize); + framesize = bytesize; + wordpointer = -1; + bitindex = -1; + return numread; + } + + /** + * Parses the data previously read with read_frame_data(). + */ + @LATTICE("GLOBAL>> (32 - sum)) & bitmask[number_of_bits]; + // returnvalue = (wordpointer[0] >> (32 - sum)) & bitmask[number_of_bits]; + if ((bitindex += number_of_bits) == 32) { + bitindex = 0; + wordpointer++; // added by me! + } + return returnvalue; + } + + // E.B : Check that ? + // ((short[])&returnvalue)[0] = ((short[])wordpointer + 1)[0]; + // wordpointer++; // Added by me! + // ((short[])&returnvalue + 1)[0] = ((short[])wordpointer)[0]; + @LOC("RL") int Right = (framebuffer[wordpointer] & 0x0000FFFF); + wordpointer++; + @LOC("RL") int Left = (framebuffer[wordpointer] & 0xFFFF0000); + returnvalue = ((Right << 16) & 0xFFFF0000) | ((Left >>> 16) & 0x0000FFFF); + + returnvalue >>>= 48 - sum; // returnvalue >>= 16 - (number_of_bits - (32 - + // bitindex)) + returnvalue &= bitmask[number_of_bits]; + bitindex = sum - 32; + return returnvalue; + } + + /** + * Set the word we want to sync the header to. In Big-Endian byte order + */ + void set_syncword(@LOC("IN") int syncword0) { + syncword = syncword0 & 0xFFFFFF3F; + single_ch_mode = ((syncword0 & 0x000000C0) == 0x000000C0); + } + + /** + * Reads the exact number of bytes from the source input stream into a byte + * array. + * + * @param b + * The byte array to read the specified number of bytes into. + * @param offs + * The index in the array where the first byte read should be stored. + * @param len + * the number of bytes to read. + * + * @exception BitstreamException + * is thrown if the specified number of bytes could not be read + * from the stream. + */ + @LATTICE("OUT 0) { + @LOC("IN") int bytesread = source.read(b, offs, len); + if (bytesread == -1) { + while (len-- > 0) { + b[offs++] = 0; + } + break; + // throw newBitstreamException(UNEXPECTED_EOF, new EOFException()); + } + nRead = nRead + bytesread; + offs += bytesread; + len -= bytesread; + } + } catch (IOException ex) { + throw newBitstreamException(STREAM_ERROR, ex); + } + return nRead; + } + + /** + * Simlar to readFully, but doesn't throw exception when EOF is reached. + */ + @LATTICE("OUT 0) { + @LOC("IN") int bytesread = source.read(b, offs, len); + if (bytesread == -1) { + break; + } + totalBytesRead += bytesread; + offs += bytesread; + len -= bytesread; + } + } catch (IOException ex) { + throw newBitstreamException(STREAM_ERROR, ex); + } + return totalBytesRead; + } + + public SideInfoBuffer getSideInfoBuffer(int channelType) { + + if (wordpointer < 0) + wordpointer = 0; + + SideInfoBuffer sib = new SideInfoBuffer(); + + // first, store main_data_begin from the side inforamtion + main_data_begin = peek_bits(9); + + int max; + if (channelType == 1) { // mono + max = wordpointer + 4; + } else { + max = wordpointer + 8; + } + + try { + for (; wordpointer < max; wordpointer++) { + sib.setBuffer(wordpointer, framebuffer[wordpointer]); + } + } catch (ArrayIndexOutOfBoundsException e) { + System.out.print("wordpointer=" + wordpointer); + System.out.println("framebuffer length=" + framebuffer.length); + } + + return sib; + } + + public BitReserve getBitReserve(int nSlots) { + + int flush_main; + int bytes_to_discard; + int i; + + for (i = 0; i < nSlots; i++) + br.hputbuf(get_bits(8)); + + int main_data_end = br.hsstell() >>> 3; // of previous frame + + if ((flush_main = (br.hsstell() & 7)) != 0) { + br.hgetbits(8 - flush_main); + main_data_end++; + } + + bytes_to_discard = frame_start - main_data_end - main_data_begin; + + frame_start += nSlots; + + if (bytes_to_discard < 0) { + return null; + } + + if (main_data_end > 4096) { + frame_start -= 4096; + br.rewindNbytes(4096); + } + + for (; bytes_to_discard > 0; bytes_to_discard--) + br.hgetbits(8); + + return br; + } +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/BitstreamErrors.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/BitstreamErrors.java new file mode 100644 index 00000000..07114dbf --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/BitstreamErrors.java @@ -0,0 +1,70 @@ +/* + * 11/19/04 1.0 moved to LGPL. + * 11/17/04 INVALIDFRAME code added. javalayer@javazoom.net + * 12/12/99 Initial version. mdm@techie.com + *----------------------------------------------------------------------- + * 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. + *---------------------------------------------------------------------- + */ + +/** + * This interface describes all error codes that can be thrown + * in BistreamExceptions. + * + * @see BitstreamException + * + * @author MDM 12/12/99 + * @since 0.0.6 + */ + +public interface BitstreamErrors extends JavaLayerErrors +{ + + /** + * An undeterminable error occurred. + */ + static public final int UNKNOWN_ERROR = BITSTREAM_ERROR + 0; + + /** + * The header describes an unknown sample rate. + */ + static public final int UNKNOWN_SAMPLE_RATE = BITSTREAM_ERROR + 1; + + /** + * A problem occurred reading from the stream. + */ + static public final int STREAM_ERROR = BITSTREAM_ERROR + 2; + + /** + * The end of the stream was reached prematurely. + */ + static public final int UNEXPECTED_EOF = BITSTREAM_ERROR + 3; + + /** + * The end of the stream was reached. + */ + static public final int STREAM_EOF = BITSTREAM_ERROR + 4; + + /** + * Frame data are missing. + */ + static public final int INVALIDFRAME = BITSTREAM_ERROR + 5; + + /** + * + */ + static public final int BITSTREAM_LAST = 0x1ff; + +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/BitstreamException.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/BitstreamException.java new file mode 100644 index 00000000..fb2e60c7 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/BitstreamException.java @@ -0,0 +1,70 @@ +/* + * 11/19/04 1.0 moved to LGPL. + * 12/12/99 Initial version. mdm@techie.com + *----------------------------------------------------------------------- + * 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. + *---------------------------------------------------------------------- + */ + +/** + * Instances of BitstreamException are thrown + * when operations on a Bitstream fail. + *

+ * The exception provides details of the exception condition + * in two ways: + *

  1. + * as an error-code describing the nature of the error + *


  2. + * as the Throwable instance, if any, that was thrown + * indicating that an exceptional condition has occurred. + *

+ * + * @since 0.0.6 + * @author MDM 12/12/99 + */ +@LATTICE("E") +public class BitstreamException extends JavaLayerException + implements BitstreamErrors +{ + @LOC("E") private int errorcode = UNKNOWN_ERROR; + + public BitstreamException(String msg, Throwable t) + { + super(msg, t); + } + + public BitstreamException(int errorcode, Throwable t) + { + this(getErrorString(errorcode), t); + this.errorcode = errorcode; + } + + public int getErrorCode() + { + return errorcode; + } + + + static public String getErrorString(int errorcode) + { + // REVIEW: use resource bundle to map error codes + // to locale-sensitive strings. + +// return "Bitstream errorcode "+Integer.toHexString(errorcode); + return "Bitstream errorcode "+errorcode; + } + + +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/BitstreamWrapper.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/BitstreamWrapper.java new file mode 100644 index 00000000..6a3209d1 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/BitstreamWrapper.java @@ -0,0 +1,17 @@ +public class BitstreamWrapper { + + private static Bitstream stream; + + @TRUST + public static void init(String filename) { + FileInputStream fin = new FileInputStream(filename); + BufferedInputStream bin = new BufferedInputStream(fin); + stream = new Bitstream(bin); + } + + @TRUST + public static Header readFrame() { + return stream.readFrame(); + } + +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/Control.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/Control.java new file mode 100644 index 00000000..c677b5fd --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/Control.java @@ -0,0 +1,55 @@ +/* + * 11/19/04 1.0 moved to LGPL. + *----------------------------------------------------------------------- + * 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. + *---------------------------------------------------------------------- + */ + +/** + * Work in progress. + */ + +public interface Control +{ + + /** + * Starts playback of the media presented by this control. + */ + public void start(); + + /** + * Stops playback of the media presented by this control. + */ + public void stop(); + + public boolean isPlaying(); + + public void pause(); + + + public boolean isRandomAccess(); + + /** + * Retrieves the current position. + */ + public double getPosition(); + + /** + * + */ + public void setPosition(double d); + + +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/Crc16.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/Crc16.java new file mode 100644 index 00000000..20c32d86 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/Crc16.java @@ -0,0 +1,75 @@ +/* + * 11/19/04 : 1.0 moved to LGPL. + * + * 02/12/99 : Java Conversion by E.B , javalayer@javazoom.net + * + * @(#) crc.h 1.5, last edit: 6/15/94 16:55:32 + * @(#) Copyright (C) 1993, 1994 Tobias Bading (bading@cs.tu-berlin.de) + * @(#) Berlin University of Technology + *----------------------------------------------------------------------- + * 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. + *---------------------------------------------------------------------- + */ + +/** + * 16-Bit CRC checksum + */ +@LATTICE("B>>= 1) != 0); + } + + /** + * Return the calculated checksum. + * Erase it for next calls to add_bits(). + */ + @RETURNLOC("OUT") + public short checksum() + { + @LOC("OUT") short sum = crc; + crc = (short) 0xFFFF; + return sum; + } +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/Decoder.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/Decoder.java new file mode 100644 index 00000000..12287b1c --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/Decoder.java @@ -0,0 +1,296 @@ +/* + * 11/19/04 1.0 moved to LGPL. + * 01/12/99 Initial version. mdm@techie.com + *----------------------------------------------------------------------- + * 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. + *---------------------------------------------------------------------- + */ + +/** + * The Decoder class encapsulates the details of decoding an MPEG + * audio frame. + * + * @author MDM + * @version 0.0.7 12/12/99 + * @since 0.0.5 + */ +@LATTICE("OUTDecoder instance with default parameters. + */ + + public Decoder() { + this(null); + } + + /** + * Creates a new Decoder instance with default parameters. + * + * @param params + * The Params instance that describes the customizable + * aspects of the decoder. + */ + public Decoder(@DELEGATE Params params0) { + + if (params0 == null) { + params0 = getDefaultParams(); + } + + params = params0; + + Equalizer eq = params.getInitialEqualizerSettings(); + if (eq != null) { + equalizer.setFrom(eq); + } + } + + static public Params getDefaultParams() { + return (Params) DEFAULT_PARAMS.clone(); + } + + // public void setEqualizer(Equalizer eq) { + // if (eq == null) + // eq = Equalizer.PASS_THRU_EQ; + // + // equalizer.setFrom(eq); + // + // float[] factors = equalizer.getBandFactors(); + // + // if (filter1 != null) + // filter1.setEQ(factors); + // + // if (filter2 != null) + // filter2.setEQ(factors); + // } + @LATTICE("THISParams class presents the customizable aspects of the + * decoder. + *

+ * Instances of this class are not thread safe. + */ + public static class Params implements Cloneable { + + // private OutputChannels outputChannels = OutputChannels.BOTH; + private OutputChannels outputChannels = new OutputChannels(0); + + private Equalizer equalizer = new Equalizer(); + + public Params() { + } + + public Object clone() { + // TODO: need to have better clone method + Params clone = new Params(); + clone.outputChannels = new OutputChannels(outputChannels.getChannelsOutputCode()); + clone.equalizer = new Equalizer(); + return clone; + // try + // { + // return super.clone(); + // } + // catch (CloneNotSupportedException ex) + // { + // throw new InternalError(this+": "+ex); + // } + } + + public void setOutputChannels(OutputChannels out) { + if (out == null) + throw new NullPointerException("out"); + + outputChannels = out; + } + + public OutputChannels getOutputChannels() { + return outputChannels; + } + + /** + * Retrieves the equalizer settings that the decoder's equalizer will be + * initialized from. + *

+ * The Equalizer instance returned cannot be changed in real + * time to affect the decoder output as it is used only to initialize the + * decoders EQ settings. To affect the decoder's output in realtime, use the + * Equalizer returned from the getEqualizer() method on the decoder. + * + * @return The Equalizer used to initialize the EQ settings of + * the decoder. + */ + public Equalizer getInitialEqualizerSettings() { + return equalizer; + } + + }; +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/DecoderErrors.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/DecoderErrors.java new file mode 100644 index 00000000..ef3552ad --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/DecoderErrors.java @@ -0,0 +1,44 @@ +/* + * 09/26/08 throw exception on subbband alloc error: Christopher G. Jennings (cjennings@acm.org) + * 11/19/04 1.0 moved to LGPL. + * 01/12/99 Initial version. mdm@techie.com + *----------------------------------------------------------------------- + * 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. + *---------------------------------------------------------------------- + */ + + +/** + * This interface provides constants describing the error + * codes used by the Decoder to indicate errors. + * + * @author MDM + */ +public interface DecoderErrors extends JavaLayerErrors +{ + + static public final int UNKNOWN_ERROR = DECODER_ERROR + 0; + + /** + * Layer not supported by the decoder. + */ + static public final int UNSUPPORTED_LAYER = DECODER_ERROR + 1; + + /** + * Illegal allocation in subband layer. Indicates a corrupt stream. + */ + static public final int ILLEGAL_SUBBAND_ALLOCATION = DECODER_ERROR + 2; + +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/DecoderException.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/DecoderException.java new file mode 100644 index 00000000..d33b0f09 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/DecoderException.java @@ -0,0 +1,61 @@ +/* + * 11/19/04 1.0 moved to LGPL. + * 01/12/99 Initial version. mdm@techie.com + *----------------------------------------------------------------------- + * 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. + *---------------------------------------------------------------------- + */ + + +/** + * The DecoderException represents the class of + * errors that can occur when decoding MPEG audio. + * + * @author MDM + */ +public class DecoderException extends JavaLayerException + implements DecoderErrors +{ + private int errorcode = UNKNOWN_ERROR; + + public DecoderException(String msg, Throwable t) + { + super(msg, t); + } + + public DecoderException(int errorcode, Throwable t) + { + this(getErrorString(errorcode), t); + this.errorcode = errorcode; + } + + public int getErrorCode() + { + return errorcode; + } + + + static public String getErrorString(int errorcode) + { + // REVIEW: use resource file to map error codes + // to locale-sensitive strings. + +// return "Decoder errorcode "+Integer.toHexString(errorcode); + return "Decoder errorcode "+errorcode; + } + + +} + diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/Equalizer.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/Equalizer.java new file mode 100644 index 00000000..90182cc8 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/Equalizer.java @@ -0,0 +1,200 @@ +/* + * 11/19/04 1.0 moved to LGPL. + * 12/12/99 Initial version. mdm@techie.com + *----------------------------------------------------------------------- + * 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. + *---------------------------------------------------------------------- + */ + +/** + * The Equalizer class can be used to specify equalization settings + * for the MPEG audio decoder. + *

+ * The equalizer consists of 32 band-pass filters. Each band of the equalizer + * can take on a fractional value between -1.0 and +1.0. At -1.0, the input + * signal is attenuated by 6dB, at +1.0 the signal is amplified by 6dB. + * + * @see Decoder + * + * @author MDM + */ +@LATTICE("BEqualizer instance. + */ + public Equalizer() { + } + + // private Equalizer(float b1, float b2, float b3, float b4, float b5, + // float b6, float b7, float b8, float b9, float b10, float b11, + // float b12, float b13, float b14, float b15, float b16, + // float b17, float b18, float b19, float b20); + + public Equalizer(float[] settings) { + setFrom(settings); + } + + public Equalizer(EQFunction eq) { + setFrom(eq); + } + + public void setFrom(float[] eq) { + reset(); + int max = (eq.length > BANDS) ? BANDS : eq.length; + + for (int i = 0; i < max; i++) { + settings[i] = limit(eq[i]); + } + } + + public void setFrom(EQFunction eq) { + reset(); + int max = BANDS; + + for (int i = 0; i < max; i++) { + settings[i] = limit(eq.getBand(i)); + } + } + + /** + * Sets the bands of this equalizer to the value the bands of another + * equalizer. Bands that are not present in both equalizers are ignored. + */ + public void setFrom(Equalizer eq) { + if (eq != this) { + setFrom(eq.settings); + } + } + + /** + * Sets all bands to 0.0 + */ + public void reset() { + for (int i = 0; i < BANDS; i++) { + settings[i] = 0.0f; + } + } + + /** + * Retrieves the number of bands present in this equalizer. + */ + public int getBandCount() { + return settings.length; + } + + public float setBand(int band, float neweq) { + float eq = 0.0f; + + if ((band >= 0) && (band < BANDS)) { + eq = settings[band]; + settings[band] = limit(neweq); + } + + return eq; + } + + /** + * Retrieves the eq setting for a given band. + */ + public float getBand(int band) { + float eq = 0.0f; + + if ((band >= 0) && (band < BANDS)) { + eq = settings[band]; + } + + return eq; + } + + private float limit(float eq) { + if (eq == BAND_NOT_PRESENT) + return eq; + if (eq > 1.0f) + return 1.0f; + if (eq < -1.0f) + return -1.0f; + + return eq; + } + + /** + * Retrieves an array of floats whose values represent a scaling factor that + * can be applied to linear samples in each band to provide the equalization + * represented by this instance. + * + * @return an array of factors that can be applied to the subbands. + */ + @LATTICE("OUT>> 19) & 1); + if (((headerstring >>> 20) & 1) == 0) // SZD: MPEG2.5 detection + if (h_version == MPEG2_LSF) + h_version = MPEG25_LSF; + else + throw stream.newBitstreamException(Bitstream.UNKNOWN_ERROR); + if ((h_sample_frequency = ((headerstring >>> 10) & 3)) == 3) { + throw stream.newBitstreamException(Bitstream.UNKNOWN_ERROR); + } + } + h_layer = 4 - (headerstring >>> 17) & 3; + h_protection_bit = (headerstring >>> 16) & 1; + h_bitrate_index = (headerstring >>> 12) & 0xF; + h_padding_bit = (headerstring >>> 9) & 1; + h_mode = ((headerstring >>> 6) & 3); + h_mode_extension = (headerstring >>> 4) & 3; + if (h_mode == JOINT_STEREO) + h_intensity_stereo_bound = (h_mode_extension << 2) + 4; + else + h_intensity_stereo_bound = 0; // should never be used + if (((headerstring >>> 3) & 1) == 1) + h_copyright = true; + if (((headerstring >>> 2) & 1) == 1) + h_original = true; + // calculate number of subbands: + if (h_layer == 1) + h_number_of_subbands = 32; + else { + channel_bitrate = h_bitrate_index; + // calculate bitrate per channel: + if (h_mode != SINGLE_CHANNEL) + if (channel_bitrate == 4) + channel_bitrate = 1; + else + channel_bitrate -= 4; + if ((channel_bitrate == 1) || (channel_bitrate == 2)) + if (h_sample_frequency == THIRTYTWO) + h_number_of_subbands = 12; + else + h_number_of_subbands = 8; + else if ((h_sample_frequency == FOURTYEIGHT) + || ((channel_bitrate >= 3) && (channel_bitrate <= 5))) + h_number_of_subbands = 27; + else + h_number_of_subbands = 30; + } + if (h_intensity_stereo_bound > h_number_of_subbands) + h_intensity_stereo_bound = h_number_of_subbands; + // calculate framesize and nSlots + calculate_framesize(); + // read framedata: + int framesizeloaded = stream.read_frame_data(framesize); + if ((framesize >= 0) && (framesizeloaded != framesize)) { + // Data loaded does not match to expected framesize, + // it might be an ID3v1 TAG. (Fix 11/17/04). + throw stream.newBitstreamException(Bitstream.INVALIDFRAME); + } + if (stream.isSyncCurrentPosition(syncmode)) { + if (syncmode == Bitstream.INITIAL_SYNC) { + syncmode = Bitstream.STRICT_SYNC; + stream.set_syncword(headerstring & 0xFFF80CC0); + } + sync = true; + } else { + stream.unreadFrame(); + } + } while (!sync); + stream.parse_frame(); + if (h_protection_bit == 0) { + // frame contains a crc checksum + checksum = (short) stream.get_bits(16); + if (crc == null) + crc = new Crc16(); + crc.add_bits(headerstring, 16); + crcp[0] = crc; + } else + crcp[0] = null; + if (h_sample_frequency == FOURTYFOUR_POINT_ONE) { + /* + * if (offset == null) { int max = max_number_of_frames(stream); offset = + * new int[max]; for(int i=0; i 0) && (cf == lf)) { offset[cf] = + * offset[cf-1] + h_padding_bit; } else { offset[0] = h_padding_bit; } + */ + } + return 0; + } + + /** + * Parse frame to extract optionnal VBR frame. + * + * @param firstframe + * @author E.B (javalayer@javazoom.net) + */ + void parseVBR(byte[] firstframe) throws BitstreamException { + // Trying Xing header. + String xing = "Xing"; + byte tmp[] = new byte[4]; + int offset = 0; + // Compute "Xing" offset depending on MPEG version and channels. + if (h_version == MPEG1) { + if (h_mode == SINGLE_CHANNEL) + offset = 21 - 4; + else + offset = 36 - 4; + } else { + if (h_mode == SINGLE_CHANNEL) + offset = 13 - 4; + else + offset = 21 - 4; + } + try { + System.arraycopy(firstframe, offset, tmp, 0, 4); + // Is "Xing" ? + if (xing.equals(new String(tmp))) { + // Yes. + h_vbr = true; + h_vbr_frames = -1; + h_vbr_bytes = -1; + h_vbr_scale = -1; + h_vbr_toc = new byte[100]; + + int length = 4; + // Read flags. + byte flags[] = new byte[4]; + System.arraycopy(firstframe, offset + length, flags, 0, flags.length); + length += flags.length; + // Read number of frames (if available). + if ((flags[3] & (byte) (1 << 0)) != 0) { + System.arraycopy(firstframe, offset + length, tmp, 0, tmp.length); + h_vbr_frames = + (tmp[0] << 24) & 0xFF000000 | (tmp[1] << 16) & 0x00FF0000 | (tmp[2] << 8) + & 0x0000FF00 | tmp[3] & 0x000000FF; + length += 4; + } + // Read size (if available). + if ((flags[3] & (byte) (1 << 1)) != 0) { + System.arraycopy(firstframe, offset + length, tmp, 0, tmp.length); + h_vbr_bytes = + (tmp[0] << 24) & 0xFF000000 | (tmp[1] << 16) & 0x00FF0000 | (tmp[2] << 8) + & 0x0000FF00 | tmp[3] & 0x000000FF; + length += 4; + } + // Read TOC (if available). + if ((flags[3] & (byte) (1 << 2)) != 0) { + System.arraycopy(firstframe, offset + length, h_vbr_toc, 0, h_vbr_toc.length); + length += h_vbr_toc.length; + } + // Read scale (if available). + if ((flags[3] & (byte) (1 << 3)) != 0) { + System.arraycopy(firstframe, offset + length, tmp, 0, tmp.length); + h_vbr_scale = + (tmp[0] << 24) & 0xFF000000 | (tmp[1] << 16) & 0x00FF0000 | (tmp[2] << 8) + & 0x0000FF00 | tmp[3] & 0x000000FF; + length += 4; + } + // System.out.println("VBR:"+xing+" Frames:"+ h_vbr_frames + // +" Size:"+h_vbr_bytes); + } + } catch (ArrayIndexOutOfBoundsException e) { + throw new BitstreamException("XingVBRHeader Corrupted", e); + } + + // Trying VBRI header. + String vbri = "VBRI"; + offset = 36 - 4; + try { + System.arraycopy(firstframe, offset, tmp, 0, 4); + // Is "VBRI" ? + if (vbri.equals(new String(tmp))) { + // Yes. + h_vbr = true; + h_vbr_frames = -1; + h_vbr_bytes = -1; + h_vbr_scale = -1; + h_vbr_toc = new byte[100]; + // Bytes. + int length = 4 + 6; + System.arraycopy(firstframe, offset + length, tmp, 0, tmp.length); + h_vbr_bytes = + (tmp[0] << 24) & 0xFF000000 | (tmp[1] << 16) & 0x00FF0000 | (tmp[2] << 8) & 0x0000FF00 + | tmp[3] & 0x000000FF; + length += 4; + // Frames. + System.arraycopy(firstframe, offset + length, tmp, 0, tmp.length); + h_vbr_frames = + (tmp[0] << 24) & 0xFF000000 | (tmp[1] << 16) & 0x00FF0000 | (tmp[2] << 8) & 0x0000FF00 + | tmp[3] & 0x000000FF; + length += 4; + // System.out.println("VBR:"+vbri+" Frames:"+ h_vbr_frames + // +" Size:"+h_vbr_bytes); + // TOC + // TODO + } + } catch (ArrayIndexOutOfBoundsException e) { + throw new BitstreamException("VBRIVBRHeader Corrupted", e); + } + } + + // Functions to query header contents: + /** + * Returns version. + */ + @RETURNLOC("THIS,Header.HV") + public int version() { + return h_version; + } + + /** + * Returns Layer ID. + */ + @RETURNLOC("THIS,Header.H") + public int layer() { + return h_layer; + } + + /** + * Returns bitrate index. + */ + public int bitrate_index() { + return h_bitrate_index; + } + + /** + * Returns Sample Frequency. + */ + @RETURNLOC("THIS,Header.H") + public int sample_frequency() { + return h_sample_frequency; + } + + /** + * Returns Frequency. + */ + @RETURNLOC("THIS,Header.FS") + public int frequency() { + return frequencies[h_version][h_sample_frequency]; + } + + /** + * Returns Mode. + */ + @RETURNLOC("THIS,Header.H") + public int mode() { + return h_mode; + } + + /** + * Returns Protection bit. + */ + @RETURNLOC("THIS,Header.H") + public boolean checksums() { + if (h_protection_bit == 0) + return true; + else + return false; + } + + /** + * Returns Copyright. + */ + public boolean copyright() { + return h_copyright; + } + + /** + * Returns Original. + */ + public boolean original() { + return h_original; + } + + /** + * Return VBR. + * + * @return true if VBR header is found + */ + public boolean vbr() { + return h_vbr; + } + + /** + * Return VBR scale. + * + * @return scale of -1 if not available + */ + public int vbr_scale() { + return h_vbr_scale; + } + + /** + * Return VBR TOC. + * + * @return vbr toc ot null if not available + */ + public byte[] vbr_toc() { + return h_vbr_toc; + } + + /** + * Returns Checksum flag. Compares computed checksum with stream checksum. + */ + @RETURNLOC("OUT") + public boolean checksum_ok() { + return (checksum == crc.checksum()); + } + + // Seeking and layer III stuff + /** + * Returns Layer III Padding bit. + */ + public boolean padding() { + if (h_padding_bit == 0) + return false; + else + return true; + } + + /** + * Returns Slots. + */ + @RETURNLOC("THIS,Header.NS") + public int slots() { + return nSlots; + } + + /** + * Returns Mode Extension. + */ + @RETURNLOC("THIS,Header.H") + public int mode_extension() { + return h_mode_extension; + } + + // E.B -> private to public + public static final int bitrates[][][] = { + { + { 0 /* free format */, 32000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 144000, + 160000, 176000, 192000, 224000, 256000, 0 }, + { 0 /* free format */, 8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 80000, + 96000, 112000, 128000, 144000, 160000, 0 }, + { 0 /* free format */, 8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 80000, + 96000, 112000, 128000, 144000, 160000, 0 } }, + + { + { 0 /* free format */, 32000, 64000, 96000, 128000, 160000, 192000, 224000, 256000, + 288000, 320000, 352000, 384000, 416000, 448000, 0 }, + { 0 /* free format */, 32000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 160000, + 192000, 224000, 256000, 320000, 384000, 0 }, + { 0 /* free format */, 32000, 40000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, + 160000, 192000, 224000, 256000, 320000, 0 } }, + // SZD: MPEG2.5 + { + { 0 /* free format */, 32000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 144000, + 160000, 176000, 192000, 224000, 256000, 0 }, + { 0 /* free format */, 8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 80000, + 96000, 112000, 128000, 144000, 160000, 0 }, + { 0 /* free format */, 8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 80000, + 96000, 112000, 128000, 144000, 160000, 0 } }, + + }; + + // E.B -> private to public + /** + * Calculate Frame size. Calculates framesize in bytes excluding header size. + */ + public int calculate_framesize() { + + if (h_layer == 1) { + framesize = + (12 * bitrates[h_version][0][h_bitrate_index]) + / frequencies[h_version][h_sample_frequency]; + if (h_padding_bit != 0) + framesize++; + framesize <<= 2; // one slot is 4 bytes long + nSlots = 0; + } else { + framesize = + (144 * bitrates[h_version][h_layer - 1][h_bitrate_index]) + / frequencies[h_version][h_sample_frequency]; + if (h_version == MPEG2_LSF || h_version == MPEG25_LSF) + framesize >>= 1; // SZD + if (h_padding_bit != 0) + framesize++; + // Layer III slots + if (h_layer == 3) { + if (h_version == MPEG1) { + nSlots = framesize - ((h_mode == SINGLE_CHANNEL) ? 17 : 32) // side + // info + // size + - ((h_protection_bit != 0) ? 0 : 2) // CRC size + - 4; // header size + } else { // MPEG-2 LSF, SZD: MPEG-2.5 LSF + nSlots = framesize - ((h_mode == SINGLE_CHANNEL) ? 9 : 17) // side + // info + // size + - ((h_protection_bit != 0) ? 0 : 2) // CRC size + - 4; // header size + } + } else { + nSlots = 0; + } + } + framesize -= 4; // subtract header size + return framesize; + } + + /** + * Returns the maximum number of frames in the stream. + * + * @param streamsize + * @return number of frames + */ + public int max_number_of_frames(int streamsize) // E.B + { + if (h_vbr == true) + return h_vbr_frames; + else { + if ((framesize + 4 - h_padding_bit) == 0) + return 0; + else + return (streamsize / (framesize + 4 - h_padding_bit)); + } + } + + /** + * Returns the maximum number of frames in the stream. + * + * @param streamsize + * @return number of frames + */ + public int min_number_of_frames(int streamsize) // E.B + { + if (h_vbr == true) + return h_vbr_frames; + else { + if ((framesize + 5 - h_padding_bit) == 0) + return 0; + else + return (streamsize / (framesize + 5 - h_padding_bit)); + } + } + + /** + * Returns ms/frame. + * + * @return milliseconds per frame + */ + @LATTICE("OUT private to public + public static final String bitrate_str[][][] = { + { + { "free format", "32 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s", "80 kbit/s", + "96 kbit/s", "112 kbit/s", "128 kbit/s", "144 kbit/s", "160 kbit/s", "176 kbit/s", + "192 kbit/s", "224 kbit/s", "256 kbit/s", "forbidden" }, + { "free format", "8 kbit/s", "16 kbit/s", "24 kbit/s", "32 kbit/s", "40 kbit/s", + "48 kbit/s", "56 kbit/s", "64 kbit/s", "80 kbit/s", "96 kbit/s", "112 kbit/s", + "128 kbit/s", "144 kbit/s", "160 kbit/s", "forbidden" }, + { "free format", "8 kbit/s", "16 kbit/s", "24 kbit/s", "32 kbit/s", "40 kbit/s", + "48 kbit/s", "56 kbit/s", "64 kbit/s", "80 kbit/s", "96 kbit/s", "112 kbit/s", + "128 kbit/s", "144 kbit/s", "160 kbit/s", "forbidden" } }, + + { + { "free format", "32 kbit/s", "64 kbit/s", "96 kbit/s", "128 kbit/s", "160 kbit/s", + "192 kbit/s", "224 kbit/s", "256 kbit/s", "288 kbit/s", "320 kbit/s", "352 kbit/s", + "384 kbit/s", "416 kbit/s", "448 kbit/s", "forbidden" }, + { "free format", "32 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s", "80 kbit/s", + "96 kbit/s", "112 kbit/s", "128 kbit/s", "160 kbit/s", "192 kbit/s", "224 kbit/s", + "256 kbit/s", "320 kbit/s", "384 kbit/s", "forbidden" }, + { "free format", "32 kbit/s", "40 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s", + "80 kbit/s", "96 kbit/s", "112 kbit/s", "128 kbit/s", "160 kbit/s", "192 kbit/s", + "224 kbit/s", "256 kbit/s", "320 kbit/s", "forbidden" } }, + // SZD: MPEG2.5 + { + { "free format", "32 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s", "80 kbit/s", + "96 kbit/s", "112 kbit/s", "128 kbit/s", "144 kbit/s", "160 kbit/s", "176 kbit/s", + "192 kbit/s", "224 kbit/s", "256 kbit/s", "forbidden" }, + { "free format", "8 kbit/s", "16 kbit/s", "24 kbit/s", "32 kbit/s", "40 kbit/s", + "48 kbit/s", "56 kbit/s", "64 kbit/s", "80 kbit/s", "96 kbit/s", "112 kbit/s", + "128 kbit/s", "144 kbit/s", "160 kbit/s", "forbidden" }, + { "free format", "8 kbit/s", "16 kbit/s", "24 kbit/s", "32 kbit/s", "40 kbit/s", + "48 kbit/s", "56 kbit/s", "64 kbit/s", "80 kbit/s", "96 kbit/s", "112 kbit/s", + "128 kbit/s", "144 kbit/s", "160 kbit/s", "forbidden" } }, }; + + /** + * Return Bitrate. + * + * @return bitrate in bps + */ + + @RETURNLOC("THIS,Header.FS") + public String bitrate_string() { + @LOC("THIS,Header.T") String kbs = " kb/s"; + if (h_vbr == true) { + return Integer.toString(bitrate() / 1000) + kbs; + } else { + return bitrate_str[h_version][h_layer - 1][h_bitrate_index]; + } + } + + /** + * Return Bitrate. + * + * @return bitrate in bps and average bitrate for VBR header + */ + @RETURNLOC("THIS,Header.FS") + public int bitrate() { + if (h_vbr == true) { + return ((int) ((h_vbr_bytes * 8) / (ms_per_frame() * h_vbr_frames))) * 1000; + } else { + return bitrates[h_version][h_layer - 1][h_bitrate_index]; + } + } + + /** + * Return Instant Bitrate. Bitrate for VBR is not constant. + * + * @return bitrate in bps + */ + public int bitrate_instant() { + return bitrates[h_version][h_layer - 1][h_bitrate_index]; + } + + /** + * Returns Frequency + * + * @return frequency string in kHz + */ + @RETURNLOC("THIS,Header.FS") + public String sample_frequency_string() { + switch (h_sample_frequency) { + case THIRTYTWO: + if (h_version == MPEG1) + return "32 kHz"; + else if (h_version == MPEG2_LSF) + return "16 kHz"; + else + // SZD + return "8 kHz"; + case FOURTYFOUR_POINT_ONE: + if (h_version == MPEG1) + return "44.1 kHz"; + else if (h_version == MPEG2_LSF) + return "22.05 kHz"; + else + // SZD + return "11.025 kHz"; + case FOURTYEIGHT: + if (h_version == MPEG1) + return "48 kHz"; + else if (h_version == MPEG2_LSF) + return "24 kHz"; + else + // SZD + return "12 kHz"; + } + return (null); + } + + /** + * Returns Mode. + */ + @RETURNLOC("THIS,Header.H") + public String mode_string() { + switch (h_mode) { + case STEREO: + return "Stereo"; + case JOINT_STEREO: + return "Joint stereo"; + case DUAL_CHANNEL: + return "Dual channel"; + case SINGLE_CHANNEL: + return "Single channel"; + } + return null; + } + + /** + * Returns Version. + * + * @return MPEG-1 or MPEG-2 LSF or MPEG-2.5 LSF + */ + @RETURNLOC("THIS,Header.HV") + public String version_string() { + switch (h_version) { + case MPEG1: + return "MPEG-1"; + case MPEG2_LSF: + return "MPEG-2 LSF"; + case MPEG25_LSF: // SZD + return "MPEG-2.5 LSF"; + } + return (null); + } + + /** + * Returns the number of subbands in the current frame. + * + * @return number of subbands + */ + public int number_of_subbands() { + return h_number_of_subbands; + } + + /** + * Returns Intensity Stereo. (Layer II joint stereo only). Returns the number + * of subbands which are in stereo mode, subbands above that limit are in + * intensity stereo mode. + * + * @return intensity + */ + public int intensity_stereo_bound() { + return h_intensity_stereo_bound; + } + + public void setSideInfoBuf(SideInfoBuffer sib) { + this.sib = sib; + } + + public void setBitReserve(BitReserve br) { + this.br = br; + } + + @RETURNLOC("THIS,Header.T") + public SideInfoBuffer getSideInfoBuffer() { + return sib; + } + + @RETURNLOC("THIS,Header.T") + public BitReserve getBitReserve() { + return br; + } + +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/HuffData.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/HuffData.java new file mode 100644 index 00000000..7497a51e --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/HuffData.java @@ -0,0 +1,19 @@ +// need to have this class for liner type system +@LATTICE("V") +public class HuffData { + + @LOC("V") public int x; + @LOC("V") public int y; + @LOC("V") public int w; + @LOC("V") public int v; + @LOC("V") public BitReserve br; + + public HuffData(int x, int y, int w, int v, BitReserve br) { + this.x = x; + this.y = y; + this.w = w; + this.v = v; + this.br = br; + } + +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/InputStreamSource.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/InputStreamSource.java new file mode 100644 index 00000000..3945c3d0 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/InputStreamSource.java @@ -0,0 +1,78 @@ +/* + * 11/19/04 1.0 moved to LGPL. + * 12/12/99 Initial version. mdm@techie.com + *----------------------------------------------------------------------- + * 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. + *---------------------------------------------------------------------- + */ + +import java.io.IOException; +import java.io.InputStream; + +/** + * Work In Progress. + * + * An instance of InputStreamSource implements a + * Source that provides data from an InputStream + * . Seeking functionality is not supported. + * + * @author MDM + */ +public class InputStreamSource implements Source +{ + private final InputStream in; + + public InputStreamSource(InputStream in) + { + if (in==null) + throw new NullPointerException("in"); + + this.in = in; + } + + public int read(byte[] b, int offs, int len) + throws IOException + { + int read = in.read(b, offs, len); + return read; + } + + public boolean willReadBlock() + { + return true; + //boolean block = (in.available()==0); + //return block; + } + + public boolean isSeekable() + { + return false; + } + + public long tell() + { + return -1; + } + + public long seek(long to) + { + return -1; + } + + public long length() + { + return -1; + } +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/JavaLayerError.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/JavaLayerError.java new file mode 100644 index 00000000..cc8dde73 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/JavaLayerError.java @@ -0,0 +1,29 @@ +/* + * 11/19/04 1.0 moved to LGPL. + * 12/12/99 Initial version. mdm@techie.com + *----------------------------------------------------------------------- + * 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. + *---------------------------------------------------------------------- + */ + +/** + * Work in progress. + * + * API usage errors may be handled by throwing an instance of this + * class, as per JMF 2.0. + */ +public class JavaLayerError extends Error +{ +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/JavaLayerErrors.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/JavaLayerErrors.java new file mode 100644 index 00000000..4d11270c --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/JavaLayerErrors.java @@ -0,0 +1,39 @@ +/* + * 11/19/04 1.0 moved to LGPL. + * 12/12/99 Initial version. mdm@techie.com + *----------------------------------------------------------------------- + * 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. + *---------------------------------------------------------------------- + */ + + +/** + * Exception erorr codes for components of the JavaLayer API. + */ +public interface JavaLayerErrors +{ + /** + * The first bitstream error code. See the {@link DecoderErrors DecoderErrors} + * interface for other bitstream error codes. + */ + static public final int BITSTREAM_ERROR = 0x100; + + /** + * The first decoder error code. See the {@link DecoderErrors DecoderErrors} + * interface for other decoder error codes. + */ + static public final int DECODER_ERROR = 0x200; + +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/JavaLayerException.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/JavaLayerException.java new file mode 100644 index 00000000..2759a9a8 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/JavaLayerException.java @@ -0,0 +1,79 @@ +/* + * 11/19/04 1.0 moved to LGPL. + * 12/12/99 Initial version. mdm@techie.com + *----------------------------------------------------------------------- + * 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. + *---------------------------------------------------------------------- + */ + + +//import java.io.PrintStream; + + +/** + * The JavaLayerException is the base class for all API-level + * exceptions thrown by JavaLayer. To facilitate conversion and + * common handling of exceptions from other domains, the class + * can delegate some functionality to a contained Throwable instance. + *

+ * + * @author MDM + */ +public class JavaLayerException extends Exception +{ + + private Throwable exception; + + + public JavaLayerException() + { + } + + public JavaLayerException(String msg) + { + super(msg); + } + + public JavaLayerException(String msg, Throwable t) + { + super(msg); + exception = t; + } + + public Throwable getException() + { + return exception; + } + + + public void printStackTrace() + { +// printStackTrace(System.err); + } + + public void printStackTrace(PrintStream ps) + { +// if (this.exception==null) +// { +// super.printStackTrace(ps); +// } +// else +// { +// exception.printStackTrace(); +// } + } + + +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/JavaLayerHook.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/JavaLayerHook.java new file mode 100644 index 00000000..eda09dec --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/JavaLayerHook.java @@ -0,0 +1,35 @@ +/* + * 11/19/04 1.0 moved to LGPL. + *----------------------------------------------------------------------- + * 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. + *---------------------------------------------------------------------- + */ + + +//import java.io.InputStream; + +/** + * The JavaLayerHooks class allows developers to change + * the way the JavaLayer library uses Resources. + */ + +public interface JavaLayerHook +{ + /** + * Retrieves the named resource. This allows resources to be + * obtained without specifying how they are retrieved. + */ + public InputStream getResourceAsStream(String name); +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/JavaLayerUtils.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/JavaLayerUtils.java new file mode 100644 index 00000000..13f2ac0b --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/JavaLayerUtils.java @@ -0,0 +1,227 @@ +/* + * 11/19/04 1.0 moved to LGPL. + * 12/12/99 Initial version. mdm@techie.com + *----------------------------------------------------------------------- + * 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. + *---------------------------------------------------------------------- + */ + + +//import java.io.IOException; +//import java.io.InputStream; +//import java.io.InvalidClassException; +//import java.io.InvalidObjectException; +//import java.io.ObjectInputStream; +//import java.io.ObjectOutputStream; +//import java.io.OutputStream; +//import java.lang.reflect.Array; + +/** + * The JavaLayerUtils class is not strictly part of the JavaLayer API. + * It serves to provide useful methods and system-wide hooks. + * + * @author MDM + */ +public class JavaLayerUtils +{ + static private JavaLayerHook hook = null; + + /** + * Deserializes the object contained in the given input stream. + * @param in The input stream to deserialize an object from. + * @param cls The expected class of the deserialized object. + */ +// static public Object deserialize(InputStream in, Class cls) + static public Object deserialize(InputStream in) + throws IOException + { +// if (cls==null) +// throw new NullPointerException("cls"); + +// Object obj = deserialize(in, cls); + Object obj = deserialize(in); +// if (!cls.isInstance(obj)) +// { +// throw new InvalidObjectException("type of deserialized instance not of required class."); +// } + + return obj; + } + + /** + * Deserializes an object from the given InputStream. + * The deserialization is delegated to an + * ObjectInputStream instance. + * + * @param in The InputStream to deserialize an object + * from. + * + * @return The object deserialized from the stream. + * @exception IOException is thrown if there was a problem reading + * the underlying stream, or an object could not be deserialized + * from the stream. + * + * @see java.io.ObjectInputStream + */ + static public Object deserialize(InputStream in) + throws IOException + { + if (in==null) + throw new NullPointerException("in"); + + //TODO : need to enable after having objectinputstream + /* + ObjectInputStream objIn = new ObjectInputStream(in); + + Object obj; + + try + { + obj = objIn.readObject(); + } + catch (ClassNotFoundException ex) + { + throw new InvalidClassException(ex.toString()); + } + + return obj; + */ + return null; + } + + /** + * Deserializes an array from a given InputStream. + * + * @param in The InputStream to + * deserialize an object from. + * + * @param elemType The class denoting the type of the array + * elements. + * @param length The expected length of the array, or -1 if + * any length is expected. + */ + static public Object deserializeArray(InputStream in, int length) + throws IOException + { + if (length<-1) + throw new IllegalArgumentException("length"); + + Object obj = deserialize(in); + + return obj; + } +// static public Object deserializeArray(InputStream in, Class elemType, int length) +// throws IOException +// { +// if (elemType==null) +// throw new NullPointerException("elemType"); +// +// if (length<-1) +// throw new IllegalArgumentException("length"); +// +// Object obj = deserialize(in); +// +// //SSJava will never throw exceptions as it is so this code is meaningless +// /* +// Class cls = obj.getClass(); +// +// if (!cls.isArray()) +// throw new InvalidObjectException("object is not an array"); +// +// Class arrayElemType = cls.getComponentType(); +// if (arrayElemType!=elemType) +// throw new InvalidObjectException("unexpected array component type"); +// +// if (length != -1) +// { +// int arrayLength = Array.getLength(obj); +// if (arrayLength!=length) +// throw new InvalidObjectException("array length mismatch"); +// } +// */ +// return obj; +// } + +// static public Object deserializeArrayResource(String name, Class elemType, int length) + static public Object deserializeArrayResource(String name, int length) + throws IOException + { + InputStream str = getResourceAsStream(name); + if (str==null) + throw new IOException("unable to load resource '"+name+"'"); + +// Object obj = deserializeArray(str, elemType, length); + Object obj = deserializeArray(str, length); + + return obj; + } + + static public void serialize(OutputStream out, Object obj) + throws IOException + { + //TODO : need to enable after having objectinputstream +// if (out==null) +// throw new NullPointerException("out"); +// +// if (obj==null) +// throw new NullPointerException("obj"); +// +// ObjectOutputStream objOut = new ObjectOutputStream(out); +// objOut.writeObject(obj); + + } + + /** + * Sets the system-wide JavaLayer hook. + */ + static synchronized public void setHook(JavaLayerHook hook0) + { + hook = hook0; + } + + static synchronized public JavaLayerHook getHook() + { + return hook; + } + + /** + * Retrieves an InputStream for a named resource. + * + * @param name The name of the resource. This must be a simple + * name, and not a qualified package name. + * + * @return The InputStream for the named resource, or null if + * the resource has not been found. If a hook has been + * provided, its getResourceAsStream() method is called + * to retrieve the resource. + */ + static synchronized public InputStream getResourceAsStream(String name) + { + InputStream is = null; + + if (hook!=null) + { + is = hook.getResourceAsStream(name); + } + //TODO java reflection +// else +// { +// Class cls = JavaLayerUtils.class; +// is = cls.getResourceAsStream(name); +// } + + return is; + } +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/LATTICE.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/LATTICE.java new file mode 100644 index 00000000..3dc53b81 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/LATTICE.java @@ -0,0 +1,3 @@ +public @interface LATTICE{ + String value(); +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/LOC.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/LOC.java new file mode 100644 index 00000000..0165516c --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/LOC.java @@ -0,0 +1,7 @@ +public @interface LOC { + String value(); +} + +public @interface RETURNLOC { + String value(); +} \ No newline at end of file diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/LayerIDecoder.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/LayerIDecoder.java new file mode 100644 index 00000000..ef79a880 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/LayerIDecoder.java @@ -0,0 +1,432 @@ +/* + * 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. + *---------------------------------------------------------------------- + */ + +/** + * Implements decoding of MPEG Audio Layer I frames. + */ +@LATTICE("SB1 source.length - 3) temp = source.length - 3; + if (temp > groupingtable[0].length - 3) { + temp = groupingtable[0].length - 3; + } + + samples[tmp] = groupingtable[0][temp]; + temp++; + tmp++; + samples[tmp] = groupingtable[0][temp]; + temp++; + tmp++; + samples[tmp] = groupingtable[0][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; + } + + // ssjava + public boolean put_next_sample(@LOC("IN") int channels, @LOC("IN") SynthesisFilter filter1, + @LOC("IN") SynthesisFilter filter2) { + + if ((allocation != 0) && (channels != OutputChannels.RIGHT_CHANNEL)) { + + @LOC("THIS,LayerIIDecoder$SubbandLayer2.SM") 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. + */ + @LATTICE("S>> 4) / 5; + new_slen[1] = (scalefac_comp >>> 4) % 5; + new_slen[2] = (scalefac_comp & 0xF) >>> 2; + new_slen[3] = (scalefac_comp & 3); + si.ch[ch].gr[gr].preflag = 0; + blocknumber = 0; + + } else if (scalefac_comp < 500) { + + new_slen[0] = ((scalefac_comp - 400) >>> 2) / 5; + new_slen[1] = ((scalefac_comp - 400) >>> 2) % 5; + new_slen[2] = (scalefac_comp - 400) & 3; + new_slen[3] = 0; + si.ch[ch].gr[gr].preflag = 0; + blocknumber = 1; + + } else if (scalefac_comp < 512) { + + new_slen[0] = (scalefac_comp - 500) / 3; + new_slen[1] = (scalefac_comp - 500) % 3; + new_slen[2] = 0; + new_slen[3] = 0; + si.ch[ch].gr[gr].preflag = 1; + blocknumber = 2; + } + } + + if ((((mode_ext == 1) || (mode_ext == 3)) && (ch == 1))) { + int_scalefac_comp = scalefac_comp >>> 1; + + if (int_scalefac_comp < 180) { + new_slen[0] = int_scalefac_comp / 36; + new_slen[1] = (int_scalefac_comp % 36) / 6; + new_slen[2] = (int_scalefac_comp % 36) % 6; + new_slen[3] = 0; + si.ch[ch].gr[gr].preflag = 0; + blocknumber = 3; + } else if (int_scalefac_comp < 244) { + new_slen[0] = ((int_scalefac_comp - 180) & 0x3F) >>> 4; + new_slen[1] = ((int_scalefac_comp - 180) & 0xF) >>> 2; + new_slen[2] = (int_scalefac_comp - 180) & 3; + new_slen[3] = 0; + si.ch[ch].gr[gr].preflag = 0; + blocknumber = 4; + } else if (int_scalefac_comp < 255) { + new_slen[0] = (int_scalefac_comp - 244) / 3; + new_slen[1] = (int_scalefac_comp - 244) % 3; + new_slen[2] = 0; + new_slen[3] = 0; + si.ch[ch].gr[gr].preflag = 0; + blocknumber = 5; + } + } + + // for (@LOC("THIS,LayerIIIDecoder.NS") int x = 0; x < 45; x++) + // // why 45, not 54? + // scalefac_buffer[x] = 0; + + m = 0; + for (@LOC("THIS,LayerIIIDecoder.NS") int i = 0; i < 4; i++) { + @LOC("THIS,LayerIIIDecoder.NS") int jmax = nr_of_sfb_block[blocknumber][blocktypenumber][i]; + for (@LOC("THIS,LayerIIIDecoder.NS") int j = 0; j < jmax; j++) { + scalefac_buffer[m] = (new_slen[i] == 0) ? 0 : br.hgetbits(new_slen[i]); + m++; + + } // for (unint32 j ... + } // for (uint32 i ... + } + + /** + * + */ + @LATTICE("THIS sfBandIndex[sfreq].l.length - 1) + buf1 = sfBandIndex[sfreq].l.length - 1; + + region1Start = sfBandIndex[sfreq].l[buf]; + region2Start = sfBandIndex[sfreq].l[buf1]; /* MI */ + } + + index = 0; + // Read bigvalues area + TERMINATE: for (@LOC("THIS,LayerIIIDecoder.BR,BitReserve.BIT") int i = 0; i < (si.ch[ch].gr[gr].big_values << 1); i += + 2) { + + @LOC("THIS,LayerIIIDecoder.SI2") int htIdx; + if (i < region1Start) { + htIdx = si.ch[ch].gr[gr].table_select[0]; + // h = huffcodetab.ht[si.ch[ch].gr[gr].table_select[0]]; + } else if (i < region2Start) { + htIdx = si.ch[ch].gr[gr].table_select[1]; + // h = huffcodetab.ht[si.ch[ch].gr[gr].table_select[1]]; + } else { + htIdx = si.ch[ch].gr[gr].table_select[2]; + // h = huffcodetab.ht[si.ch[ch].gr[gr].table_select[2]]; + } + + huffcodetab.huffman_decoder(htIdx, x, y, v, w, br); + // if (index >= is_1d.length) + // System.out.println("i0="+i+"/"+(si.ch[ch].gr[gr].big_values<<1)+" Index="+index+" is_1d="+is_1d.length); + + is_1d[index++] = x[0]; + is_1d[index++] = y[0]; + + CheckSumHuff = CheckSumHuff + x[0] + y[0]; + // System.out.println("x = " + x[0] + " y = " + y[0]); + } + + // Read count1 area + + @LOC("THIS,LayerIIIDecoder.SI2") int htIdx = si.ch[ch].gr[gr].count1table_select + 32; + // h = huffcodetab.ht[si.ch[ch].gr[gr].count1table_select + 32]; + num_bits = br.hsstell(); + + TERMINATE: while ((num_bits < part2_3_end) && (index < 576)) { + + huffcodetab.huffman_decoder(htIdx, x, y, v, w, br); + + is_1d[index++] = v[0]; + is_1d[index++] = w[0]; + is_1d[index++] = x[0]; + is_1d[index++] = y[0]; + CheckSumHuff = CheckSumHuff + v[0] + w[0] + x[0] + y[0]; + // System.out.println("v = "+v[0]+" w = "+w[0]); + // System.out.println("x = "+x[0]+" y = "+y[0]); + num_bits = br.hsstell(); + } + + if (num_bits > part2_3_end) { + br.rewindNbits(num_bits - part2_3_end); + index -= 4; + } + + num_bits = br.hsstell(); + + // Dismiss stuffing bits + if (num_bits < part2_3_end) + br.hgetbits(part2_3_end - num_bits); + + // Zero out rest + + if (index < 576) + nonzero[ch] = index; + else + nonzero[ch] = 576; + + if (index < 0) + index = 0; + + // may not be necessary + for (; index < 576; index++) + is_1d[index] = 0; + } + + @LATTICE("THIS,IN,THISLOC=THIS,RETURNLOC=THIS") + private int huffcodetab_huffman_decoder(@LOC("IN") int h) { + // TODO need to move huffmancodetab implementation here + return 0; + } + + /** + * + */ + private void i_stereo_k_values(@LOC("THIS,LayerIIIDecoder.LR") int is_pos, + @LOC("THIS,LayerIIIDecoder.LR") int io_type, @LOC("THIS,LayerIIIDecoder.LR") int i) { + if (is_pos == 0) { + k[0][i] = 1.0f; + k[1][i] = 1.0f; + } else if ((is_pos & 1) != 0) { + k[0][i] = io[io_type][(is_pos + 1) >>> 1]; + k[1][i] = 1.0f; + } else { + k[0][i] = 1.0f; + k[1][i] = io[io_type][is_pos >>> 1]; + } + } + + /** + * + */ + // @LATTICE("OUT 0) + ro[ch][quotien][reste] = g_gain * t_43[abv]; + else { + if (-abv < t_43.length) + ro[ch][quotien][reste] = -g_gain * t_43[-abv]; + else + ro[ch][quotien][reste] = -g_gain * (float) Math.pow(-abv, d43); + } + } else { + if (is_1d[j] > 0) + ro[ch][quotien][reste] = g_gain * (float) Math.pow(abv, d43); + else + ro[ch][quotien][reste] = -g_gain * (float) Math.pow(-abv, d43); + } + } + } + + // apply formula per block type + for (j = 0; j < nonzero[ch]; j++) { + // Modif E.B 02/22/99 + @LOC("THIS,LayerIIIDecoder.NZ") int reste = j % SSLIMIT; + @LOC("THIS,LayerIIIDecoder.NZ") int quotien = (int) ((j - reste) / SSLIMIT); + + if (index == next_cb_boundary) { /* Adjust critical band boundary */ + if ((si.ch[ch].gr[gr].window_switching_flag != 0) && (si.ch[ch].gr[gr].block_type == 2)) { + if (si.ch[ch].gr[gr].mixed_block_flag != 0) { + + if (index == sfBandIndex[sfreq].l[8]) { + next_cb_boundary = sfBandIndex[sfreq].s[4]; + next_cb_boundary = (next_cb_boundary << 2) - next_cb_boundary; + cb = 3; + cb_width = sfBandIndex[sfreq].s[4] - sfBandIndex[sfreq].s[3]; + + cb_begin = sfBandIndex[sfreq].s[3]; + cb_begin = (cb_begin << 2) - cb_begin; + + } else if (index < sfBandIndex[sfreq].l[8]) { + + next_cb_boundary = sfBandIndex[sfreq].l[(++cb) + 1]; + + } else { + + next_cb_boundary = sfBandIndex[sfreq].s[(++cb) + 1]; + next_cb_boundary = (next_cb_boundary << 2) - next_cb_boundary; + + cb_begin = sfBandIndex[sfreq].s[cb]; + cb_width = sfBandIndex[sfreq].s[cb + 1] - cb_begin; + cb_begin = (cb_begin << 2) - cb_begin; + } + + } else { + + next_cb_boundary = sfBandIndex[sfreq].s[(++cb) + 1]; + next_cb_boundary = (next_cb_boundary << 2) - next_cb_boundary; + + cb_begin = sfBandIndex[sfreq].s[cb]; + cb_width = sfBandIndex[sfreq].s[cb + 1] - cb_begin; + cb_begin = (cb_begin << 2) - cb_begin; + } + + } else { // long blocks + + next_cb_boundary = sfBandIndex[sfreq].l[(++cb) + 1]; + + } + } + + // Do long/short dependent scaling operations + + if ((si.ch[ch].gr[gr].window_switching_flag != 0) + && (((si.ch[ch].gr[gr].block_type == 2) && (si.ch[ch].gr[gr].mixed_block_flag == 0)) || ((si.ch[ch].gr[gr].block_type == 2) + && (si.ch[ch].gr[gr].mixed_block_flag != 0) && (j >= 36)))) { + + t_index = (index - cb_begin) / cb_width; + /* + * xr[sb][ss] *= pow(2.0, ((-2.0 * gr_info.subblock_gain[t_index]) -(0.5 + * * (1.0 + gr_info.scalefac_scale) scalefac[ch].s[t_index][cb]))); + */ + @LOC("THIS,LayerIIIDecoder.SI1") int idx = + scalefac[ch].s[t_index][cb] << si.ch[ch].gr[gr].scalefac_scale; + idx += (si.ch[ch].gr[gr].subblock_gain[t_index] << 2); + + ro[ch][quotien][reste] *= two_to_negative_half_pow[idx]; + + } else { // LONG block types 0,1,3 & 1st 2 subbands of switched blocks + /* + * xr[sb][ss] *= pow(2.0, -0.5 * (1.0+gr_info.scalefac_scale) + * (scalefac[ch].l[cb] + gr_info.preflag * pretab[cb])); + */ + @LOC("THIS,LayerIIIDecoder.SI1") int idx = scalefac[ch].l[cb]; + + if (si.ch[ch].gr[gr].preflag != 0) + idx += pretab[cb]; + + idx = idx << si.ch[ch].gr[gr].scalefac_scale; + ro[ch][quotien][reste] *= two_to_negative_half_pow[idx]; + } + index++; + } + + for (j = nonzero[ch]; j < 576; j++) { + // Modif E.B 02/22/99 + @LOC("THIS,LayerIIIDecoder.NZ") int reste = j % SSLIMIT; + @LOC("THIS,LayerIIIDecoder.NZ") int quotien = (int) ((j - reste) / SSLIMIT); + if (reste < 0) + reste = 0; + if (quotien < 0) + quotien = 0; + ro[ch][quotien][reste] = 0.0f; + } + + return; + } + + /** + * + */ + // ssjava + // @LATTICE("THIS= 3; sfb--) { + i = sfBandIndex[sfreq].s[sfb]; + lines = sfBandIndex[sfreq].s[sfb + 1] - i; + i = (i << 2) - i + (j + 1) * lines - 1; + TERMINATE: while (lines > 0) { + if (ro[1][i / 18][i % 18] != 0.0f) { + // MDM: in java, array access is very slow. + // Is quicker to compute div and mod values. + // if (ro[1][ss_div[i]][ss_mod[i]] != 0.0f) { + sfbcnt = sfb; + sfb = -10; + lines = -10; + } + + lines--; + i--; + + } // while (lines > 0) + + } // for (sfb=12 ... + sfb = sfbcnt + 1; + + if (sfb > max_sfb) + max_sfb = sfb; + + while (sfb < 12) { + temp = sfBandIndex[sfreq].s[sfb]; + sb = sfBandIndex[sfreq].s[sfb + 1] - temp; + i = (temp << 2) - temp + j * sb; + + TERMINATE: for (; sb > 0; sb--) { + is_pos[i] = scalefac[1].s[j][sfb]; + if (is_pos[i] != 7) + if (lsf) + i_stereo_k_values(is_pos[i], io_type, i); + else + is_ratio[i] = TAN12[is_pos[i]]; + + i++; + } // for (; sb>0... + sfb++; + } // while (sfb < 12) + sfb = sfBandIndex[sfreq].s[10]; + sb = sfBandIndex[sfreq].s[11] - sfb; + sfb = (sfb << 2) - sfb + j * sb; + temp = sfBandIndex[sfreq].s[11]; + sb = sfBandIndex[sfreq].s[12] - temp; + i = (temp << 2) - temp + j * sb; + TERMINATE: for (; sb > 0; sb--) { + is_pos[i] = is_pos[sfb]; + + if (lsf) { + k[0][i] = k[0][sfb]; + k[1][i] = k[1][sfb]; + } else { + is_ratio[i] = is_ratio[sfb]; + } + i++; + } // for (; sb > 0 ... + } + if (max_sfb <= 3) { + i = 2; + ss = 17; + sb = -1; + TERMINATE: while (i >= 0) { + if (ro[1][i][ss] != 0.0f) { + sb = (i << 4) + (i << 1) + ss; + i = -1; + } else { + ss--; + if (ss < 0) { + i--; + ss = 17; + } + } // if (ro ... + } // while (i>=0) + i = 0; + while (sfBandIndex[sfreq].l[i] <= sb) + i++; + sfb = i; + i = sfBandIndex[sfreq].l[i]; + for (; sfb < 8; sfb++) { + sb = sfBandIndex[sfreq].l[sfb + 1] - sfBandIndex[sfreq].l[sfb]; + TERMINATE: for (; sb > 0; sb--) { + is_pos[i] = scalefac[1].l[sfb]; + if (is_pos[i] != 7) + if (lsf) + i_stereo_k_values(is_pos[i], io_type, i); + else + is_ratio[i] = TAN12[is_pos[i]]; + i++; + } // for (; sb>0 ... + } // for (; sfb<8 ... + } // for (j=0 ... + } else { // if (gr_info.mixed_block_flag) + for (@LOC("THIS,LayerIIIDecoder.RO1") int j = 0; j < 3; j++) { + @LOC("THIS,LayerIIIDecoder.RO1") int sfbcnt; + sfbcnt = -1; + TERMINATE: for (sfb = 12; sfb >= 0; sfb--) { + temp = sfBandIndex[sfreq].s[sfb]; + lines = sfBandIndex[sfreq].s[sfb + 1] - temp; + i = (temp << 2) - temp + (j + 1) * lines - 1; + TERMINATE: while (lines > 0) { + if (ro[1][i / 18][i % 18] != 0.0f) { + // MDM: in java, array access is very slow. + // Is quicker to compute div and mod values. + // if (ro[1][ss_div[i]][ss_mod[i]] != 0.0f) { + sfbcnt = sfb; + sfb = -10; + lines = -10; + } + lines--; + i--; + } // while (lines > 0) */ + + } // for (sfb=12 ... + sfb = sfbcnt + 1; + while (sfb < 12) { + temp = sfBandIndex[sfreq].s[sfb]; + sb = sfBandIndex[sfreq].s[sfb + 1] - temp; + i = (temp << 2) - temp + j * sb; + TERMINATE: for (; sb > 0; sb--) { + is_pos[i] = scalefac[1].s[j][sfb]; + if (is_pos[i] != 7) + if (lsf) + i_stereo_k_values(is_pos[i], io_type, i); + else + is_ratio[i] = TAN12[is_pos[i]]; + i++; + } // for (; sb>0 ... + sfb++; + } // while (sfb<12) + + temp = sfBandIndex[sfreq].s[10]; + temp2 = sfBandIndex[sfreq].s[11]; + sb = temp2 - temp; + sfb = (temp << 2) - temp + j * sb; + sb = sfBandIndex[sfreq].s[12] - temp2; + i = (temp2 << 2) - temp2 + j * sb; + TERMINATE: for (; sb > 0; sb--) { + is_pos[i] = is_pos[sfb]; + + if (lsf) { + k[0][i] = k[0][sfb]; + k[1][i] = k[1][sfb]; + } else { + is_ratio[i] = is_ratio[sfb]; + } + i++; + } // for (; sb>0 ... + } // for (sfb=12 + } // for (j=0 ... + } else { // if (gr_info.window_switching_flag ... + i = 31; + ss = 17; + sb = 0; + TERMINATE: while (i >= 0) { + if (ro[1][i][ss] != 0.0f) { + sb = (i << 4) + (i << 1) + ss; + i = -1; + } else { + ss--; + if (ss < 0) { + i--; + ss = 17; + } + } + } + i = 0; + while (sfBandIndex[sfreq].l[i] <= sb) + i++; + + sfb = i; + i = sfBandIndex[sfreq].l[i]; + for (; sfb < 21; sfb++) { + sb = sfBandIndex[sfreq].l[sfb + 1] - sfBandIndex[sfreq].l[sfb]; + TERMINATE: for (; sb > 0; sb--) { + is_pos[i] = scalefac[1].l[sfb]; + if (is_pos[i] != 7) + if (lsf) + i_stereo_k_values(is_pos[i], io_type, i); + else + is_ratio[i] = TAN12[is_pos[i]]; + i++; + } + } + sfb = sfBandIndex[sfreq].l[20]; + TERMINATE: for (sb = 576 - sfBandIndex[sfreq].l[21]; (sb > 0) && (i < 576); sb--) { + is_pos[i] = is_pos[sfb]; // error here : i >=576 + + if (lsf) { + k[0][i] = k[0][sfb]; + k[1][i] = k[1][sfb]; + } else { + is_ratio[i] = is_ratio[sfb]; + } + i++; + } // if (gr_info.mixed_block_flag) + } // if (gr_info.window_switching_flag ... + } // if (i_stereo) + + i = 0; + for (sb = 0; sb < SBLIMIT; sb++) + for (ss = 0; ss < SSLIMIT; ss++) { + if (is_pos[i] == 7) { + if (ms_stereo) { + lr[0][sb][ss] = (ro[0][sb][ss] + ro[1][sb][ss]) * 0.707106781f; + lr[1][sb][ss] = (ro[0][sb][ss] - ro[1][sb][ss]) * 0.707106781f; + } else { + lr[0][sb][ss] = ro[0][sb][ss]; + lr[1][sb][ss] = ro[1][sb][ss]; + } + } else if (i_stereo) { + + if (lsf) { + lr[0][sb][ss] = ro[0][sb][ss] * k[0][i]; + lr[1][sb][ss] = ro[0][sb][ss] * k[1][i]; + } else { + lr[1][sb][ss] = ro[0][sb][ss] / (float) (1 + is_ratio[i]); + lr[0][sb][ss] = lr[1][sb][ss] * is_ratio[i]; + } + } + /* + * else { System.out.println("Error in stereo processing\n"); } + */ + i++; + } + + } // channels == 2 + + } + + /** + * + */ + // @LATTICE("THIS 32767.0f) { + s = (short) 32767; + } else if (sample < -32768.0f) { + s = (short) -32768; + } + + return s; + + } + + /** + * Write the samples to the file or directly to the audio hardware. + */ + public abstract void write_buffer(@LOC("IN") int val); + + public abstract void close(); + + /** + * Clears all data in the buffer (for seeking). + */ + public abstract void clear_buffer(); + + /** + * Notify the buffer that the user has stopped the stream. + */ + public abstract void set_stop_flag(); +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/OutputChannels.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/OutputChannels.java new file mode 100644 index 00000000..276ca6a2 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/OutputChannels.java @@ -0,0 +1,129 @@ +/* + * 11/19/04 1.0 moved to LGPL. + * 12/12/99 Initial implementation. mdm@techie.com. + *----------------------------------------------------------------------- + * 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. + *---------------------------------------------------------------------- + */ + +/** + * A Type-safe representation of the the supported output channel constants. + * + * This class is immutable and, hence, is thread safe. + * + * @author Mat McGowan 12/12/99 + * @since 0.0.7 + */ +@LATTICE("BOutputChannels instance corresponding to the given + * channel code. + * + * @param code + * one of the OutputChannels channel code constants. + * + * @throws IllegalArgumentException + * if code is not a valid channel code. + */ + static public OutputChannels fromInt(int code) { + switch (code) { + case LEFT_CHANNEL: + return LEFT; + case RIGHT_CHANNEL: + return RIGHT; + case BOTH_CHANNELS: + return BOTH; + case DOWNMIX_CHANNELS: + return DOWNMIX; + default: + throw new IllegalArgumentException("Invalid channel code: " + code); + } + } + + public OutputChannels(@LOC("IN") int channels) { + outputChannels = channels; + + if (channels < 0 || channels > 3) + throw new IllegalArgumentException("channels"); + } + + /** + * Retrieves the code representing the desired output channels. Will be one of + * LEFT_CHANNEL, RIGHT_CHANNEL, BOTH_CHANNELS or DOWNMIX_CHANNELS. + * + * @return the channel code represented by this instance. + */ + public int getChannelsOutputCode() { + return outputChannels; + } + + /** + * Retrieves the number of output channels represented by this channel output + * type. + * + * @return The number of output channels for this channel output type. This + * will be 2 for BOTH_CHANNELS only, and 1 for all other types. + */ + public int getChannelCount() { + int count = (outputChannels == BOTH_CHANNELS) ? 2 : 1; + return count; + } + + public boolean equals(Object o) { + boolean equals = false; + + if (o instanceof OutputChannels) { + OutputChannels oc = (OutputChannels) o; + equals = (oc.outputChannels == outputChannels); + } + + return equals; + } + + public int hashCode() { + return outputChannels; + } + +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/Player.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/Player.java new file mode 100644 index 00000000..b418fc1e --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/Player.java @@ -0,0 +1,239 @@ +import java.awt.image.SampleModel; + +import FileOutputStream; + +/* + * 11/19/04 1.0 moved to LGPL. + * 29/01/00 Initial version. mdm@techie.com + *----------------------------------------------------------------------- + * 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. + *---------------------------------------------------------------------- + */ + +/** + * The Player class implements a simple player for playback of an + * MPEG audio stream. + * + * @author Mat McGowan + * @since 0.0.8 + */ + +// REVIEW: the audio device should not be opened until the +// first MPEG audio frame has been decoded. +@LATTICE("BPlayer instance. + */ + public Player() throws JavaLayerException { + this(null); + } + + public Player(AudioDevice device) throws JavaLayerException { + // bitstream = new Bitstream(stream); + decoder = new Decoder(); + + // if (device!=null) + // { + // audio = device; + // } + // else + // { + // FactoryRegistry r = FactoryRegistry.systemRegistry(); + // audio = r.createAudioDevice(); + // } + + device.open(decoder); + } + + public void play() throws JavaLayerException { + play(Integer.MAX_VALUE); + } + + /** + * Plays a number of MPEG audio frames. + * + * @param frames + * The number of frames to play. + * @return true if the last frame was played, or false if there are more + * frames. + */ + @LATTICE("OUT + * AudioDevice that is used by this player to sound the decoded audio + * samples. + */ + public int getPosition() { + // int position = lastPosition; + + // AudioDevice out = audio; + // if (out!=null) + // { + // position = out.getPosition(); + // } + // return position; + return 0; + } + + /** + * Decodes a single frame. + * + * @return true if there are no more frames to decode, false otherwise. + */ + @LATTICE("CSampleBuffer class implements an output buffer that provides + * storage for a fixed size block of samples. + */ +@LATTICE("BUF [D] + frequency = sample_frequency; // [IN] -> [D] + + for (@LOC("C") int i = 0; i < number_of_channels; ++i) { + bufferp[i] = (short) i; // LOC(bufferp[i]) has indirect flows from the + // location C, IN + // also, it has a direct flow from C + // anyway, LOC(bufferp[i])=[D,SampleBuffer.BUFP] is lower than all + // locations that have in-flows + } + + } + + public int getChannelCount() { + return this.channels; + } + + public int getSampleFrequency() { + return this.frequency; + } + + public short[] getBuffer() { + return this.buffer; + } + + public int getBufferLength() { + return bufferp[0]; + } + + /** + * Takes a 16 Bit PCM sample. + */ + public void append(@LOC("IN") int channel, @LOC("IN") short value) { + buffer[bufferp[channel]] = value; + // LOC(bufferp[channel])= [local.D,SampleBuffer.BUF] + // so, for LHS, LOC(buffer) < LOC(bufferp[channle]) + // also, bet' LHS and RHS, LOC(LHS) < LOC(RHS) since LOC(value)=[IN] + + bufferp[channel] += channels; + // for lhs, LOC(bufferp[channel]) = [local.D, SampleBuffer.BUFP] + // for rhs, LOC(channels) = [local.D, SampleBuffer.CON] + + } + + @LATTICE("D [D,BUFP] + + if (fs > 32767.0f) { + fs = 32767.0f; + // it has an indirect flow from LOC(fs) + // since LOC(fs) is a shared location, it's okay + } else { + if (fs < -32767.0f) { + fs = -32767.0f; + } + } + + /* + * fs = (fs>32767.0f ? 32767.0f : (fs < -32767.0f ? -32767.0f : fs)); + */ + + s = (short) fs; // it's okay since BUFP of [D,BUFP] is a shared location + buffer[pos] = s; + // for LHS, LOC(buffer[pos])= GLB( [D,BUF] , [D,BUFP] ) = [D,BUF] + // for RHS, LOC(s) = [D,BUFP] + // so it's okay: [D,BUFP] -> [D,BUF] + + pos += channels; // [D,BUFP] -> [D,BUFP] + } + + bufferp[channel] = pos; + // for lhs, LOC(bufferp[channel])=[D,BUFP] + // for rhs, LOC(pos)=[D,BUFP] + // since BUFP is a shared location, the assignment is okay + } + + /** + * Write the samples to the file (Random Acces). + */ + public void write_buffer(@LOC("IN") int val) { + + // for (int i = 0; i < channels; ++i) + // bufferp[i] = (short)i; + + } + + public void close() { + } + + /** + * + */ + + public void clear_buffer() { + for (idx = 0; idx < channels; ++idx) + bufferp[idx] = (short) idx; + } + + /** + * + */ + public void set_stop_flag() { + } +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/SampleBufferWrapper.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/SampleBufferWrapper.java new file mode 100644 index 00000000..5c691eb2 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/SampleBufferWrapper.java @@ -0,0 +1,35 @@ +public class SampleBufferWrapper { + + static SampleBuffer output; + + @TRUST + static void init(int freq, int channels) { + output = new SampleBuffer(freq, channels); + } + + @TRUST + static void clear_buffer(){ + output.clear_buffer(); + } + + @TRUST + static SampleBuffer getOutput() { + return output; + } + + @TRUST + static short[] getBuffer() { + return output.getBuffer(); + } + + @TRUST + static int getBufferLength() { + return output.getBufferLength(); + } + + @TRUST + static void appendSamples(int channel, float[] f) { + output.appendSamples(channel, f); + } + +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/SideInfoBuffer.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/SideInfoBuffer.java new file mode 100644 index 00000000..6fef3fcf --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/SideInfoBuffer.java @@ -0,0 +1,89 @@ +@LATTICE("BUFframebuffer where the next bits are retrieved. + */ + @LOC("IDX") + private int wordpointer; + + /** + * Number (0-31, from MSB to LSB) of next bit for get_bits() + */ + @LOC("IDX") + private int bitindex; + + @LOC("V") + private int main_data_begin; + + public int getMain_data_begin() { + return main_data_begin; + } + + public void setMain_data_begin(@LOC("IN") int main_data_begin) { + this.main_data_begin = main_data_begin; + } + + private static final int bitmask[] = { + 0, // dummy + 0x00000001, 0x00000003, 0x00000007, 0x0000000F, 0x0000001F, 0x0000003F, 0x0000007F, + 0x000000FF, 0x000001FF, 0x000003FF, 0x000007FF, 0x00000FFF, 0x00001FFF, 0x00003FFF, + 0x00007FFF, 0x0000FFFF, 0x0001FFFF }; + + @LATTICE("OUT>> 16) & 0x0000FFFF); + + returnvalue >>>= 48 - sum; // returnvalue >>= 16 - (number_of_bits - (32 + // - bitindex)) + returnvalue &= bitmask[number_of_bits]; + bitindex = sum - 32; + return returnvalue; + } + + public void setBuffer(int idx, int value) { + framebuffer[idx] = value; + } + +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/Source.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/Source.java new file mode 100644 index 00000000..ad2f0c91 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/Source.java @@ -0,0 +1,48 @@ +/* + * 11/19/04 1.0 moved to LGPL. + *----------------------------------------------------------------------- + * 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. + *---------------------------------------------------------------------- + */ + + +import java.io.IOException; + +/** + * Work in progress. + * + * Class to describe a seekable data source. + * + */ +public interface Source +{ + + public static final long LENGTH_UNKNOWN = -1; + + public int read(byte[] b, int offs, int len) + throws IOException; + + + public boolean willReadBlock(); + + public boolean isSeekable(); + + public long length(); + + public long tell(); + + public long seek(long pos); + +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/Subband.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/Subband.java new file mode 100644 index 00000000..7fe106c3 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/Subband.java @@ -0,0 +1,44 @@ +//package ssJava.mp3decoder; + +/** + * Abstract base class for subband classes of layer I and II + */ +@LATTICE("S= 0; i--) { + samples[i] = s[i] * eq[i]; + } + } + + private void compute_new_v2_v1() { + + @LOC("THIS,SynthesisFilter.NEWV") float new_v0 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v1 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v2 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v3 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v4 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v5 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v6 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v7 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v8 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v9 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v10 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v11 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v12 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v13 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v14 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v15 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v16 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v17 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v18 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v19 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v20 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v21 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v22 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v23 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v24 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v25 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v26 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v27 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v28 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v29 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v30 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v31 = 0.0f; + + // float[] new_v = new float[32]; // new V[0-15] and V[33-48] of Figure + // 3-A.2 in ISO DIS 11172-3 + // float[] p = new float[16]; + // float[] pp = new float[16]; + + // float[] s = samples; + + @LOC("THIS,SynthesisFilter.NEWV") float s0 = samples[0]; + @LOC("THIS,SynthesisFilter.NEWV") float s1 = samples[1]; + @LOC("THIS,SynthesisFilter.NEWV") float s2 = samples[2]; + @LOC("THIS,SynthesisFilter.NEWV") float s3 = samples[3]; + @LOC("THIS,SynthesisFilter.NEWV") float s4 = samples[4]; + @LOC("THIS,SynthesisFilter.NEWV") float s5 = samples[5]; + @LOC("THIS,SynthesisFilter.NEWV") float s6 = samples[6]; + @LOC("THIS,SynthesisFilter.NEWV") float s7 = samples[7]; + @LOC("THIS,SynthesisFilter.NEWV") float s8 = samples[8]; + @LOC("THIS,SynthesisFilter.NEWV") float s9 = samples[9]; + @LOC("THIS,SynthesisFilter.NEWV") float s10 = samples[10]; + @LOC("THIS,SynthesisFilter.NEWV") float s11 = samples[11]; + @LOC("THIS,SynthesisFilter.NEWV") float s12 = samples[12]; + @LOC("THIS,SynthesisFilter.NEWV") float s13 = samples[13]; + @LOC("THIS,SynthesisFilter.NEWV") float s14 = samples[14]; + @LOC("THIS,SynthesisFilter.NEWV") float s15 = samples[15]; + @LOC("THIS,SynthesisFilter.NEWV") float s16 = samples[16]; + @LOC("THIS,SynthesisFilter.NEWV") float s17 = samples[17]; + @LOC("THIS,SynthesisFilter.NEWV") float s18 = samples[18]; + @LOC("THIS,SynthesisFilter.NEWV") float s19 = samples[19]; + @LOC("THIS,SynthesisFilter.NEWV") float s20 = samples[20]; + @LOC("THIS,SynthesisFilter.NEWV") float s21 = samples[21]; + @LOC("THIS,SynthesisFilter.NEWV") float s22 = samples[22]; + @LOC("THIS,SynthesisFilter.NEWV") float s23 = samples[23]; + @LOC("THIS,SynthesisFilter.NEWV") float s24 = samples[24]; + @LOC("THIS,SynthesisFilter.NEWV") float s25 = samples[25]; + @LOC("THIS,SynthesisFilter.NEWV") float s26 = samples[26]; + @LOC("THIS,SynthesisFilter.NEWV") float s27 = samples[27]; + @LOC("THIS,SynthesisFilter.NEWV") float s28 = samples[28]; + @LOC("THIS,SynthesisFilter.NEWV") float s29 = samples[29]; + @LOC("THIS,SynthesisFilter.NEWV") float s30 = samples[30]; + @LOC("THIS,SynthesisFilter.NEWV") float s31 = samples[31]; + + @LOC("THIS,SynthesisFilter.NEWV") float p0 = s0 + s31; + @LOC("THIS,SynthesisFilter.NEWV") float p1 = s1 + s30; + @LOC("THIS,SynthesisFilter.NEWV") float p2 = s2 + s29; + @LOC("THIS,SynthesisFilter.NEWV") float p3 = s3 + s28; + @LOC("THIS,SynthesisFilter.NEWV") float p4 = s4 + s27; + @LOC("THIS,SynthesisFilter.NEWV") float p5 = s5 + s26; + @LOC("THIS,SynthesisFilter.NEWV") float p6 = s6 + s25; + @LOC("THIS,SynthesisFilter.NEWV") float p7 = s7 + s24; + @LOC("THIS,SynthesisFilter.NEWV") float p8 = s8 + s23; + @LOC("THIS,SynthesisFilter.NEWV") float p9 = s9 + s22; + @LOC("THIS,SynthesisFilter.NEWV") float p10 = s10 + s21; + @LOC("THIS,SynthesisFilter.NEWV") float p11 = s11 + s20; + @LOC("THIS,SynthesisFilter.NEWV") float p12 = s12 + s19; + @LOC("THIS,SynthesisFilter.NEWV") float p13 = s13 + s18; + @LOC("THIS,SynthesisFilter.NEWV") float p14 = s14 + s17; + @LOC("THIS,SynthesisFilter.NEWV") float p15 = s15 + s16; + + @LOC("THIS,SynthesisFilter.NEWV") float pp0 = p0 + p15; + @LOC("THIS,SynthesisFilter.NEWV") float pp1 = p1 + p14; + @LOC("THIS,SynthesisFilter.NEWV") float pp2 = p2 + p13; + @LOC("THIS,SynthesisFilter.NEWV") float pp3 = p3 + p12; + @LOC("THIS,SynthesisFilter.NEWV") float pp4 = p4 + p11; + @LOC("THIS,SynthesisFilter.NEWV") float pp5 = p5 + p10; + @LOC("THIS,SynthesisFilter.NEWV") float pp6 = p6 + p9; + @LOC("THIS,SynthesisFilter.NEWV") float pp7 = p7 + p8; + @LOC("THIS,SynthesisFilter.NEWV") float pp8 = (p0 - p15) * cos1_32; + @LOC("THIS,SynthesisFilter.NEWV") float pp9 = (p1 - p14) * cos3_32; + @LOC("THIS,SynthesisFilter.NEWV") float pp10 = (p2 - p13) * cos5_32; + @LOC("THIS,SynthesisFilter.NEWV") float pp11 = (p3 - p12) * cos7_32; + @LOC("THIS,SynthesisFilter.NEWV") float pp12 = (p4 - p11) * cos9_32; + @LOC("THIS,SynthesisFilter.NEWV") float pp13 = (p5 - p10) * cos11_32; + @LOC("THIS,SynthesisFilter.NEWV") float pp14 = (p6 - p9) * cos13_32; + @LOC("THIS,SynthesisFilter.NEWV") float pp15 = (p7 - p8) * cos15_32; + + p0 = pp0 + pp7; + p1 = pp1 + pp6; + p2 = pp2 + pp5; + p3 = pp3 + pp4; + p4 = (pp0 - pp7) * cos1_16; + p5 = (pp1 - pp6) * cos3_16; + p6 = (pp2 - pp5) * cos5_16; + p7 = (pp3 - pp4) * cos7_16; + p8 = pp8 + pp15; + p9 = pp9 + pp14; + p10 = pp10 + pp13; + p11 = pp11 + pp12; + p12 = (pp8 - pp15) * cos1_16; + p13 = (pp9 - pp14) * cos3_16; + p14 = (pp10 - pp13) * cos5_16; + p15 = (pp11 - pp12) * cos7_16; + + pp0 = p0 + p3; + pp1 = p1 + p2; + pp2 = (p0 - p3) * cos1_8; + pp3 = (p1 - p2) * cos3_8; + pp4 = p4 + p7; + pp5 = p5 + p6; + pp6 = (p4 - p7) * cos1_8; + pp7 = (p5 - p6) * cos3_8; + pp8 = p8 + p11; + pp9 = p9 + p10; + pp10 = (p8 - p11) * cos1_8; + pp11 = (p9 - p10) * cos3_8; + pp12 = p12 + p15; + pp13 = p13 + p14; + pp14 = (p12 - p15) * cos1_8; + pp15 = (p13 - p14) * cos3_8; + + p0 = pp0 + pp1; + p1 = (pp0 - pp1) * cos1_4; + p2 = pp2 + pp3; + p3 = (pp2 - pp3) * cos1_4; + p4 = pp4 + pp5; + p5 = (pp4 - pp5) * cos1_4; + p6 = pp6 + pp7; + p7 = (pp6 - pp7) * cos1_4; + p8 = pp8 + pp9; + p9 = (pp8 - pp9) * cos1_4; + p10 = pp10 + pp11; + p11 = (pp10 - pp11) * cos1_4; + p12 = pp12 + pp13; + p13 = (pp12 - pp13) * cos1_4; + p14 = pp14 + pp15; + p15 = (pp14 - pp15) * cos1_4; + + // this is pretty insane coding + @LOC("THIS,SynthesisFilter.NEWV") float tmp1; + new_v19/* 36-17 */= -(new_v4 = (new_v12 = p7) + p5) - p6; + new_v27/* 44-17 */= -p6 - p7 - p4; + new_v6 = (new_v10 = (new_v14 = p15) + p11) + p13; + new_v17/* 34-17 */= -(new_v2 = p15 + p13 + p9) - p14; + new_v21/* 38-17 */= (tmp1 = -p14 - p15 - p10 - p11) - p13; + new_v29/* 46-17 */= -p14 - p15 - p12 - p8; + new_v25/* 42-17 */= tmp1 - p12; + new_v31/* 48-17 */= -p0; + new_v0 = p1; + new_v23/* 40-17 */= -(new_v8 = p3) - p2; + + p0 = (s0 - s31) * cos1_64; + p1 = (s1 - s30) * cos3_64; + p2 = (s2 - s29) * cos5_64; + p3 = (s3 - s28) * cos7_64; + p4 = (s4 - s27) * cos9_64; + p5 = (s5 - s26) * cos11_64; + p6 = (s6 - s25) * cos13_64; + p7 = (s7 - s24) * cos15_64; + p8 = (s8 - s23) * cos17_64; + p9 = (s9 - s22) * cos19_64; + p10 = (s10 - s21) * cos21_64; + p11 = (s11 - s20) * cos23_64; + p12 = (s12 - s19) * cos25_64; + p13 = (s13 - s18) * cos27_64; + p14 = (s14 - s17) * cos29_64; + p15 = (s15 - s16) * cos31_64; + + pp0 = p0 + p15; + pp1 = p1 + p14; + pp2 = p2 + p13; + pp3 = p3 + p12; + pp4 = p4 + p11; + pp5 = p5 + p10; + pp6 = p6 + p9; + pp7 = p7 + p8; + pp8 = (p0 - p15) * cos1_32; + pp9 = (p1 - p14) * cos3_32; + pp10 = (p2 - p13) * cos5_32; + pp11 = (p3 - p12) * cos7_32; + pp12 = (p4 - p11) * cos9_32; + pp13 = (p5 - p10) * cos11_32; + pp14 = (p6 - p9) * cos13_32; + pp15 = (p7 - p8) * cos15_32; + + p0 = pp0 + pp7; + p1 = pp1 + pp6; + p2 = pp2 + pp5; + p3 = pp3 + pp4; + p4 = (pp0 - pp7) * cos1_16; + p5 = (pp1 - pp6) * cos3_16; + p6 = (pp2 - pp5) * cos5_16; + p7 = (pp3 - pp4) * cos7_16; + p8 = pp8 + pp15; + p9 = pp9 + pp14; + p10 = pp10 + pp13; + p11 = pp11 + pp12; + p12 = (pp8 - pp15) * cos1_16; + p13 = (pp9 - pp14) * cos3_16; + p14 = (pp10 - pp13) * cos5_16; + p15 = (pp11 - pp12) * cos7_16; + + pp0 = p0 + p3; + pp1 = p1 + p2; + pp2 = (p0 - p3) * cos1_8; + pp3 = (p1 - p2) * cos3_8; + pp4 = p4 + p7; + pp5 = p5 + p6; + pp6 = (p4 - p7) * cos1_8; + pp7 = (p5 - p6) * cos3_8; + pp8 = p8 + p11; + pp9 = p9 + p10; + pp10 = (p8 - p11) * cos1_8; + pp11 = (p9 - p10) * cos3_8; + pp12 = p12 + p15; + pp13 = p13 + p14; + pp14 = (p12 - p15) * cos1_8; + pp15 = (p13 - p14) * cos3_8; + + p0 = pp0 + pp1; + p1 = (pp0 - pp1) * cos1_4; + p2 = pp2 + pp3; + p3 = (pp2 - pp3) * cos1_4; + p4 = pp4 + pp5; + p5 = (pp4 - pp5) * cos1_4; + p6 = pp6 + pp7; + p7 = (pp6 - pp7) * cos1_4; + p8 = pp8 + pp9; + p9 = (pp8 - pp9) * cos1_4; + p10 = pp10 + pp11; + p11 = (pp10 - pp11) * cos1_4; + p12 = pp12 + pp13; + p13 = (pp12 - pp13) * cos1_4; + p14 = pp14 + pp15; + p15 = (pp14 - pp15) * cos1_4; + + // manually doing something that a compiler should handle sucks + // coding like this is hard to read + @LOC("THIS,SynthesisFilter.NEWV") float tmp2; + new_v5 = (new_v11 = (new_v13 = (new_v15 = p15) + p7) + p11) + p5 + p13; + new_v7 = (new_v9 = p15 + p11 + p3) + p13; + new_v16/* 33-17 */= -(new_v1 = (tmp1 = p13 + p15 + p9) + p1) - p14; + new_v18/* 35-17 */= -(new_v3 = tmp1 + p5 + p7) - p6 - p14; + + new_v22/* 39-17 */= (tmp1 = -p10 - p11 - p14 - p15) - p13 - p2 - p3; + new_v20/* 37-17 */= tmp1 - p13 - p5 - p6 - p7; + new_v24/* 41-17 */= tmp1 - p12 - p2 - p3; + new_v26/* 43-17 */= tmp1 - p12 - (tmp2 = p4 + p6 + p7); + new_v30/* 47-17 */= (tmp1 = -p8 - p12 - p14 - p15) - p0; + new_v28/* 45-17 */= tmp1 - tmp2; + + // insert V[0-15] (== new_v[0-15]) into actual v: + // float[] x2 = actual_v + actual_write_pos; + // float dest[] = actual_v; v2 + + @LOC("THIS,SynthesisFilter.NEWV") int pos = actual_write_pos; + + v2[0 + pos] = new_v0; + v2[16 + pos] = new_v1; + v2[32 + pos] = new_v2; + v2[48 + pos] = new_v3; + v2[64 + pos] = new_v4; + v2[80 + pos] = new_v5; + v2[96 + pos] = new_v6; + v2[112 + pos] = new_v7; + v2[128 + pos] = new_v8; + v2[144 + pos] = new_v9; + v2[160 + pos] = new_v10; + v2[176 + pos] = new_v11; + v2[192 + pos] = new_v12; + v2[208 + pos] = new_v13; + v2[224 + pos] = new_v14; + v2[240 + pos] = new_v15; + + // V[16] is always 0.0: + v2[256 + pos] = 0.0f; + + // insert V[17-31] (== -new_v[15-1]) into actual v: + v2[272 + pos] = -new_v15; + v2[288 + pos] = -new_v14; + v2[304 + pos] = -new_v13; + v2[320 + pos] = -new_v12; + v2[336 + pos] = -new_v11; + v2[352 + pos] = -new_v10; + v2[368 + pos] = -new_v9; + v2[384 + pos] = -new_v8; + v2[400 + pos] = -new_v7; + v2[416 + pos] = -new_v6; + v2[432 + pos] = -new_v5; + v2[448 + pos] = -new_v4; + v2[464 + pos] = -new_v3; + v2[480 + pos] = -new_v2; + v2[496 + pos] = -new_v1; + + // insert V[32] (== -new_v[0]) into other v: + // dest = (actual_v == v1) ? v2 : v1; + + v1[0 + pos] = -new_v0; + // insert V[33-48] (== new_v[16-31]) into other v: + v1[16 + pos] = new_v16; + v1[32 + pos] = new_v17; + v1[48 + pos] = new_v18; + v1[64 + pos] = new_v19; + v1[80 + pos] = new_v20; + v1[96 + pos] = new_v21; + v1[112 + pos] = new_v22; + v1[128 + pos] = new_v23; + v1[144 + pos] = new_v24; + v1[160 + pos] = new_v25; + v1[176 + pos] = new_v26; + v1[192 + pos] = new_v27; + v1[208 + pos] = new_v28; + v1[224 + pos] = new_v29; + v1[240 + pos] = new_v30; + v1[256 + pos] = new_v31; + + // insert V[49-63] (== new_v[30-16]) into other v: + v1[272 + pos] = new_v30; + v1[288 + pos] = new_v29; + v1[304 + pos] = new_v28; + v1[320 + pos] = new_v27; + v1[336 + pos] = new_v26; + v1[352 + pos] = new_v25; + v1[368 + pos] = new_v24; + v1[384 + pos] = new_v23; + v1[400 + pos] = new_v22; + v1[416 + pos] = new_v21; + v1[432 + pos] = new_v20; + v1[448 + pos] = new_v19; + v1[464 + pos] = new_v18; + v1[480 + pos] = new_v17; + v1[496 + pos] = new_v16; + + /* + * setup PREV + */ + + prev2[0 + pos] = new_v0; + prev2[16 + pos] = new_v1; + prev2[32 + pos] = new_v2; + prev2[48 + pos] = new_v3; + prev2[64 + pos] = new_v4; + prev2[80 + pos] = new_v5; + prev2[96 + pos] = new_v6; + prev2[112 + pos] = new_v7; + prev2[128 + pos] = new_v8; + prev2[144 + pos] = new_v9; + prev2[160 + pos] = new_v10; + prev2[176 + pos] = new_v11; + prev2[192 + pos] = new_v12; + prev2[208 + pos] = new_v13; + prev2[224 + pos] = new_v14; + prev2[240 + pos] = new_v15; + + // V[16] is always 0.0: + prev2[256 + pos] = 0.0f; + + // insert V[17-31] (== -new_v[15-1]) into actual v: + prev2[272 + pos] = -new_v15; + prev2[288 + pos] = -new_v14; + prev2[304 + pos] = -new_v13; + prev2[320 + pos] = -new_v12; + prev2[336 + pos] = -new_v11; + prev2[352 + pos] = -new_v10; + prev2[368 + pos] = -new_v9; + prev2[384 + pos] = -new_v8; + prev2[400 + pos] = -new_v7; + prev2[416 + pos] = -new_v6; + prev2[432 + pos] = -new_v5; + prev2[448 + pos] = -new_v4; + prev2[464 + pos] = -new_v3; + prev2[480 + pos] = -new_v2; + prev2[496 + pos] = -new_v1; + + // insert V[32] (== -new_v[0]) into other v: + // dest = (actual_v == v1) ? v2 : v1; + + prev1[0 + pos] = -new_v0; + // insert V[33-48] (== new_v[16-31]) into other v: + prev1[16 + pos] = new_v16; + prev1[32 + pos] = new_v17; + prev1[48 + pos] = new_v18; + prev1[64 + pos] = new_v19; + prev1[80 + pos] = new_v20; + prev1[96 + pos] = new_v21; + prev1[112 + pos] = new_v22; + prev1[128 + pos] = new_v23; + prev1[144 + pos] = new_v24; + prev1[160 + pos] = new_v25; + prev1[176 + pos] = new_v26; + prev1[192 + pos] = new_v27; + prev1[208 + pos] = new_v28; + prev1[224 + pos] = new_v29; + prev1[240 + pos] = new_v30; + prev1[256 + pos] = new_v31; + + // insert V[49-63] (== new_v[30-16]) into other v: + prev1[272 + pos] = new_v30; + prev1[288 + pos] = new_v29; + prev1[304 + pos] = new_v28; + prev1[320 + pos] = new_v27; + prev1[336 + pos] = new_v26; + prev1[352 + pos] = new_v25; + prev1[368 + pos] = new_v24; + prev1[384 + pos] = new_v23; + prev1[400 + pos] = new_v22; + prev1[416 + pos] = new_v21; + prev1[432 + pos] = new_v20; + prev1[448 + pos] = new_v19; + prev1[464 + pos] = new_v18; + prev1[480 + pos] = new_v17; + prev1[496 + pos] = new_v16; + } + + private void compute_new_v1_v2() { + + @LOC("THIS,SynthesisFilter.NEWV") float new_v0 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v1 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v2 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v3 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v4 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v5 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v6 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v7 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v8 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v9 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v10 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v11 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v12 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v13 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v14 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v15 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v16 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v17 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v18 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v19 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v20 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v21 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v22 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v23 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v24 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v25 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v26 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v27 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v28 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v29 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v30 = 0.0f; + @LOC("THIS,SynthesisFilter.NEWV") float new_v31 = 0.0f; + + // float[] new_v = new float[32]; // new V[0-15] and V[33-48] of Figure + // 3-A.2 in ISO DIS 11172-3 + // float[] p = new float[16]; + // float[] pp = new float[16]; + + // float[] s = samples; + + @LOC("THIS,SynthesisFilter.NEWV") float s0 = samples[0]; + @LOC("THIS,SynthesisFilter.NEWV") float s1 = samples[1]; + @LOC("THIS,SynthesisFilter.NEWV") float s2 = samples[2]; + @LOC("THIS,SynthesisFilter.NEWV") float s3 = samples[3]; + @LOC("THIS,SynthesisFilter.NEWV") float s4 = samples[4]; + @LOC("THIS,SynthesisFilter.NEWV") float s5 = samples[5]; + @LOC("THIS,SynthesisFilter.NEWV") float s6 = samples[6]; + @LOC("THIS,SynthesisFilter.NEWV") float s7 = samples[7]; + @LOC("THIS,SynthesisFilter.NEWV") float s8 = samples[8]; + @LOC("THIS,SynthesisFilter.NEWV") float s9 = samples[9]; + @LOC("THIS,SynthesisFilter.NEWV") float s10 = samples[10]; + @LOC("THIS,SynthesisFilter.NEWV") float s11 = samples[11]; + @LOC("THIS,SynthesisFilter.NEWV") float s12 = samples[12]; + @LOC("THIS,SynthesisFilter.NEWV") float s13 = samples[13]; + @LOC("THIS,SynthesisFilter.NEWV") float s14 = samples[14]; + @LOC("THIS,SynthesisFilter.NEWV") float s15 = samples[15]; + @LOC("THIS,SynthesisFilter.NEWV") float s16 = samples[16]; + @LOC("THIS,SynthesisFilter.NEWV") float s17 = samples[17]; + @LOC("THIS,SynthesisFilter.NEWV") float s18 = samples[18]; + @LOC("THIS,SynthesisFilter.NEWV") float s19 = samples[19]; + @LOC("THIS,SynthesisFilter.NEWV") float s20 = samples[20]; + @LOC("THIS,SynthesisFilter.NEWV") float s21 = samples[21]; + @LOC("THIS,SynthesisFilter.NEWV") float s22 = samples[22]; + @LOC("THIS,SynthesisFilter.NEWV") float s23 = samples[23]; + @LOC("THIS,SynthesisFilter.NEWV") float s24 = samples[24]; + @LOC("THIS,SynthesisFilter.NEWV") float s25 = samples[25]; + @LOC("THIS,SynthesisFilter.NEWV") float s26 = samples[26]; + @LOC("THIS,SynthesisFilter.NEWV") float s27 = samples[27]; + @LOC("THIS,SynthesisFilter.NEWV") float s28 = samples[28]; + @LOC("THIS,SynthesisFilter.NEWV") float s29 = samples[29]; + @LOC("THIS,SynthesisFilter.NEWV") float s30 = samples[30]; + @LOC("THIS,SynthesisFilter.NEWV") float s31 = samples[31]; + + @LOC("THIS,SynthesisFilter.NEWV") float p0 = s0 + s31; + @LOC("THIS,SynthesisFilter.NEWV") float p1 = s1 + s30; + @LOC("THIS,SynthesisFilter.NEWV") float p2 = s2 + s29; + @LOC("THIS,SynthesisFilter.NEWV") float p3 = s3 + s28; + @LOC("THIS,SynthesisFilter.NEWV") float p4 = s4 + s27; + @LOC("THIS,SynthesisFilter.NEWV") float p5 = s5 + s26; + @LOC("THIS,SynthesisFilter.NEWV") float p6 = s6 + s25; + @LOC("THIS,SynthesisFilter.NEWV") float p7 = s7 + s24; + @LOC("THIS,SynthesisFilter.NEWV") float p8 = s8 + s23; + @LOC("THIS,SynthesisFilter.NEWV") float p9 = s9 + s22; + @LOC("THIS,SynthesisFilter.NEWV") float p10 = s10 + s21; + @LOC("THIS,SynthesisFilter.NEWV") float p11 = s11 + s20; + @LOC("THIS,SynthesisFilter.NEWV") float p12 = s12 + s19; + @LOC("THIS,SynthesisFilter.NEWV") float p13 = s13 + s18; + @LOC("THIS,SynthesisFilter.NEWV") float p14 = s14 + s17; + @LOC("THIS,SynthesisFilter.NEWV") float p15 = s15 + s16; + + @LOC("THIS,SynthesisFilter.NEWV") float pp0 = p0 + p15; + @LOC("THIS,SynthesisFilter.NEWV") float pp1 = p1 + p14; + @LOC("THIS,SynthesisFilter.NEWV") float pp2 = p2 + p13; + @LOC("THIS,SynthesisFilter.NEWV") float pp3 = p3 + p12; + @LOC("THIS,SynthesisFilter.NEWV") float pp4 = p4 + p11; + @LOC("THIS,SynthesisFilter.NEWV") float pp5 = p5 + p10; + @LOC("THIS,SynthesisFilter.NEWV") float pp6 = p6 + p9; + @LOC("THIS,SynthesisFilter.NEWV") float pp7 = p7 + p8; + @LOC("THIS,SynthesisFilter.NEWV") float pp8 = (p0 - p15) * cos1_32; + @LOC("THIS,SynthesisFilter.NEWV") float pp9 = (p1 - p14) * cos3_32; + @LOC("THIS,SynthesisFilter.NEWV") float pp10 = (p2 - p13) * cos5_32; + @LOC("THIS,SynthesisFilter.NEWV") float pp11 = (p3 - p12) * cos7_32; + @LOC("THIS,SynthesisFilter.NEWV") float pp12 = (p4 - p11) * cos9_32; + @LOC("THIS,SynthesisFilter.NEWV") float pp13 = (p5 - p10) * cos11_32; + @LOC("THIS,SynthesisFilter.NEWV") float pp14 = (p6 - p9) * cos13_32; + @LOC("THIS,SynthesisFilter.NEWV") float pp15 = (p7 - p8) * cos15_32; + + p0 = pp0 + pp7; + p1 = pp1 + pp6; + p2 = pp2 + pp5; + p3 = pp3 + pp4; + p4 = (pp0 - pp7) * cos1_16; + p5 = (pp1 - pp6) * cos3_16; + p6 = (pp2 - pp5) * cos5_16; + p7 = (pp3 - pp4) * cos7_16; + p8 = pp8 + pp15; + p9 = pp9 + pp14; + p10 = pp10 + pp13; + p11 = pp11 + pp12; + p12 = (pp8 - pp15) * cos1_16; + p13 = (pp9 - pp14) * cos3_16; + p14 = (pp10 - pp13) * cos5_16; + p15 = (pp11 - pp12) * cos7_16; + + pp0 = p0 + p3; + pp1 = p1 + p2; + pp2 = (p0 - p3) * cos1_8; + pp3 = (p1 - p2) * cos3_8; + pp4 = p4 + p7; + pp5 = p5 + p6; + pp6 = (p4 - p7) * cos1_8; + pp7 = (p5 - p6) * cos3_8; + pp8 = p8 + p11; + pp9 = p9 + p10; + pp10 = (p8 - p11) * cos1_8; + pp11 = (p9 - p10) * cos3_8; + pp12 = p12 + p15; + pp13 = p13 + p14; + pp14 = (p12 - p15) * cos1_8; + pp15 = (p13 - p14) * cos3_8; + + p0 = pp0 + pp1; + p1 = (pp0 - pp1) * cos1_4; + p2 = pp2 + pp3; + p3 = (pp2 - pp3) * cos1_4; + p4 = pp4 + pp5; + p5 = (pp4 - pp5) * cos1_4; + p6 = pp6 + pp7; + p7 = (pp6 - pp7) * cos1_4; + p8 = pp8 + pp9; + p9 = (pp8 - pp9) * cos1_4; + p10 = pp10 + pp11; + p11 = (pp10 - pp11) * cos1_4; + p12 = pp12 + pp13; + p13 = (pp12 - pp13) * cos1_4; + p14 = pp14 + pp15; + p15 = (pp14 - pp15) * cos1_4; + + // this is pretty insane coding + @LOC("THIS,SynthesisFilter.NEWV") float tmp1; + new_v19/* 36-17 */= -(new_v4 = (new_v12 = p7) + p5) - p6; + new_v27/* 44-17 */= -p6 - p7 - p4; + new_v6 = (new_v10 = (new_v14 = p15) + p11) + p13; + new_v17/* 34-17 */= -(new_v2 = p15 + p13 + p9) - p14; + new_v21/* 38-17 */= (tmp1 = -p14 - p15 - p10 - p11) - p13; + new_v29/* 46-17 */= -p14 - p15 - p12 - p8; + new_v25/* 42-17 */= tmp1 - p12; + new_v31/* 48-17 */= -p0; + new_v0 = p1; + new_v23/* 40-17 */= -(new_v8 = p3) - p2; + + p0 = (s0 - s31) * cos1_64; + p1 = (s1 - s30) * cos3_64; + p2 = (s2 - s29) * cos5_64; + p3 = (s3 - s28) * cos7_64; + p4 = (s4 - s27) * cos9_64; + p5 = (s5 - s26) * cos11_64; + p6 = (s6 - s25) * cos13_64; + p7 = (s7 - s24) * cos15_64; + p8 = (s8 - s23) * cos17_64; + p9 = (s9 - s22) * cos19_64; + p10 = (s10 - s21) * cos21_64; + p11 = (s11 - s20) * cos23_64; + p12 = (s12 - s19) * cos25_64; + p13 = (s13 - s18) * cos27_64; + p14 = (s14 - s17) * cos29_64; + p15 = (s15 - s16) * cos31_64; + + pp0 = p0 + p15; + pp1 = p1 + p14; + pp2 = p2 + p13; + pp3 = p3 + p12; + pp4 = p4 + p11; + pp5 = p5 + p10; + pp6 = p6 + p9; + pp7 = p7 + p8; + pp8 = (p0 - p15) * cos1_32; + pp9 = (p1 - p14) * cos3_32; + pp10 = (p2 - p13) * cos5_32; + pp11 = (p3 - p12) * cos7_32; + pp12 = (p4 - p11) * cos9_32; + pp13 = (p5 - p10) * cos11_32; + pp14 = (p6 - p9) * cos13_32; + pp15 = (p7 - p8) * cos15_32; + + p0 = pp0 + pp7; + p1 = pp1 + pp6; + p2 = pp2 + pp5; + p3 = pp3 + pp4; + p4 = (pp0 - pp7) * cos1_16; + p5 = (pp1 - pp6) * cos3_16; + p6 = (pp2 - pp5) * cos5_16; + p7 = (pp3 - pp4) * cos7_16; + p8 = pp8 + pp15; + p9 = pp9 + pp14; + p10 = pp10 + pp13; + p11 = pp11 + pp12; + p12 = (pp8 - pp15) * cos1_16; + p13 = (pp9 - pp14) * cos3_16; + p14 = (pp10 - pp13) * cos5_16; + p15 = (pp11 - pp12) * cos7_16; + + pp0 = p0 + p3; + pp1 = p1 + p2; + pp2 = (p0 - p3) * cos1_8; + pp3 = (p1 - p2) * cos3_8; + pp4 = p4 + p7; + pp5 = p5 + p6; + pp6 = (p4 - p7) * cos1_8; + pp7 = (p5 - p6) * cos3_8; + pp8 = p8 + p11; + pp9 = p9 + p10; + pp10 = (p8 - p11) * cos1_8; + pp11 = (p9 - p10) * cos3_8; + pp12 = p12 + p15; + pp13 = p13 + p14; + pp14 = (p12 - p15) * cos1_8; + pp15 = (p13 - p14) * cos3_8; + + p0 = pp0 + pp1; + p1 = (pp0 - pp1) * cos1_4; + p2 = pp2 + pp3; + p3 = (pp2 - pp3) * cos1_4; + p4 = pp4 + pp5; + p5 = (pp4 - pp5) * cos1_4; + p6 = pp6 + pp7; + p7 = (pp6 - pp7) * cos1_4; + p8 = pp8 + pp9; + p9 = (pp8 - pp9) * cos1_4; + p10 = pp10 + pp11; + p11 = (pp10 - pp11) * cos1_4; + p12 = pp12 + pp13; + p13 = (pp12 - pp13) * cos1_4; + p14 = pp14 + pp15; + p15 = (pp14 - pp15) * cos1_4; + + // manually doing something that a compiler should handle sucks + // coding like this is hard to read + @LOC("THIS,SynthesisFilter.NEWV") float tmp2; + new_v5 = (new_v11 = (new_v13 = (new_v15 = p15) + p7) + p11) + p5 + p13; + new_v7 = (new_v9 = p15 + p11 + p3) + p13; + new_v16/* 33-17 */= -(new_v1 = (tmp1 = p13 + p15 + p9) + p1) - p14; + new_v18/* 35-17 */= -(new_v3 = tmp1 + p5 + p7) - p6 - p14; + + new_v22/* 39-17 */= (tmp1 = -p10 - p11 - p14 - p15) - p13 - p2 - p3; + new_v20/* 37-17 */= tmp1 - p13 - p5 - p6 - p7; + new_v24/* 41-17 */= tmp1 - p12 - p2 - p3; + new_v26/* 43-17 */= tmp1 - p12 - (tmp2 = p4 + p6 + p7); + new_v30/* 47-17 */= (tmp1 = -p8 - p12 - p14 - p15) - p0; + new_v28/* 45-17 */= tmp1 - tmp2; + + // insert V[0-15] (== new_v[0-15]) into actual v: + // float[] x2 = actual_v + actual_write_pos; + // float dest[] = actual_v; actual_v=v1; + + @LOC("THIS,SynthesisFilter.NEWV") int pos = actual_write_pos; + + v1[0 + pos] = new_v0; + v1[16 + pos] = new_v1; + v1[32 + pos] = new_v2; + v1[48 + pos] = new_v3; + v1[64 + pos] = new_v4; + v1[80 + pos] = new_v5; + v1[96 + pos] = new_v6; + v1[112 + pos] = new_v7; + v1[128 + pos] = new_v8; + v1[144 + pos] = new_v9; + v1[160 + pos] = new_v10; + v1[176 + pos] = new_v11; + v1[192 + pos] = new_v12; + v1[208 + pos] = new_v13; + v1[224 + pos] = new_v14; + v1[240 + pos] = new_v15; + + // V[16] is always 0.0: + v1[256 + pos] = 0.0f; + + // insert V[17-31] (== -new_v[15-1]) into actual v: + v1[272 + pos] = -new_v15; + v1[288 + pos] = -new_v14; + v1[304 + pos] = -new_v13; + v1[320 + pos] = -new_v12; + v1[336 + pos] = -new_v11; + v1[352 + pos] = -new_v10; + v1[368 + pos] = -new_v9; + v1[384 + pos] = -new_v8; + v1[400 + pos] = -new_v7; + v1[416 + pos] = -new_v6; + v1[432 + pos] = -new_v5; + v1[448 + pos] = -new_v4; + v1[464 + pos] = -new_v3; + v1[480 + pos] = -new_v2; + v1[496 + pos] = -new_v1; + + // insert V[32] (== -new_v[0]) into other v: + // dest = (actual_v == v1) ? v2 : v1; + + v2[0 + pos] = -new_v0; + // insert V[33-48] (== new_v[16-31]) into other v: + v2[16 + pos] = new_v16; + v2[32 + pos] = new_v17; + v2[48 + pos] = new_v18; + v2[64 + pos] = new_v19; + v2[80 + pos] = new_v20; + v2[96 + pos] = new_v21; + v2[112 + pos] = new_v22; + v2[128 + pos] = new_v23; + v2[144 + pos] = new_v24; + v2[160 + pos] = new_v25; + v2[176 + pos] = new_v26; + v2[192 + pos] = new_v27; + v2[208 + pos] = new_v28; + v2[224 + pos] = new_v29; + v2[240 + pos] = new_v30; + v2[256 + pos] = new_v31; + + // insert V[49-63] (== new_v[30-16]) into other v: + v2[272 + pos] = new_v30; + v2[288 + pos] = new_v29; + v2[304 + pos] = new_v28; + v2[320 + pos] = new_v27; + v2[336 + pos] = new_v26; + v2[352 + pos] = new_v25; + v2[368 + pos] = new_v24; + v2[384 + pos] = new_v23; + v2[400 + pos] = new_v22; + v2[416 + pos] = new_v21; + v2[432 + pos] = new_v20; + v2[448 + pos] = new_v19; + v2[464 + pos] = new_v18; + v2[480 + pos] = new_v17; + v2[496 + pos] = new_v16; + + /* + * setup PREV + */ + + prev1[0 + pos] = new_v0; + prev1[16 + pos] = new_v1; + prev1[32 + pos] = new_v2; + prev1[48 + pos] = new_v3; + prev1[64 + pos] = new_v4; + prev1[80 + pos] = new_v5; + prev1[96 + pos] = new_v6; + prev1[112 + pos] = new_v7; + prev1[128 + pos] = new_v8; + prev1[144 + pos] = new_v9; + prev1[160 + pos] = new_v10; + prev1[176 + pos] = new_v11; + prev1[192 + pos] = new_v12; + prev1[208 + pos] = new_v13; + prev1[224 + pos] = new_v14; + prev1[240 + pos] = new_v15; + + // V[16] is always 0.0: + prev1[256 + pos] = 0.0f; + + // insert V[17-31] (== -new_v[15-1]) into actual v: + prev1[272 + pos] = -new_v15; + prev1[288 + pos] = -new_v14; + prev1[304 + pos] = -new_v13; + prev1[320 + pos] = -new_v12; + prev1[336 + pos] = -new_v11; + prev1[352 + pos] = -new_v10; + prev1[368 + pos] = -new_v9; + prev1[384 + pos] = -new_v8; + prev1[400 + pos] = -new_v7; + prev1[416 + pos] = -new_v6; + prev1[432 + pos] = -new_v5; + prev1[448 + pos] = -new_v4; + prev1[464 + pos] = -new_v3; + prev1[480 + pos] = -new_v2; + prev1[496 + pos] = -new_v1; + + // insert V[32] (== -new_v[0]) into other v: + // dest = (actual_v == v1) ? v2 : v1; + + prev2[0 + pos] = -new_v0; + // insert V[33-48] (== new_v[16-31]) into other v: + prev2[16 + pos] = new_v16; + prev2[32 + pos] = new_v17; + prev2[48 + pos] = new_v18; + prev2[64 + pos] = new_v19; + prev2[80 + pos] = new_v20; + prev2[96 + pos] = new_v21; + prev2[112 + pos] = new_v22; + prev2[128 + pos] = new_v23; + prev2[144 + pos] = new_v24; + prev2[160 + pos] = new_v25; + prev2[176 + pos] = new_v26; + prev2[192 + pos] = new_v27; + prev2[208 + pos] = new_v28; + prev2[224 + pos] = new_v29; + prev2[240 + pos] = new_v30; + prev2[256 + pos] = new_v31; + + // insert V[49-63] (== new_v[30-16]) into other v: + prev2[272 + pos] = new_v30; + prev2[288 + pos] = new_v29; + prev2[304 + pos] = new_v28; + prev2[320 + pos] = new_v27; + prev2[336 + pos] = new_v26; + prev2[352 + pos] = new_v25; + prev2[368 + pos] = new_v24; + prev2[384 + pos] = new_v23; + prev2[400 + pos] = new_v22; + prev2[416 + pos] = new_v21; + prev2[432 + pos] = new_v20; + prev2[448 + pos] = new_v19; + prev2[464 + pos] = new_v18; + prev2[480 + pos] = new_v17; + prev2[496 + pos] = new_v16; + } + + /** + * Compute PCM Samples. + */ + + @LOC("OUT") + private float[] _tmpOut = new float[32]; + + private void compute_pcm_samples0() { + + if (vidx == 1) { + // final float[] vp = actual_v; + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + // final float[] dp = d16[i]; + pcm_sample = + (float) (((v1[0 + dvp] * d16[i][0]) + (v1[15 + dvp] * d16[i][1]) + + (v1[14 + dvp] * d16[i][2]) + (v1[13 + dvp] * d16[i][3]) + + (v1[12 + dvp] * d16[i][4]) + (v1[11 + dvp] * d16[i][5]) + + (v1[10 + dvp] * d16[i][6]) + (v1[9 + dvp] * d16[i][7]) + + (v1[8 + dvp] * d16[i][8]) + (v1[7 + dvp] * d16[i][9]) + + (v1[6 + dvp] * d16[i][10]) + (v1[5 + dvp] * d16[i][11]) + + (v1[4 + dvp] * d16[i][12]) + (v1[3 + dvp] * d16[i][13]) + + (v1[2 + dvp] * d16[i][14]) + (v1[1 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } else { + // final float[] vp = actual_v; + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + // final float[] dp = d16[i]; + pcm_sample = + (float) (((v2[0 + dvp] * d16[i][0]) + (v2[15 + dvp] * d16[i][1]) + + (v2[14 + dvp] * d16[i][2]) + (v2[13 + dvp] * d16[i][3]) + + (v2[12 + dvp] * d16[i][4]) + (v2[11 + dvp] * d16[i][5]) + + (v2[10 + dvp] * d16[i][6]) + (v2[9 + dvp] * d16[i][7]) + + (v2[8 + dvp] * d16[i][8]) + (v2[7 + dvp] * d16[i][9]) + + (v2[6 + dvp] * d16[i][10]) + (v2[5 + dvp] * d16[i][11]) + + (v2[4 + dvp] * d16[i][12]) + (v2[3 + dvp] * d16[i][13]) + + (v2[2 + dvp] * d16[i][14]) + (v2[1 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } + + } + + private void compute_pcm_samples1() { + + if (vidx == 1) { + // final float[] vp = actual_v; + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v1[1 + dvp] * d16[i][0]) + (v1[0 + dvp] * d16[i][1]) + + (v1[15 + dvp] * d16[i][2]) + (v1[14 + dvp] * d16[i][3]) + + (v1[13 + dvp] * d16[i][4]) + (v1[12 + dvp] * d16[i][5]) + + (v1[11 + dvp] * d16[i][6]) + (v1[10 + dvp] * d16[i][7]) + + (v1[9 + dvp] * d16[i][8]) + (v1[8 + dvp] * d16[i][9]) + + (v1[7 + dvp] * d16[i][10]) + (v1[6 + dvp] * d16[i][11]) + + (v1[5 + dvp] * d16[i][12]) + (v1[4 + dvp] * d16[i][13]) + + (v1[3 + dvp] * d16[i][14]) + (v1[2 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } else { + // final float[] vp = actual_v; + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v2[1 + dvp] * d16[i][0]) + (v2[0 + dvp] * d16[i][1]) + + (v2[15 + dvp] * d16[i][2]) + (v2[14 + dvp] * d16[i][3]) + + (v2[13 + dvp] * d16[i][4]) + (v2[12 + dvp] * d16[i][5]) + + (v2[11 + dvp] * d16[i][6]) + (v2[10 + dvp] * d16[i][7]) + + (v2[9 + dvp] * d16[i][8]) + (v2[8 + dvp] * d16[i][9]) + + (v2[7 + dvp] * d16[i][10]) + (v2[6 + dvp] * d16[i][11]) + + (v2[5 + dvp] * d16[i][12]) + (v2[4 + dvp] * d16[i][13]) + + (v2[3 + dvp] * d16[i][14]) + (v2[2 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } + + } + + private void compute_pcm_samples2() { + + if (vidx == 1) { + // final float[] vp = actual_v; + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v1[2 + dvp] * d16[i][0]) + (v1[1 + dvp] * d16[i][1]) + + (v1[0 + dvp] * d16[i][2]) + (v1[15 + dvp] * d16[i][3]) + + (v1[14 + dvp] * d16[i][4]) + (v1[13 + dvp] * d16[i][5]) + + (v1[12 + dvp] * d16[i][6]) + (v1[11 + dvp] * d16[i][7]) + + (v1[10 + dvp] * d16[i][8]) + (v1[9 + dvp] * d16[i][9]) + + (v1[8 + dvp] * d16[i][10]) + (v1[7 + dvp] * d16[i][11]) + + (v1[6 + dvp] * d16[i][12]) + (v1[5 + dvp] * d16[i][13]) + + (v1[4 + dvp] * d16[i][14]) + (v1[3 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } else { + // final float[] vp = actual_v; + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v2[2 + dvp] * d16[i][0]) + (v2[1 + dvp] * d16[i][1]) + + (v2[0 + dvp] * d16[i][2]) + (v2[15 + dvp] * d16[i][3]) + + (v2[14 + dvp] * d16[i][4]) + (v2[13 + dvp] * d16[i][5]) + + (v2[12 + dvp] * d16[i][6]) + (v2[11 + dvp] * d16[i][7]) + + (v2[10 + dvp] * d16[i][8]) + (v2[9 + dvp] * d16[i][9]) + + (v2[8 + dvp] * d16[i][10]) + (v2[7 + dvp] * d16[i][11]) + + (v2[6 + dvp] * d16[i][12]) + (v2[5 + dvp] * d16[i][13]) + + (v2[4 + dvp] * d16[i][14]) + (v2[3 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } + + } + + private void compute_pcm_samples3() { + + if (vidx == 1) { + // final float[] vp = actual_v; + + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v1[3 + dvp] * d16[i][0]) + (v1[2 + dvp] * d16[i][1]) + + (v1[1 + dvp] * d16[i][2]) + (v1[0 + dvp] * d16[i][3]) + + (v1[15 + dvp] * d16[i][4]) + (v1[14 + dvp] * d16[i][5]) + + (v1[13 + dvp] * d16[i][6]) + (v1[12 + dvp] * d16[i][7]) + + (v1[11 + dvp] * d16[i][8]) + (v1[10 + dvp] * d16[i][9]) + + (v1[9 + dvp] * d16[i][10]) + (v1[8 + dvp] * d16[i][11]) + + (v1[7 + dvp] * d16[i][12]) + (v1[6 + dvp] * d16[i][13]) + + (v1[5 + dvp] * d16[i][14]) + (v1[4 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } else { + // final float[] vp = actual_v; + + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v2[3 + dvp] * d16[i][0]) + (v2[2 + dvp] * d16[i][1]) + + (v2[1 + dvp] * d16[i][2]) + (v2[0 + dvp] * d16[i][3]) + + (v2[15 + dvp] * d16[i][4]) + (v2[14 + dvp] * d16[i][5]) + + (v2[13 + dvp] * d16[i][6]) + (v2[12 + dvp] * d16[i][7]) + + (v2[11 + dvp] * d16[i][8]) + (v2[10 + dvp] * d16[i][9]) + + (v2[9 + dvp] * d16[i][10]) + (v2[8 + dvp] * d16[i][11]) + + (v2[7 + dvp] * d16[i][12]) + (v2[6 + dvp] * d16[i][13]) + + (v2[5 + dvp] * d16[i][14]) + (v2[4 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } + + } + + private void compute_pcm_samples4() { + + if (vidx == 1) { + // final float[] vp = actual_v; + + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v1[4 + dvp] * d16[i][0]) + (v1[3 + dvp] * d16[i][1]) + + (v1[2 + dvp] * d16[i][2]) + (v1[1 + dvp] * d16[i][3]) + (v1[0 + dvp] * d16[i][4]) + + (v1[15 + dvp] * d16[i][5]) + (v1[14 + dvp] * d16[i][6]) + + (v1[13 + dvp] * d16[i][7]) + (v1[12 + dvp] * d16[i][8]) + + (v1[11 + dvp] * d16[i][9]) + (v1[10 + dvp] * d16[i][10]) + + (v1[9 + dvp] * d16[i][11]) + (v1[8 + dvp] * d16[i][12]) + + (v1[7 + dvp] * d16[i][13]) + (v1[6 + dvp] * d16[i][14]) + (v1[5 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } else { + // final float[] vp = actual_v; + + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v2[4 + dvp] * d16[i][0]) + (v2[3 + dvp] * d16[i][1]) + + (v2[2 + dvp] * d16[i][2]) + (v2[1 + dvp] * d16[i][3]) + (v2[0 + dvp] * d16[i][4]) + + (v2[15 + dvp] * d16[i][5]) + (v2[14 + dvp] * d16[i][6]) + + (v2[13 + dvp] * d16[i][7]) + (v2[12 + dvp] * d16[i][8]) + + (v2[11 + dvp] * d16[i][9]) + (v2[10 + dvp] * d16[i][10]) + + (v2[9 + dvp] * d16[i][11]) + (v2[8 + dvp] * d16[i][12]) + + (v2[7 + dvp] * d16[i][13]) + (v2[6 + dvp] * d16[i][14]) + (v2[5 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } + + } + + private void compute_pcm_samples5() { + + if (vidx == 1) { + // final float[] vp = actual_v; + + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v1[5 + dvp] * d16[i][0]) + (v1[4 + dvp] * d16[i][1]) + + (v1[3 + dvp] * d16[i][2]) + (v1[2 + dvp] * d16[i][3]) + (v1[1 + dvp] * d16[i][4]) + + (v1[0 + dvp] * d16[i][5]) + (v1[15 + dvp] * d16[i][6]) + + (v1[14 + dvp] * d16[i][7]) + (v1[13 + dvp] * d16[i][8]) + + (v1[12 + dvp] * d16[i][9]) + (v1[11 + dvp] * d16[i][10]) + + (v1[10 + dvp] * d16[i][11]) + (v1[9 + dvp] * d16[i][12]) + + (v1[8 + dvp] * d16[i][13]) + (v1[7 + dvp] * d16[i][14]) + (v1[6 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } else { + // final float[] vp = actual_v; + + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v2[5 + dvp] * d16[i][0]) + (v2[4 + dvp] * d16[i][1]) + + (v2[3 + dvp] * d16[i][2]) + (v2[2 + dvp] * d16[i][3]) + (v2[1 + dvp] * d16[i][4]) + + (v2[0 + dvp] * d16[i][5]) + (v2[15 + dvp] * d16[i][6]) + + (v2[14 + dvp] * d16[i][7]) + (v2[13 + dvp] * d16[i][8]) + + (v2[12 + dvp] * d16[i][9]) + (v2[11 + dvp] * d16[i][10]) + + (v2[10 + dvp] * d16[i][11]) + (v2[9 + dvp] * d16[i][12]) + + (v2[8 + dvp] * d16[i][13]) + (v2[7 + dvp] * d16[i][14]) + (v2[6 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } + + } + + private void compute_pcm_samples6() { + + if (vidx == 1) { + + // final float[] vp = actual_v; + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v1[6 + dvp] * d16[i][0]) + (v1[5 + dvp] * d16[i][1]) + + (v1[4 + dvp] * d16[i][2]) + (v1[3 + dvp] * d16[i][3]) + (v1[2 + dvp] * d16[i][4]) + + (v1[1 + dvp] * d16[i][5]) + (v1[0 + dvp] * d16[i][6]) + + (v1[15 + dvp] * d16[i][7]) + (v1[14 + dvp] * d16[i][8]) + + (v1[13 + dvp] * d16[i][9]) + (v1[12 + dvp] * d16[i][10]) + + (v1[11 + dvp] * d16[i][11]) + (v1[10 + dvp] * d16[i][12]) + + (v1[9 + dvp] * d16[i][13]) + (v1[8 + dvp] * d16[i][14]) + (v1[7 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } else { + + // final float[] vp = actual_v; + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v2[6 + dvp] * d16[i][0]) + (v2[5 + dvp] * d16[i][1]) + + (v2[4 + dvp] * d16[i][2]) + (v2[3 + dvp] * d16[i][3]) + (v2[2 + dvp] * d16[i][4]) + + (v2[1 + dvp] * d16[i][5]) + (v2[0 + dvp] * d16[i][6]) + + (v2[15 + dvp] * d16[i][7]) + (v2[14 + dvp] * d16[i][8]) + + (v2[13 + dvp] * d16[i][9]) + (v2[12 + dvp] * d16[i][10]) + + (v2[11 + dvp] * d16[i][11]) + (v2[10 + dvp] * d16[i][12]) + + (v2[9 + dvp] * d16[i][13]) + (v2[8 + dvp] * d16[i][14]) + (v2[7 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } + + } + + private void compute_pcm_samples7() { + + if (vidx == 1) { + // final float[] vp = actual_v; + + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v1[7 + dvp] * d16[i][0]) + (v1[6 + dvp] * d16[i][1]) + + (v1[5 + dvp] * d16[i][2]) + (v1[4 + dvp] * d16[i][3]) + (v1[3 + dvp] * d16[i][4]) + + (v1[2 + dvp] * d16[i][5]) + (v1[1 + dvp] * d16[i][6]) + (v1[0 + dvp] * d16[i][7]) + + (v1[15 + dvp] * d16[i][8]) + (v1[14 + dvp] * d16[i][9]) + + (v1[13 + dvp] * d16[i][10]) + (v1[12 + dvp] * d16[i][11]) + + (v1[11 + dvp] * d16[i][12]) + (v1[10 + dvp] * d16[i][13]) + + (v1[9 + dvp] * d16[i][14]) + (v1[8 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } else { + // final float[] vp = actual_v; + + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v2[7 + dvp] * d16[i][0]) + (v2[6 + dvp] * d16[i][1]) + + (v2[5 + dvp] * d16[i][2]) + (v2[4 + dvp] * d16[i][3]) + (v2[3 + dvp] * d16[i][4]) + + (v2[2 + dvp] * d16[i][5]) + (v2[1 + dvp] * d16[i][6]) + (v2[0 + dvp] * d16[i][7]) + + (v2[15 + dvp] * d16[i][8]) + (v2[14 + dvp] * d16[i][9]) + + (v2[13 + dvp] * d16[i][10]) + (v2[12 + dvp] * d16[i][11]) + + (v2[11 + dvp] * d16[i][12]) + (v2[10 + dvp] * d16[i][13]) + + (v2[9 + dvp] * d16[i][14]) + (v2[8 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } + + } + + private void compute_pcm_samples8() { + + if (vidx == 1) { + + // final float[] vp = actual_v; + + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v1[8 + dvp] * d16[i][0]) + (v1[7 + dvp] * d16[i][1]) + + (v1[6 + dvp] * d16[i][2]) + (v1[5 + dvp] * d16[i][3]) + (v1[4 + dvp] * d16[i][4]) + + (v1[3 + dvp] * d16[i][5]) + (v1[2 + dvp] * d16[i][6]) + (v1[1 + dvp] * d16[i][7]) + + (v1[0 + dvp] * d16[i][8]) + (v1[15 + dvp] * d16[i][9]) + + (v1[14 + dvp] * d16[i][10]) + (v1[13 + dvp] * d16[i][11]) + + (v1[12 + dvp] * d16[i][12]) + (v1[11 + dvp] * d16[i][13]) + + (v1[10 + dvp] * d16[i][14]) + (v1[9 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } else { + + // final float[] vp = actual_v; + + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v2[8 + dvp] * d16[i][0]) + (v2[7 + dvp] * d16[i][1]) + + (v2[6 + dvp] * d16[i][2]) + (v2[5 + dvp] * d16[i][3]) + (v2[4 + dvp] * d16[i][4]) + + (v2[3 + dvp] * d16[i][5]) + (v2[2 + dvp] * d16[i][6]) + (v2[1 + dvp] * d16[i][7]) + + (v2[0 + dvp] * d16[i][8]) + (v2[15 + dvp] * d16[i][9]) + + (v2[14 + dvp] * d16[i][10]) + (v2[13 + dvp] * d16[i][11]) + + (v2[12 + dvp] * d16[i][12]) + (v2[11 + dvp] * d16[i][13]) + + (v2[10 + dvp] * d16[i][14]) + (v2[9 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } + + } + + private void compute_pcm_samples9() { + + if (vidx == 1) { + // final float[] vp = actual_v; + + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v1[9 + dvp] * d16[i][0]) + (v1[8 + dvp] * d16[i][1]) + + (v1[7 + dvp] * d16[i][2]) + (v1[6 + dvp] * d16[i][3]) + (v1[5 + dvp] * d16[i][4]) + + (v1[4 + dvp] * d16[i][5]) + (v1[3 + dvp] * d16[i][6]) + (v1[2 + dvp] * d16[i][7]) + + (v1[1 + dvp] * d16[i][8]) + (v1[0 + dvp] * d16[i][9]) + + (v1[15 + dvp] * d16[i][10]) + (v1[14 + dvp] * d16[i][11]) + + (v1[13 + dvp] * d16[i][12]) + (v1[12 + dvp] * d16[i][13]) + + (v1[11 + dvp] * d16[i][14]) + (v1[10 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } else { + // final float[] vp = actual_v; + + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v2[9 + dvp] * d16[i][0]) + (v2[8 + dvp] * d16[i][1]) + + (v2[7 + dvp] * d16[i][2]) + (v2[6 + dvp] * d16[i][3]) + (v2[5 + dvp] * d16[i][4]) + + (v2[4 + dvp] * d16[i][5]) + (v2[3 + dvp] * d16[i][6]) + (v2[2 + dvp] * d16[i][7]) + + (v2[1 + dvp] * d16[i][8]) + (v2[0 + dvp] * d16[i][9]) + + (v2[15 + dvp] * d16[i][10]) + (v2[14 + dvp] * d16[i][11]) + + (v2[13 + dvp] * d16[i][12]) + (v2[12 + dvp] * d16[i][13]) + + (v2[11 + dvp] * d16[i][14]) + (v2[10 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } + + } + + private void compute_pcm_samples10() { + if (vidx == 1) { + // final float[] vp = actual_v; + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v1[10 + dvp] * d16[i][0]) + (v1[9 + dvp] * d16[i][1]) + + (v1[8 + dvp] * d16[i][2]) + (v1[7 + dvp] * d16[i][3]) + (v1[6 + dvp] * d16[i][4]) + + (v1[5 + dvp] * d16[i][5]) + (v1[4 + dvp] * d16[i][6]) + (v1[3 + dvp] * d16[i][7]) + + (v1[2 + dvp] * d16[i][8]) + (v1[1 + dvp] * d16[i][9]) + + (v1[0 + dvp] * d16[i][10]) + (v1[15 + dvp] * d16[i][11]) + + (v1[14 + dvp] * d16[i][12]) + (v1[13 + dvp] * d16[i][13]) + + (v1[12 + dvp] * d16[i][14]) + (v1[11 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } else { + // final float[] vp = actual_v; + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v2[10 + dvp] * d16[i][0]) + (v2[9 + dvp] * d16[i][1]) + + (v2[8 + dvp] * d16[i][2]) + (v2[7 + dvp] * d16[i][3]) + (v2[6 + dvp] * d16[i][4]) + + (v2[5 + dvp] * d16[i][5]) + (v2[4 + dvp] * d16[i][6]) + (v2[3 + dvp] * d16[i][7]) + + (v2[2 + dvp] * d16[i][8]) + (v2[1 + dvp] * d16[i][9]) + + (v2[0 + dvp] * d16[i][10]) + (v2[15 + dvp] * d16[i][11]) + + (v2[14 + dvp] * d16[i][12]) + (v2[13 + dvp] * d16[i][13]) + + (v2[12 + dvp] * d16[i][14]) + (v2[11 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } + + } + + private void compute_pcm_samples11() { + + if (vidx == 1) { + // final float[] vp = actual_v; + + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v1[11 + dvp] * d16[i][0]) + (v1[10 + dvp] * d16[i][1]) + + (v1[9 + dvp] * d16[i][2]) + (v1[8 + dvp] * d16[i][3]) + (v1[7 + dvp] * d16[i][4]) + + (v1[6 + dvp] * d16[i][5]) + (v1[5 + dvp] * d16[i][6]) + (v1[4 + dvp] * d16[i][7]) + + (v1[3 + dvp] * d16[i][8]) + (v1[2 + dvp] * d16[i][9]) + + (v1[1 + dvp] * d16[i][10]) + (v1[0 + dvp] * d16[i][11]) + + (v1[15 + dvp] * d16[i][12]) + (v1[14 + dvp] * d16[i][13]) + + (v1[13 + dvp] * d16[i][14]) + (v1[12 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } else { + // final float[] vp = actual_v; + + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v2[11 + dvp] * d16[i][0]) + (v2[10 + dvp] * d16[i][1]) + + (v2[9 + dvp] * d16[i][2]) + (v2[8 + dvp] * d16[i][3]) + (v2[7 + dvp] * d16[i][4]) + + (v2[6 + dvp] * d16[i][5]) + (v2[5 + dvp] * d16[i][6]) + (v2[4 + dvp] * d16[i][7]) + + (v2[3 + dvp] * d16[i][8]) + (v2[2 + dvp] * d16[i][9]) + + (v2[1 + dvp] * d16[i][10]) + (v2[0 + dvp] * d16[i][11]) + + (v2[15 + dvp] * d16[i][12]) + (v2[14 + dvp] * d16[i][13]) + + (v2[13 + dvp] * d16[i][14]) + (v2[12 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } + + } + + private void compute_pcm_samples12() { + + if (vidx == 1) { + // final float[] vp = actual_v; + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v1[12 + dvp] * d16[i][0]) + (v1[11 + dvp] * d16[i][1]) + + (v1[10 + dvp] * d16[i][2]) + (v1[9 + dvp] * d16[i][3]) + + (v1[8 + dvp] * d16[i][4]) + (v1[7 + dvp] * d16[i][5]) + (v1[6 + dvp] * d16[i][6]) + + (v1[5 + dvp] * d16[i][7]) + (v1[4 + dvp] * d16[i][8]) + (v1[3 + dvp] * d16[i][9]) + + (v1[2 + dvp] * d16[i][10]) + (v1[1 + dvp] * d16[i][11]) + + (v1[0 + dvp] * d16[i][12]) + (v1[15 + dvp] * d16[i][13]) + + (v1[14 + dvp] * d16[i][14]) + (v1[13 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } else { + // final float[] vp = actual_v; + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v2[12 + dvp] * d16[i][0]) + (v2[11 + dvp] * d16[i][1]) + + (v2[10 + dvp] * d16[i][2]) + (v2[9 + dvp] * d16[i][3]) + + (v2[8 + dvp] * d16[i][4]) + (v2[7 + dvp] * d16[i][5]) + (v2[6 + dvp] * d16[i][6]) + + (v2[5 + dvp] * d16[i][7]) + (v2[4 + dvp] * d16[i][8]) + (v2[3 + dvp] * d16[i][9]) + + (v2[2 + dvp] * d16[i][10]) + (v2[1 + dvp] * d16[i][11]) + + (v2[0 + dvp] * d16[i][12]) + (v2[15 + dvp] * d16[i][13]) + + (v2[14 + dvp] * d16[i][14]) + (v2[13 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } + + } + + private void compute_pcm_samples13() { + + if (vidx == 1) { + // final float[] vp = actual_v; + + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v1[13 + dvp] * d16[i][0]) + (v1[12 + dvp] * d16[i][1]) + + (v1[11 + dvp] * d16[i][2]) + (v1[10 + dvp] * d16[i][3]) + + (v1[9 + dvp] * d16[i][4]) + (v1[8 + dvp] * d16[i][5]) + (v1[7 + dvp] * d16[i][6]) + + (v1[6 + dvp] * d16[i][7]) + (v1[5 + dvp] * d16[i][8]) + (v1[4 + dvp] * d16[i][9]) + + (v1[3 + dvp] * d16[i][10]) + (v1[2 + dvp] * d16[i][11]) + + (v1[1 + dvp] * d16[i][12]) + (v1[0 + dvp] * d16[i][13]) + + (v1[15 + dvp] * d16[i][14]) + (v1[14 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } else { + // final float[] vp = actual_v; + + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v2[13 + dvp] * d16[i][0]) + (v2[12 + dvp] * d16[i][1]) + + (v2[11 + dvp] * d16[i][2]) + (v2[10 + dvp] * d16[i][3]) + + (v2[9 + dvp] * d16[i][4]) + (v2[8 + dvp] * d16[i][5]) + (v2[7 + dvp] * d16[i][6]) + + (v2[6 + dvp] * d16[i][7]) + (v2[5 + dvp] * d16[i][8]) + (v2[4 + dvp] * d16[i][9]) + + (v2[3 + dvp] * d16[i][10]) + (v2[2 + dvp] * d16[i][11]) + + (v2[1 + dvp] * d16[i][12]) + (v2[0 + dvp] * d16[i][13]) + + (v2[15 + dvp] * d16[i][14]) + (v2[14 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } + + } + + private void compute_pcm_samples14() { + + if (vidx == 1) { + // final float[] vp = actual_v; + + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v1[14 + dvp] * d16[i][0]) + (v1[13 + dvp] * d16[i][1]) + + (v1[12 + dvp] * d16[i][2]) + (v1[11 + dvp] * d16[i][3]) + + (v1[10 + dvp] * d16[i][4]) + (v1[9 + dvp] * d16[i][5]) + + (v1[8 + dvp] * d16[i][6]) + (v1[7 + dvp] * d16[i][7]) + (v1[6 + dvp] * d16[i][8]) + + (v1[5 + dvp] * d16[i][9]) + (v1[4 + dvp] * d16[i][10]) + + (v1[3 + dvp] * d16[i][11]) + (v1[2 + dvp] * d16[i][12]) + + (v1[1 + dvp] * d16[i][13]) + (v1[0 + dvp] * d16[i][14]) + (v1[15 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } else { + // final float[] vp = actual_v; + + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + // final float[] dp = d16[i]; + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + + pcm_sample = + (float) (((v2[14 + dvp] * d16[i][0]) + (v2[13 + dvp] * d16[i][1]) + + (v2[12 + dvp] * d16[i][2]) + (v2[11 + dvp] * d16[i][3]) + + (v2[10 + dvp] * d16[i][4]) + (v2[9 + dvp] * d16[i][5]) + + (v2[8 + dvp] * d16[i][6]) + (v2[7 + dvp] * d16[i][7]) + (v2[6 + dvp] * d16[i][8]) + + (v2[5 + dvp] * d16[i][9]) + (v2[4 + dvp] * d16[i][10]) + + (v2[3 + dvp] * d16[i][11]) + (v2[2 + dvp] * d16[i][12]) + + (v2[1 + dvp] * d16[i][13]) + (v2[0 + dvp] * d16[i][14]) + (v2[15 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + + dvp += 16; + } // for + } + + } + + private void compute_pcm_samples15() { + if (vidx == 1) { + // final float[] vp = actual_v; + + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + // final float d16[i][] = d16[i]; + pcm_sample = + (float) (((v1[15 + dvp] * d16[i][0]) + (v1[14 + dvp] * d16[i][1]) + + (v1[13 + dvp] * d16[i][2]) + (v1[12 + dvp] * d16[i][3]) + + (v1[11 + dvp] * d16[i][4]) + (v1[10 + dvp] * d16[i][5]) + + (v1[9 + dvp] * d16[i][6]) + (v1[8 + dvp] * d16[i][7]) + (v1[7 + dvp] * d16[i][8]) + + (v1[6 + dvp] * d16[i][9]) + (v1[5 + dvp] * d16[i][10]) + + (v1[4 + dvp] * d16[i][11]) + (v1[3 + dvp] * d16[i][12]) + + (v1[2 + dvp] * d16[i][13]) + (v1[1 + dvp] * d16[i][14]) + (v1[0 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + dvp += 16; + } // for + } else { + // final float[] vp = actual_v; + + // int inc = v_inc; + // final float[] tmpOut = _tmpOut; + @LOC("THIS,SynthesisFilter.NEWV") int dvp = 0; + + // fat chance of having this loop unroll + for (@LOC("THIS,SynthesisFilter.NEWV") int i = 0; i < 32; i++) { + @LOC("THIS,SynthesisFilter.V2") float pcm_sample; + // final float d16[i][] = d16[i]; + pcm_sample = + (float) (((v2[15 + dvp] * d16[i][0]) + (v2[14 + dvp] * d16[i][1]) + + (v2[13 + dvp] * d16[i][2]) + (v2[12 + dvp] * d16[i][3]) + + (v2[11 + dvp] * d16[i][4]) + (v2[10 + dvp] * d16[i][5]) + + (v2[9 + dvp] * d16[i][6]) + (v2[8 + dvp] * d16[i][7]) + (v2[7 + dvp] * d16[i][8]) + + (v2[6 + dvp] * d16[i][9]) + (v2[5 + dvp] * d16[i][10]) + + (v2[4 + dvp] * d16[i][11]) + (v2[3 + dvp] * d16[i][12]) + + (v2[2 + dvp] * d16[i][13]) + (v2[1 + dvp] * d16[i][14]) + (v2[0 + dvp] * d16[i][15])) * scalefactor); + + _tmpOut[i] = pcm_sample; + dvp += 16; + } // for + } + + } + + private void compute_pcm_samples() { + + switch (actual_write_pos) { + case 0: + compute_pcm_samples0(); + break; + case 1: + compute_pcm_samples1(); + break; + case 2: + compute_pcm_samples2(); + break; + case 3: + compute_pcm_samples3(); + break; + case 4: + compute_pcm_samples4(); + break; + case 5: + compute_pcm_samples5(); + break; + case 6: + compute_pcm_samples6(); + break; + case 7: + compute_pcm_samples7(); + break; + case 8: + compute_pcm_samples8(); + break; + case 9: + compute_pcm_samples9(); + break; + case 10: + compute_pcm_samples10(); + break; + case 11: + compute_pcm_samples11(); + break; + case 12: + compute_pcm_samples12(); + break; + case 13: + compute_pcm_samples13(); + break; + case 14: + compute_pcm_samples14(); + break; + case 15: + compute_pcm_samples15(); + break; + } + + // if (buffer != null) { + // buffer.appendSamples(channel, _tmpOut); + // } + SampleBufferWrapper.appendSamples(channel, _tmpOut); + + /* + * // MDM: I was considering putting in quality control for // low-spec + * CPUs, but the performance gain (about 10-15%) // did not justify the + * considerable drop in audio quality. switch (inc) { case 16: + * buffer.appendSamples(channel, tmpOut); break; case 32: for (int i=0; + * i<16; i++) { buffer.append(channel, (short)tmpOut[i]); + * buffer.append(channel, (short)tmpOut[i]); } break; case 64: for (int i=0; + * i<8; i++) { buffer.append(channel, (short)tmpOut[i]); + * buffer.append(channel, (short)tmpOut[i]); buffer.append(channel, + * (short)tmpOut[i]); buffer.append(channel, (short)tmpOut[i]); } break; + * + * } + */ + } + + @LATTICE("THISblockSize. + */ + static private float[][] splitArray(final float[] array, final int blockSize) { + int size = array.length / blockSize; + float[][] split = new float[size][]; + for (int i = 0; i < size; i++) { + split[i] = subArray(array, i * blockSize, blockSize); + } + return split; + } + + /** + * Returns a subarray of an existing array. + * + * @param array + * The array to retrieve a subarra from. + * @param offs + * The offset in the array that corresponds to the first index of the + * subarray. + * @param len + * The number of indeces in the subarray. + * @return The subarray, which may be of length 0. + */ + static private float[] subArray(final float[] array, final int offs, int len) { + if (offs + len > array.length) { + len = array.length - offs; + } + + if (len < 0) + len = 0; + + float[] subarray = new float[len]; + for (int i = 0; i < len; i++) { + subarray[i] = array[offs + i]; + } + + return subarray; + } + + // The original data for d[]. This data is loaded from a file + // to reduce the overall package size and to improve performance. + + static final float d[] = { 0.000000000f, -0.000442505f, 0.003250122f, -0.007003784f, + 0.031082153f, -0.078628540f, 0.100311279f, -0.572036743f, 1.144989014f, 0.572036743f, + 0.100311279f, 0.078628540f, 0.031082153f, 0.007003784f, 0.003250122f, 0.000442505f, + -0.000015259f, -0.000473022f, 0.003326416f, -0.007919312f, 0.030517578f, -0.084182739f, + 0.090927124f, -0.600219727f, 1.144287109f, 0.543823242f, 0.108856201f, 0.073059082f, + 0.031478882f, 0.006118774f, 0.003173828f, 0.000396729f, -0.000015259f, -0.000534058f, + 0.003387451f, -0.008865356f, 0.029785156f, -0.089706421f, 0.080688477f, -0.628295898f, + 1.142211914f, 0.515609741f, 0.116577148f, 0.067520142f, 0.031738281f, 0.005294800f, + 0.003082275f, 0.000366211f, -0.000015259f, -0.000579834f, 0.003433228f, -0.009841919f, + 0.028884888f, -0.095169067f, 0.069595337f, -0.656219482f, 1.138763428f, 0.487472534f, + 0.123474121f, 0.061996460f, 0.031845093f, 0.004486084f, 0.002990723f, 0.000320435f, + -0.000015259f, -0.000625610f, 0.003463745f, -0.010848999f, 0.027801514f, -0.100540161f, + 0.057617188f, -0.683914185f, 1.133926392f, 0.459472656f, 0.129577637f, 0.056533813f, + 0.031814575f, 0.003723145f, 0.002899170f, 0.000289917f, -0.000015259f, -0.000686646f, + 0.003479004f, -0.011886597f, 0.026535034f, -0.105819702f, 0.044784546f, -0.711318970f, + 1.127746582f, 0.431655884f, 0.134887695f, 0.051132202f, 0.031661987f, 0.003005981f, + 0.002792358f, 0.000259399f, -0.000015259f, -0.000747681f, 0.003479004f, -0.012939453f, + 0.025085449f, -0.110946655f, 0.031082153f, -0.738372803f, 1.120223999f, 0.404083252f, + 0.139450073f, 0.045837402f, 0.031387329f, 0.002334595f, 0.002685547f, 0.000244141f, + -0.000030518f, -0.000808716f, 0.003463745f, -0.014022827f, 0.023422241f, -0.115921021f, + 0.016510010f, -0.765029907f, 1.111373901f, 0.376800537f, 0.143264771f, 0.040634155f, + 0.031005859f, 0.001693726f, 0.002578735f, 0.000213623f, -0.000030518f, -0.000885010f, + 0.003417969f, -0.015121460f, 0.021575928f, -0.120697021f, 0.001068115f, -0.791213989f, + 1.101211548f, 0.349868774f, 0.146362305f, 0.035552979f, 0.030532837f, 0.001098633f, + 0.002456665f, 0.000198364f, -0.000030518f, -0.000961304f, 0.003372192f, -0.016235352f, + 0.019531250f, -0.125259399f, -0.015228271f, -0.816864014f, 1.089782715f, 0.323318481f, + 0.148773193f, 0.030609131f, 0.029937744f, 0.000549316f, 0.002349854f, 0.000167847f, + -0.000030518f, -0.001037598f, 0.003280640f, -0.017349243f, 0.017257690f, -0.129562378f, + -0.032379150f, -0.841949463f, 1.077117920f, 0.297210693f, 0.150497437f, 0.025817871f, + 0.029281616f, 0.000030518f, 0.002243042f, 0.000152588f, -0.000045776f, -0.001113892f, + 0.003173828f, -0.018463135f, 0.014801025f, -0.133590698f, -0.050354004f, -0.866363525f, + 1.063217163f, 0.271591187f, 0.151596069f, 0.021179199f, 0.028533936f, -0.000442505f, + 0.002120972f, 0.000137329f, -0.000045776f, -0.001205444f, 0.003051758f, -0.019577026f, + 0.012115479f, -0.137298584f, -0.069168091f, -0.890090942f, 1.048156738f, 0.246505737f, + 0.152069092f, 0.016708374f, 0.027725220f, -0.000869751f, 0.002014160f, 0.000122070f, + -0.000061035f, -0.001296997f, 0.002883911f, -0.020690918f, 0.009231567f, -0.140670776f, + -0.088775635f, -0.913055420f, 1.031936646f, 0.221984863f, 0.151962280f, 0.012420654f, + 0.026840210f, -0.001266479f, 0.001907349f, 0.000106812f, -0.000061035f, -0.001388550f, + 0.002700806f, -0.021789551f, 0.006134033f, -0.143676758f, -0.109161377f, -0.935195923f, + 1.014617920f, 0.198059082f, 0.151306152f, 0.008316040f, 0.025909424f, -0.001617432f, + 0.001785278f, 0.000106812f, -0.000076294f, -0.001480103f, 0.002487183f, -0.022857666f, + 0.002822876f, -0.146255493f, -0.130310059f, -0.956481934f, 0.996246338f, 0.174789429f, + 0.150115967f, 0.004394531f, 0.024932861f, -0.001937866f, 0.001693726f, 0.000091553f, + -0.000076294f, -0.001586914f, 0.002227783f, -0.023910522f, -0.000686646f, -0.148422241f, + -0.152206421f, -0.976852417f, 0.976852417f, 0.152206421f, 0.148422241f, 0.000686646f, + 0.023910522f, -0.002227783f, 0.001586914f, 0.000076294f, -0.000091553f, -0.001693726f, + 0.001937866f, -0.024932861f, -0.004394531f, -0.150115967f, -0.174789429f, -0.996246338f, + 0.956481934f, 0.130310059f, 0.146255493f, -0.002822876f, 0.022857666f, -0.002487183f, + 0.001480103f, 0.000076294f, -0.000106812f, -0.001785278f, 0.001617432f, -0.025909424f, + -0.008316040f, -0.151306152f, -0.198059082f, -1.014617920f, 0.935195923f, 0.109161377f, + 0.143676758f, -0.006134033f, 0.021789551f, -0.002700806f, 0.001388550f, 0.000061035f, + -0.000106812f, -0.001907349f, 0.001266479f, -0.026840210f, -0.012420654f, -0.151962280f, + -0.221984863f, -1.031936646f, 0.913055420f, 0.088775635f, 0.140670776f, -0.009231567f, + 0.020690918f, -0.002883911f, 0.001296997f, 0.000061035f, -0.000122070f, -0.002014160f, + 0.000869751f, -0.027725220f, -0.016708374f, -0.152069092f, -0.246505737f, -1.048156738f, + 0.890090942f, 0.069168091f, 0.137298584f, -0.012115479f, 0.019577026f, -0.003051758f, + 0.001205444f, 0.000045776f, -0.000137329f, -0.002120972f, 0.000442505f, -0.028533936f, + -0.021179199f, -0.151596069f, -0.271591187f, -1.063217163f, 0.866363525f, 0.050354004f, + 0.133590698f, -0.014801025f, 0.018463135f, -0.003173828f, 0.001113892f, 0.000045776f, + -0.000152588f, -0.002243042f, -0.000030518f, -0.029281616f, -0.025817871f, -0.150497437f, + -0.297210693f, -1.077117920f, 0.841949463f, 0.032379150f, 0.129562378f, -0.017257690f, + 0.017349243f, -0.003280640f, 0.001037598f, 0.000030518f, -0.000167847f, -0.002349854f, + -0.000549316f, -0.029937744f, -0.030609131f, -0.148773193f, -0.323318481f, -1.089782715f, + 0.816864014f, 0.015228271f, 0.125259399f, -0.019531250f, 0.016235352f, -0.003372192f, + 0.000961304f, 0.000030518f, -0.000198364f, -0.002456665f, -0.001098633f, -0.030532837f, + -0.035552979f, -0.146362305f, -0.349868774f, -1.101211548f, 0.791213989f, -0.001068115f, + 0.120697021f, -0.021575928f, 0.015121460f, -0.003417969f, 0.000885010f, 0.000030518f, + -0.000213623f, -0.002578735f, -0.001693726f, -0.031005859f, -0.040634155f, -0.143264771f, + -0.376800537f, -1.111373901f, 0.765029907f, -0.016510010f, 0.115921021f, -0.023422241f, + 0.014022827f, -0.003463745f, 0.000808716f, 0.000030518f, -0.000244141f, -0.002685547f, + -0.002334595f, -0.031387329f, -0.045837402f, -0.139450073f, -0.404083252f, -1.120223999f, + 0.738372803f, -0.031082153f, 0.110946655f, -0.025085449f, 0.012939453f, -0.003479004f, + 0.000747681f, 0.000015259f, -0.000259399f, -0.002792358f, -0.003005981f, -0.031661987f, + -0.051132202f, -0.134887695f, -0.431655884f, -1.127746582f, 0.711318970f, -0.044784546f, + 0.105819702f, -0.026535034f, 0.011886597f, -0.003479004f, 0.000686646f, 0.000015259f, + -0.000289917f, -0.002899170f, -0.003723145f, -0.031814575f, -0.056533813f, -0.129577637f, + -0.459472656f, -1.133926392f, 0.683914185f, -0.057617188f, 0.100540161f, -0.027801514f, + 0.010848999f, -0.003463745f, 0.000625610f, 0.000015259f, -0.000320435f, -0.002990723f, + -0.004486084f, -0.031845093f, -0.061996460f, -0.123474121f, -0.487472534f, -1.138763428f, + 0.656219482f, -0.069595337f, 0.095169067f, -0.028884888f, 0.009841919f, -0.003433228f, + 0.000579834f, 0.000015259f, -0.000366211f, -0.003082275f, -0.005294800f, -0.031738281f, + -0.067520142f, -0.116577148f, -0.515609741f, -1.142211914f, 0.628295898f, -0.080688477f, + 0.089706421f, -0.029785156f, 0.008865356f, -0.003387451f, 0.000534058f, 0.000015259f, + -0.000396729f, -0.003173828f, -0.006118774f, -0.031478882f, -0.073059082f, -0.108856201f, + -0.543823242f, -1.144287109f, 0.600219727f, -0.090927124f, 0.084182739f, -0.030517578f, + 0.007919312f, -0.003326416f, 0.000473022f, 0.000015259f }; + +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/focus.mp3 b/Robust/src/Benchmarks/SSJava/MP3Decoder/focus.mp3 new file mode 100644 index 00000000..06a9386d Binary files /dev/null and b/Robust/src/Benchmarks/SSJava/MP3Decoder/focus.mp3 differ diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/huffcodetab.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/huffcodetab.java new file mode 100644 index 00000000..4442b8d2 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/huffcodetab.java @@ -0,0 +1,663 @@ +/* + * 11/19/04 1.0 moved to LGPL. + * 16/11/99 Renamed class, added javadoc, and changed table + * name from String to 3 chars. mdm@techie.com + * 02/15/99 Java Conversion by E.B, javalayer@javazoom.net + * + * 04/19/97 : Adapted from the ISO MPEG Audio Subgroup Software Simulation + * Group's public c source for its MPEG audio decoder. Miscellaneous + * changes by Jeff Tsay (ctsay@pasteur.eecs.berkeley.edu). + *----------------------------------------------------------------------- + * Copyright (c) 1991 MPEG/audio software simulation group, All Rights Reserved + * MPEG/audio coding/decoding software, work in progress + * NOT for public distribution until verified and approved by the + * MPEG/audio committee. For further information, please contact + * Davis Pan, 508-493-2241, e-mail: pan@3d.enet.dec.com + * + * VERSION 4.1 + * changes made since last update: + * date programmers comment + * 27.2.92 F.O.Witte (ITT Intermetall) + * 8/24/93 M. Iwadare Changed for 1 pass decoding. + * 7/14/94 J. Koller useless 'typedef' before huffcodetab removed + *----------------------------------------------------------------------- + * 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. + *---------------------------------------------------------------------- + */ + +/** + * Class to implements Huffman decoder. + */ +@LATTICE("FIELD>> 4; + y[0] = ht[htIdx].val[point][1] & 0xf; + error = 0; + break; + } + + // hget1bit() is called thousands of times, and so needs to be + // ultra fast. + /* + * if (bitIndex==bitsAvailable) { bitsAvailable = br.readBits(bits, 32); + * bitIndex = 0; } + */ + // if (bits[bitIndex++]!=0) + if (br.hget1bit() != 0) { + TERMINATE: while (ht[htIdx].val[point][1] >= MXOFF) + point += ht[htIdx].val[point][1]; + point += ht[htIdx].val[point][1]; + } else { + TERMINATE: while (ht[htIdx].val[point][0] >= MXOFF) + point += ht[htIdx].val[point][0]; + point += ht[htIdx].val[point][0]; + } + level >>>= 1; + // MDM: ht[0] is always 0; + } while ((level != 0) || (point < 0 /* ht[0].treelen */)); + + // put back any bits not consumed + /* + * int unread = (bitsAvailable-bitIndex); if (unread>0) + * br.rewindNbits(unread); + */ + /* Process sign encodings for quadruples tables. */ + // System.out.println(ht[htIdx].tablename); + if (ht[htIdx].tablename0 == '3' && (ht[htIdx].tablename1 == '2' || ht[htIdx].tablename1 == '3')) { + v[0] = (y[0] >> 3) & 1; + w[0] = (y[0] >> 2) & 1; + x[0] = (y[0] >> 1) & 1; + y[0] = y[0] & 1; + + /* + * v, w, x and y are reversed in the bitstream. switch them around to make + * test bistream work. + */ + + if (v[0] != 0) + if (br.hget1bit() != 0) + v[0] = -v[0]; + if (w[0] != 0) + if (br.hget1bit() != 0) + w[0] = -w[0]; + if (x[0] != 0) + if (br.hget1bit() != 0) + x[0] = -x[0]; + if (y[0] != 0) + if (br.hget1bit() != 0) + y[0] = -y[0]; + } else { + // Process sign and escape encodings for dual tables. + // x and y are reversed in the test bitstream. + // Reverse x and y here to make test bitstream work. + + if (ht[htIdx].linbits != 0) + if ((ht[htIdx].xlen - 1) == x[0]) + x[0] += br.hgetbits(ht[htIdx].linbits); + if (x[0] != 0) + if (br.hget1bit() != 0) + x[0] = -x[0]; + if (ht[htIdx].linbits != 0) + if ((ht[htIdx].ylen - 1) == y[0]) + y[0] += br.hgetbits(ht[htIdx].linbits); + if (y[0] != 0) + if (br.hget1bit() != 0) + y[0] = -y[0]; + } + return error; + } + + public static void inithuff() { + + if (ht != null) + return; + + ht = new huffcodetab[HTN]; + ht[0] = new huffcodetab("0 ", 0, 0, 0, 0, -1, null, null, ValTab0, 0); + ht[1] = new huffcodetab("1 ", 2, 2, 0, 0, -1, null, null, ValTab1, 7); + ht[2] = new huffcodetab("2 ", 3, 3, 0, 0, -1, null, null, ValTab2, 17); + ht[3] = new huffcodetab("3 ", 3, 3, 0, 0, -1, null, null, ValTab3, 17); + ht[4] = new huffcodetab("4 ", 0, 0, 0, 0, -1, null, null, ValTab4, 0); + ht[5] = new huffcodetab("5 ", 4, 4, 0, 0, -1, null, null, ValTab5, 31); + ht[6] = new huffcodetab("6 ", 4, 4, 0, 0, -1, null, null, ValTab6, 31); + ht[7] = new huffcodetab("7 ", 6, 6, 0, 0, -1, null, null, ValTab7, 71); + ht[8] = new huffcodetab("8 ", 6, 6, 0, 0, -1, null, null, ValTab8, 71); + ht[9] = new huffcodetab("9 ", 6, 6, 0, 0, -1, null, null, ValTab9, 71); + ht[10] = new huffcodetab("10 ", 8, 8, 0, 0, -1, null, null, ValTab10, 127); + ht[11] = new huffcodetab("11 ", 8, 8, 0, 0, -1, null, null, ValTab11, 127); + ht[12] = new huffcodetab("12 ", 8, 8, 0, 0, -1, null, null, ValTab12, 127); + ht[13] = new huffcodetab("13 ", 16, 16, 0, 0, -1, null, null, ValTab13, 511); + ht[14] = new huffcodetab("14 ", 0, 0, 0, 0, -1, null, null, ValTab14, 0); + ht[15] = new huffcodetab("15 ", 16, 16, 0, 0, -1, null, null, ValTab15, 511); + ht[16] = new huffcodetab("16 ", 16, 16, 1, 1, -1, null, null, ValTab16, 511); + ht[17] = new huffcodetab("17 ", 16, 16, 2, 3, 16, null, null, ValTab16, 511); + ht[18] = new huffcodetab("18 ", 16, 16, 3, 7, 16, null, null, ValTab16, 511); + ht[19] = new huffcodetab("19 ", 16, 16, 4, 15, 16, null, null, ValTab16, 511); + ht[20] = new huffcodetab("20 ", 16, 16, 6, 63, 16, null, null, ValTab16, 511); + ht[21] = new huffcodetab("21 ", 16, 16, 8, 255, 16, null, null, ValTab16, 511); + ht[22] = new huffcodetab("22 ", 16, 16, 10, 1023, 16, null, null, ValTab16, 511); + ht[23] = new huffcodetab("23 ", 16, 16, 13, 8191, 16, null, null, ValTab16, 511); + ht[24] = new huffcodetab("24 ", 16, 16, 4, 15, -1, null, null, ValTab24, 512); + ht[25] = new huffcodetab("25 ", 16, 16, 5, 31, 24, null, null, ValTab24, 512); + ht[26] = new huffcodetab("26 ", 16, 16, 6, 63, 24, null, null, ValTab24, 512); + ht[27] = new huffcodetab("27 ", 16, 16, 7, 127, 24, null, null, ValTab24, 512); + ht[28] = new huffcodetab("28 ", 16, 16, 8, 255, 24, null, null, ValTab24, 512); + ht[29] = new huffcodetab("29 ", 16, 16, 9, 511, 24, null, null, ValTab24, 512); + ht[30] = new huffcodetab("30 ", 16, 16, 11, 2047, 24, null, null, ValTab24, 512); + ht[31] = new huffcodetab("31 ", 16, 16, 13, 8191, 24, null, null, ValTab24, 512); + ht[32] = new huffcodetab("32 ", 1, 16, 0, 0, -1, null, null, ValTab32, 31); + ht[33] = new huffcodetab("33 ", 1, 16, 0, 0, -1, null, null, ValTab33, 31); + } +} diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/makefile b/Robust/src/Benchmarks/SSJava/MP3Decoder/makefile new file mode 100644 index 00000000..503e2d11 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/makefile @@ -0,0 +1,23 @@ +BUILDSCRIPT=../../../buildscript + +PROGRAM=MP3Player +SOURCE_FILES=MP3Player.java + +BSFLAGS= -32bit -ssjava -mainclass $(PROGRAM) -heapsize-mb 1000 -nooptimize -debug -garbagestats -ssjavadebug #-printlinenum #-joptimize + +default: $(PROGRAM)s.bin + +$(PROGRAM)s.bin: $(SOURCE_FILES) makefile + $(BUILDSCRIPT) $(BSFLAGS) -o $(PROGRAM) -builddir sing $(SOURCE_FILES) + +clean: + rm -f $(PROGRAM).bin + rm -fr sing + rm -f *~ + rm -f *.dot + rm -f *.png + rm -f *.txt + rm -f aliases.txt + rm -f results*txt + rm -f *log + diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/outputfocusmp3 b/Robust/src/Benchmarks/SSJava/MP3Decoder/outputfocusmp3 new file mode 100644 index 00000000..45fcfde7 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/outputfocusmp3 @@ -0,0 +1,168 @@ +playing focus.mp3... +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +-4777 +-631072 +1293323 +-1326139 +861767 +451288 +-47296 +-1248777 +1925353 +-2179234 +1182947 +683998 +-2517503 +2835485 +-2320058 +2460065 +-2306413 +195502 +1310892 +-1577569 +2430640 +-2328745 +1740775 +-1051879 +-376916 +1246895 +-1709109 +1874073 +-1369555 +601164 +293020 +-738830 +499587 +-630175 +1256735 +-783515 +104125 +-124200 +-342781 +812927 +-998554 +947185 +-717666 +353871 +163304 +-621030 +722986 +-594950 +632691 +-271096 +-144508 +104417 +-298261 +621697 +-447509 +308172 +-393156 +152638 +150214 +-265019 +545920 +-590735 +387837 +-202976 +-59867 +392340 +-483584 +362935 +-348877 +211165 +-163997 +17939 +244738 +-312426 +949236 +-261437 +-240964 +850661 +744267 +-2000037 +-1233522 +130242 +743770 +1774653 +357115 +-1197546 +-1206982 +-843540 +184622 +2128890 +359831 +442096 +-818716 +-689965 +-947304 +773965 +646175 +520632 +-72768 +-630029 +-808955 +-155733 +682029 +576228 +188296 +-67453 +-549263 +-718693 +488039 +350375 +350661 +65091 +-277534 +-1095438 +155867 +396317 +488158 +190983 +-211400 +-626435 +-132469 +118532 +187159 +206311 +312933 +-494249 +-59286 +-154420 +13707 +235088 +178369 +27036 +-238910 +-136433 +8957 +133869 +61867 +159041 +-102253 +-137070 +60010 +-87635 +15930 +209339 +-92839 +-5986 +-38700 +-20011 +26409 +29158 +16768 +-21964 +1477 +0 +0 +0 +0 diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/run b/Robust/src/Benchmarks/SSJava/MP3Decoder/run new file mode 100755 index 00000000..4642b81b --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/run @@ -0,0 +1 @@ +./MP3Player.bin focus.mp3 \ No newline at end of file diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/ssoutput b/Robust/src/Benchmarks/SSJava/MP3Decoder/ssoutput new file mode 100644 index 00000000..45fcfde7 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/ssoutput @@ -0,0 +1,168 @@ +playing focus.mp3... +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +-4777 +-631072 +1293323 +-1326139 +861767 +451288 +-47296 +-1248777 +1925353 +-2179234 +1182947 +683998 +-2517503 +2835485 +-2320058 +2460065 +-2306413 +195502 +1310892 +-1577569 +2430640 +-2328745 +1740775 +-1051879 +-376916 +1246895 +-1709109 +1874073 +-1369555 +601164 +293020 +-738830 +499587 +-630175 +1256735 +-783515 +104125 +-124200 +-342781 +812927 +-998554 +947185 +-717666 +353871 +163304 +-621030 +722986 +-594950 +632691 +-271096 +-144508 +104417 +-298261 +621697 +-447509 +308172 +-393156 +152638 +150214 +-265019 +545920 +-590735 +387837 +-202976 +-59867 +392340 +-483584 +362935 +-348877 +211165 +-163997 +17939 +244738 +-312426 +949236 +-261437 +-240964 +850661 +744267 +-2000037 +-1233522 +130242 +743770 +1774653 +357115 +-1197546 +-1206982 +-843540 +184622 +2128890 +359831 +442096 +-818716 +-689965 +-947304 +773965 +646175 +520632 +-72768 +-630029 +-808955 +-155733 +682029 +576228 +188296 +-67453 +-549263 +-718693 +488039 +350375 +350661 +65091 +-277534 +-1095438 +155867 +396317 +488158 +190983 +-211400 +-626435 +-132469 +118532 +187159 +206311 +312933 +-494249 +-59286 +-154420 +13707 +235088 +178369 +27036 +-238910 +-136433 +8957 +133869 +61867 +159041 +-102253 +-137070 +60010 +-87635 +15930 +209339 +-92839 +-5986 +-38700 +-20011 +26409 +29158 +16768 +-21964 +1477 +0 +0 +0 +0