From: yeom Date: Mon, 20 Jun 2011 22:01:38 +0000 (+0000) Subject: provides makefile and makes it compile for david X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=fb4fdb2e21b81ce5d74bb4d4dac93acf16ee69c6;p=IRC.git provides makefile and makes it compile for david --- diff --git a/Robust/src/Tests/ssJava/mp3decoder/BitReserve.java b/Robust/src/Tests/ssJava/mp3decoder/BitReserve.java index 9b6da48e..24794c1a 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/BitReserve.java +++ b/Robust/src/Tests/ssJava/mp3decoder/BitReserve.java @@ -24,8 +24,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *---------------------------------------------------------------------- */ - -package javazoom.jl.decoder; /** * Implementation of Bit Reservoir for Layer III. diff --git a/Robust/src/Tests/ssJava/mp3decoder/Bitstream.java b/Robust/src/Tests/ssJava/mp3decoder/Bitstream.java index d91ea26f..b0493045 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/Bitstream.java +++ b/Robust/src/Tests/ssJava/mp3decoder/Bitstream.java @@ -33,8 +33,6 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; - import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.IOException; diff --git a/Robust/src/Tests/ssJava/mp3decoder/BitstreamErrors.java b/Robust/src/Tests/ssJava/mp3decoder/BitstreamErrors.java index 26daeb9d..07114dbf 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/BitstreamErrors.java +++ b/Robust/src/Tests/ssJava/mp3decoder/BitstreamErrors.java @@ -19,8 +19,6 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; - /** * This interface describes all error codes that can be thrown * in BistreamExceptions. diff --git a/Robust/src/Tests/ssJava/mp3decoder/BitstreamException.java b/Robust/src/Tests/ssJava/mp3decoder/BitstreamException.java index e4afb1a1..ba005809 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/BitstreamException.java +++ b/Robust/src/Tests/ssJava/mp3decoder/BitstreamException.java @@ -18,8 +18,6 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; - /** * Instances of BitstreamException are thrown * when operations on a Bitstream fail. diff --git a/Robust/src/Tests/ssJava/mp3decoder/Control.java b/Robust/src/Tests/ssJava/mp3decoder/Control.java index 9d566049..c677b5fd 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/Control.java +++ b/Robust/src/Tests/ssJava/mp3decoder/Control.java @@ -17,8 +17,6 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; - /** * Work in progress. */ diff --git a/Robust/src/Tests/ssJava/mp3decoder/Crc16.java b/Robust/src/Tests/ssJava/mp3decoder/Crc16.java index caad01ca..058896af 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/Crc16.java +++ b/Robust/src/Tests/ssJava/mp3decoder/Crc16.java @@ -22,7 +22,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; /** * 16-Bit CRC checksum diff --git a/Robust/src/Tests/ssJava/mp3decoder/Decoder.java b/Robust/src/Tests/ssJava/mp3decoder/Decoder.java index 6de55997..ffafed30 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/Decoder.java +++ b/Robust/src/Tests/ssJava/mp3decoder/Decoder.java @@ -18,7 +18,6 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; /** * The Decoder class encapsulates the details of diff --git a/Robust/src/Tests/ssJava/mp3decoder/DecoderErrors.java b/Robust/src/Tests/ssJava/mp3decoder/DecoderErrors.java index 686f2602..ef3552ad 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/DecoderErrors.java +++ b/Robust/src/Tests/ssJava/mp3decoder/DecoderErrors.java @@ -19,7 +19,6 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; /** * This interface provides constants describing the error diff --git a/Robust/src/Tests/ssJava/mp3decoder/DecoderException.java b/Robust/src/Tests/ssJava/mp3decoder/DecoderException.java index 87638ad2..a00a20b5 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/DecoderException.java +++ b/Robust/src/Tests/ssJava/mp3decoder/DecoderException.java @@ -18,7 +18,6 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; /** * The DecoderException represents the class of diff --git a/Robust/src/Tests/ssJava/mp3decoder/Equalizer.java b/Robust/src/Tests/ssJava/mp3decoder/Equalizer.java index 439279e6..1dc88f42 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/Equalizer.java +++ b/Robust/src/Tests/ssJava/mp3decoder/Equalizer.java @@ -19,7 +19,6 @@ */ -package javazoom.jl.decoder; /** * The Equalizer class can be used to specify diff --git a/Robust/src/Tests/ssJava/mp3decoder/FrameDecoder.java b/Robust/src/Tests/ssJava/mp3decoder/FrameDecoder.java index 12912f6e..9c7029dd 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/FrameDecoder.java +++ b/Robust/src/Tests/ssJava/mp3decoder/FrameDecoder.java @@ -19,7 +19,6 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; /** * Implementations of FrameDecoder are responsible for decoding diff --git a/Robust/src/Tests/ssJava/mp3decoder/Header.java b/Robust/src/Tests/ssJava/mp3decoder/Header.java index a36572dc..b0dd1001 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/Header.java +++ b/Robust/src/Tests/ssJava/mp3decoder/Header.java @@ -29,7 +29,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; /** * Class for extracting information from a frame header. diff --git a/Robust/src/Tests/ssJava/mp3decoder/InputStreamSource.java b/Robust/src/Tests/ssJava/mp3decoder/InputStreamSource.java index fb6c0299..3945c3d0 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/InputStreamSource.java +++ b/Robust/src/Tests/ssJava/mp3decoder/InputStreamSource.java @@ -18,8 +18,6 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; - import java.io.IOException; import java.io.InputStream; diff --git a/Robust/src/Tests/ssJava/mp3decoder/JavaLayerError.java b/Robust/src/Tests/ssJava/mp3decoder/JavaLayerError.java index 042d83a5..cc8dde73 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/JavaLayerError.java +++ b/Robust/src/Tests/ssJava/mp3decoder/JavaLayerError.java @@ -18,8 +18,6 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; - /** * Work in progress. * diff --git a/Robust/src/Tests/ssJava/mp3decoder/JavaLayerErrors.java b/Robust/src/Tests/ssJava/mp3decoder/JavaLayerErrors.java index b141ce84..4d11270c 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/JavaLayerErrors.java +++ b/Robust/src/Tests/ssJava/mp3decoder/JavaLayerErrors.java @@ -18,7 +18,6 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; /** * Exception erorr codes for components of the JavaLayer API. diff --git a/Robust/src/Tests/ssJava/mp3decoder/JavaLayerException.java b/Robust/src/Tests/ssJava/mp3decoder/JavaLayerException.java index 0767bf21..2d47f5cd 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/JavaLayerException.java +++ b/Robust/src/Tests/ssJava/mp3decoder/JavaLayerException.java @@ -18,7 +18,6 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; import java.io.PrintStream; diff --git a/Robust/src/Tests/ssJava/mp3decoder/JavaLayerHook.java b/Robust/src/Tests/ssJava/mp3decoder/JavaLayerHook.java index edd890dd..2096d65a 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/JavaLayerHook.java +++ b/Robust/src/Tests/ssJava/mp3decoder/JavaLayerHook.java @@ -17,7 +17,6 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; import java.io.InputStream; diff --git a/Robust/src/Tests/ssJava/mp3decoder/JavaLayerUtils.java b/Robust/src/Tests/ssJava/mp3decoder/JavaLayerUtils.java index b7cd5484..2156e3db 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/JavaLayerUtils.java +++ b/Robust/src/Tests/ssJava/mp3decoder/JavaLayerUtils.java @@ -18,7 +18,6 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; import java.io.IOException; import java.io.InputStream; diff --git a/Robust/src/Tests/ssJava/mp3decoder/LATTICE.java b/Robust/src/Tests/ssJava/mp3decoder/LATTICE.java new file mode 100644 index 00000000..3dc53b81 --- /dev/null +++ b/Robust/src/Tests/ssJava/mp3decoder/LATTICE.java @@ -0,0 +1,3 @@ +public @interface LATTICE{ + String value(); +} diff --git a/Robust/src/Tests/ssJava/mp3decoder/LOC.java b/Robust/src/Tests/ssJava/mp3decoder/LOC.java new file mode 100644 index 00000000..3918fe50 --- /dev/null +++ b/Robust/src/Tests/ssJava/mp3decoder/LOC.java @@ -0,0 +1,3 @@ +public @interface LOC{ + String value(); +} \ No newline at end of file diff --git a/Robust/src/Tests/ssJava/mp3decoder/LayerIDecoder.java b/Robust/src/Tests/ssJava/mp3decoder/LayerIDecoder.java index fb936d2b..97363a97 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/LayerIDecoder.java +++ b/Robust/src/Tests/ssJava/mp3decoder/LayerIDecoder.java @@ -24,7 +24,6 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; /** * Implements decoding of MPEG Audio Layer I frames. diff --git a/Robust/src/Tests/ssJava/mp3decoder/LayerIIDecoder.java b/Robust/src/Tests/ssJava/mp3decoder/LayerIIDecoder.java index 7265b1f8..0872aaa0 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/LayerIIDecoder.java +++ b/Robust/src/Tests/ssJava/mp3decoder/LayerIIDecoder.java @@ -27,7 +27,6 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; /** * Implements decoding of MPEG Audio Layer II frames. diff --git a/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java b/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java index 9e66a93b..056d744c 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java +++ b/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java @@ -32,7 +32,6 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; /** * Class Implementing Layer 3 Decoder. @@ -50,14 +49,14 @@ final class LayerIIIDecoder implements FrameDecoder { private int[] is_1d; private float[][][] ro; private float[][][] lr; - private float[] out_1d; + private float[] out_1d; // 576 samples private float[][] prevblck; private float[][] k; private int[] nonzero; private Bitstream stream; - @HEADER private Header header; + private Header header; private SynthesisFilter filter1, filter2; - private Obuffer buffer; + private Obuffer buffer; // output buffer private int which_channels; private BitReserve br; private III_side_info_t si; @@ -288,20 +287,26 @@ final class LayerIIIDecoder implements FrameDecoder { for (; bytes_to_discard > 0; bytes_to_discard--) // bytes_to_discard > br br.hgetbits(8); + // doing something from here + // here 'gr' and 'max_gr' should be higher than 'ch','channels', and more - for (gr = 0; gr < max_gr; gr++) { + for (gr = 0; gr < max_gr; gr++) { // two granules per channel // in the loop body, access set={part2_start} // 'ch', 'channels' should be higher than all locs in the below body for (ch = 0; ch < channels; ch++) { part2_start = br.hsstell(); // part2_start < br + // grab scale factors from the main data. + // following the scale factors is the actual compressed data if (header.version() == Header.MPEG1) get_scale_factors(ch, gr); // no need to care from this side + // here move scale factor data from 'br' buffer to 'scalefac' field else // MPEG-2 LSF, SZD: MPEG-2.5 LSF get_LSF_scale_factors(ch, gr); // no need to care from this side + // here, decoding the compressed audio data huffman_decode(ch, gr); // no need to care from this side // System.out.println("CheckSum HuffMan = " + CheckSumHuff); dequantize_sample(ro[ch], ch, gr); // no need to care from this side @@ -1039,6 +1044,12 @@ final class LayerIIIDecoder implements FrameDecoder { * */ private void reorder(float xr[][], int ch, int gr) { + // the purpose of reordering: move 'short samples' back to their original position + // after reorder, the samples are no long ordered by frequency + + // the format of input data to reorder: + // three small chunks of 192 samples each are combined to 576 samples ordered by frequency + gr_info_s gr_info = (si.ch[ch].gr[gr]); int freq, freq3; int index; @@ -2452,3 +2463,4 @@ final class LayerIIIDecoder implements FrameDecoder { { { 8, 8, 5, 0 }, { 15, 12, 9, 0 }, { 6, 18, 9, 0 } } }; } + diff --git a/Robust/src/Tests/ssJava/mp3decoder/METHODDEFAULT.java b/Robust/src/Tests/ssJava/mp3decoder/METHODDEFAULT.java new file mode 100644 index 00000000..8cc6ce76 --- /dev/null +++ b/Robust/src/Tests/ssJava/mp3decoder/METHODDEFAULT.java @@ -0,0 +1,3 @@ +public @interface METHODDEFAULT{ + String value(); +} diff --git a/Robust/src/Tests/ssJava/mp3decoder/Manager.java b/Robust/src/Tests/ssJava/mp3decoder/Manager.java index 47f53118..fe855401 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/Manager.java +++ b/Robust/src/Tests/ssJava/mp3decoder/Manager.java @@ -17,7 +17,6 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; /** * Work in progress. diff --git a/Robust/src/Tests/ssJava/mp3decoder/Obuffer.java b/Robust/src/Tests/ssJava/mp3decoder/Obuffer.java index 0481f11c..d05900d0 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/Obuffer.java +++ b/Robust/src/Tests/ssJava/mp3decoder/Obuffer.java @@ -1,88 +1,88 @@ -/* - * 11/19/04 1.0 moved to LGPL. - * 12/12/99 Added appendSamples() method for efficiency. MDM. - * 15/02/99 ,Java Conversion by E.B ,ebsp@iname.com, JavaLayer - * - * Declarations for output buffer, includes operating system - * implementation of the virtual Obuffer. Optional routines - * enabling seeks and stops added by Jeff Tsay. - * - * @(#) obuffer.h 1.8, last edit: 6/15/94 16:51:56 - * @(#) Copyright (C) 1993, 1994 Tobias Bading (bading@cs.tu-berlin.de) - * @(#) Berlin University of Technology - * - * Idea and first implementation for u-law output with fast downsampling by - * Jim Boucher (jboucher@flash.bu.edu) - * - * LinuxObuffer class written by - * Louis P. Kruger (lpkruger@phoenix.princeton.edu) - *----------------------------------------------------------------------- - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - *---------------------------------------------------------------------- - */ -package javazoom.jl.decoder; - -/** - * Base Class for audio output. - */ -public abstract class Obuffer -{ - public static final int OBUFFERSIZE = 2 * 1152; // max. 2 * 1152 samples per frame - public static final int MAXCHANNELS = 2; // max. number of channels - - /** - * Takes a 16 Bit PCM sample. - */ - public abstract void append(int channel, short value); - - /** - * Accepts 32 new PCM samples. - */ - public void appendSamples(int channel, float[] f) - { - short s; - for (int i=0; i<32;) - { - s = clip(f[i++]); - append(channel, s); - } - } - - /** - * Clip Sample to 16 Bits - */ - private final short clip(float sample) - { - return ((sample > 32767.0f) ? 32767 : - ((sample < -32768.0f) ? -32768 : - (short) sample)); - } - - /** - * Write the samples to the file or directly to the audio hardware. - */ - public abstract void write_buffer(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(); -} +/* + * 11/19/04 1.0 moved to LGPL. + * 12/12/99 Added appendSamples() method for efficiency. MDM. + * 15/02/99 ,Java Conversion by E.B ,ebsp@iname.com, JavaLayer + * + * Declarations for output buffer, includes operating system + * implementation of the virtual Obuffer. Optional routines + * enabling seeks and stops added by Jeff Tsay. + * + * @(#) obuffer.h 1.8, last edit: 6/15/94 16:51:56 + * @(#) Copyright (C) 1993, 1994 Tobias Bading (bading@cs.tu-berlin.de) + * @(#) Berlin University of Technology + * + * Idea and first implementation for u-law output with fast downsampling by + * Jim Boucher (jboucher@flash.bu.edu) + * + * LinuxObuffer class written by + * Louis P. Kruger (lpkruger@phoenix.princeton.edu) + *----------------------------------------------------------------------- + * 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. + *---------------------------------------------------------------------- + */ + +/** + * Base Class for audio output. + */ +@METHODDEFAULT("D 32767.0f) ? 32767 : + ((sample < -32768.0f) ? -32768 : + (short) sample)); + } + + /** + * Write the samples to the file or directly to the audio hardware. + */ + public abstract void write_buffer(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/Tests/ssJava/mp3decoder/OutputChannels.java b/Robust/src/Tests/ssJava/mp3decoder/OutputChannels.java index be2c66d2..91458859 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/OutputChannels.java +++ b/Robust/src/Tests/ssJava/mp3decoder/OutputChannels.java @@ -18,7 +18,6 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; /** diff --git a/Robust/src/Tests/ssJava/mp3decoder/Player.java b/Robust/src/Tests/ssJava/mp3decoder/Player.java index c3020575..406876e2 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/Player.java +++ b/Robust/src/Tests/ssJava/mp3decoder/Player.java @@ -18,16 +18,9 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.player; import java.io.InputStream; -import javazoom.jl.decoder.Bitstream; -import javazoom.jl.decoder.BitstreamException; -import javazoom.jl.decoder.Decoder; -import javazoom.jl.decoder.Header; -import javazoom.jl.decoder.JavaLayerException; -import javazoom.jl.decoder.SampleBuffer; /** * The Player class implements a simple player for playback @@ -60,7 +53,7 @@ public class Player /** * The AudioDevice the audio samples are written to. */ - private AudioDevice audio; + //private AudioDevice audio; /** * Has the player been closed? @@ -79,9 +72,10 @@ public class Player */ public Player(InputStream stream) throws JavaLayerException { - this(stream, null); + //this(stream, null); } - + + /* temporarily disabled by eom public Player(InputStream stream, AudioDevice device) throws JavaLayerException { bitstream = new Bitstream(stream); @@ -98,6 +92,7 @@ public class Player } audio.open(decoder); } + */ public void play() throws JavaLayerException { @@ -114,12 +109,13 @@ public class Player public boolean play(int frames) throws JavaLayerException { boolean ret = true; - + + while (frames-- > 0 && ret) { ret = decodeFrame(); } - + /* if (!ret) { // last frame, ensure all data flushed to the audio device. @@ -134,6 +130,7 @@ public class Player } } } + */ return ret; } @@ -141,8 +138,10 @@ public class Player * Cloases this player. Any audio currently playing is stopped * immediately. */ + public synchronized void close() { +/* AudioDevice out = audio; if (out!=null) { @@ -160,8 +159,10 @@ public class Player { } } +*/ } + /** * Returns the completed status of this player. * @@ -181,14 +182,15 @@ public class Player */ public int getPosition() { - int position = lastPosition; + //int position = lastPosition; - AudioDevice out = audio; - if (out!=null) - { - position = out.getPosition(); - } - return position; + //AudioDevice out = audio; + //if (out!=null) + //{ + // position = out.getPosition(); + //} + //return position; + return 0; } /** @@ -200,9 +202,9 @@ public class Player { try { - AudioDevice out = audio; - if (out==null) - return false; + //AudioDevice out = audio; + //if (out==null) + // return false; Header h = bitstream.readFrame(); @@ -212,14 +214,14 @@ public class Player // sample buffer set when decoder constructed SampleBuffer output = (SampleBuffer)decoder.decodeFrame(h, bitstream); - synchronized (this) - { - out = audio; - if (out!=null) - { - out.write(output.getBuffer(), 0, output.getBufferLength()); - } - } + //synchronized (this) + //{ + // out = audio; + // if (out!=null) + // { + // out.write(output.getBuffer(), 0, output.getBufferLength()); + // } + //} bitstream.closeFrame(); } diff --git a/Robust/src/Tests/ssJava/mp3decoder/SampleBuffer.java b/Robust/src/Tests/ssJava/mp3decoder/SampleBuffer.java index 3bc0fe85..a1e20aa1 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/SampleBuffer.java +++ b/Robust/src/Tests/ssJava/mp3decoder/SampleBuffer.java @@ -1,132 +1,167 @@ -/* - * 11/19/04 1.0 moved to LGPL. - * - * 12/12/99 Initial Version based on FileObuffer. mdm@techie.com. - * - * FileObuffer: - * 15/02/99 Java Conversion by E.B ,javalayer@javazoom.net - * - *----------------------------------------------------------------------- - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - *---------------------------------------------------------------------- - */ - -package javazoom.jl.decoder; - -/** - * The SampleBuffer class implements an output buffer - * that provides storage for a fixed size block of samples. - */ -public class SampleBuffer extends Obuffer -{ - private short[] buffer; - private int[] bufferp; - private int channels; - private int frequency; - - /** - * Constructor - */ - public SampleBuffer(int sample_frequency, int number_of_channels) - { - buffer = new short[OBUFFERSIZE]; - bufferp = new int[MAXCHANNELS]; - channels = number_of_channels; - frequency = sample_frequency; - - for (int i = 0; i < number_of_channels; ++i) - bufferp[i] = (short)i; - - } - - 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(int channel, short value) - { - buffer[bufferp[channel]] = value; - bufferp[channel] += channels; - } - - public void appendSamples(int channel, float[] f) - { - int pos = bufferp[channel]; - - short s; - float fs; - for (int i=0; i<32;) - { - fs = f[i++]; - fs = (fs>32767.0f ? 32767.0f - : (fs < -32767.0f ? -32767.0f : fs)); - - s = (short)fs; - buffer[pos] = s; - pos += channels; - } - - bufferp[channel] = pos; - } - - - /** - * Write the samples to the file (Random Acces). - */ - public void write_buffer(int val) - { - - //for (int i = 0; i < channels; ++i) - // bufferp[i] = (short)i; - - } - - public void close() - {} - - /** - * - */ - public void clear_buffer() - { - for (int i = 0; i < channels; ++i) - bufferp[i] = (short)i; - } - - /** - * - */ - public void set_stop_flag() - {} -} +/* + * 11/19/04 1.0 moved to LGPL. + * + * 12/12/99 Initial Version based on FileObuffer. mdm@techie.com. + * + * FileObuffer: + * 15/02/99 Java Conversion by E.B ,javalayer@javazoom.net + * + *----------------------------------------------------------------------- + * 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 SampleBuffer 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<-32767f){ + fs=-327.67f; + } + } + + /* + 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(int val) + { + + //for (int i = 0; i < channels; ++i) + // bufferp[i] = (short)i; + + } + + public void close() + {} + + /** + * + */ + public void clear_buffer() + { + for (int i = 0; i < channels; ++i) + bufferp[i] = (short)i; + } + + /** + * + */ + public void set_stop_flag() + {} +} diff --git a/Robust/src/Tests/ssJava/mp3decoder/Source.java b/Robust/src/Tests/ssJava/mp3decoder/Source.java index f4d7316a..ad2f0c91 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/Source.java +++ b/Robust/src/Tests/ssJava/mp3decoder/Source.java @@ -17,7 +17,6 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; import java.io.IOException; diff --git a/Robust/src/Tests/ssJava/mp3decoder/SynthesisFilter.java b/Robust/src/Tests/ssJava/mp3decoder/SynthesisFilter.java index b657b518..61d06aeb 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/SynthesisFilter.java +++ b/Robust/src/Tests/ssJava/mp3decoder/SynthesisFilter.java @@ -28,7 +28,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; import java.io.IOException; @@ -318,6 +317,7 @@ final class SynthesisFilter p7 = (pp6 - pp7) * cos1_4; p8 = pp8 + pp9; p9 = (pp8 - pp9) * cos1_4; + p10 = pp10 + pp11; p11 = (pp10 - pp11) * cos1_4; p12 = pp12 + pp13; diff --git a/Robust/src/Tests/ssJava/mp3decoder/huffcodetab.java b/Robust/src/Tests/ssJava/mp3decoder/huffcodetab.java index 64c98816..d64d1f25 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/huffcodetab.java +++ b/Robust/src/Tests/ssJava/mp3decoder/huffcodetab.java @@ -37,7 +37,6 @@ *---------------------------------------------------------------------- */ -package javazoom.jl.decoder; /** * Class to implements Huffman decoder. diff --git a/Robust/src/Tests/ssJava/mp3decoder/makefile b/Robust/src/Tests/ssJava/mp3decoder/makefile new file mode 100644 index 00000000..4bf22cbe --- /dev/null +++ b/Robust/src/Tests/ssJava/mp3decoder/makefile @@ -0,0 +1,23 @@ +BUILDSCRIPT=../../../buildscript + +PROGRAM=Player +SOURCE_FILES=Player.java + +BSFLAGS= -32bit -ssjava -printlinenum -mainclass $(PROGRAM) -heapsize-mb 1000 -garbagestats -joptimize -noloop -optimize -debug + +default: $(PROGRAM)s.bin + +$(PROGRAM)s.bin: $(SOURCE_FILES) makefile + $(BUILDSCRIPT) $(BSFLAGS) -o $(PROGRAM)s -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 +