From: yeom Date: Tue, 16 Aug 2011 01:36:06 +0000 (+0000) Subject: mp3decoder compiled by our research compiler produces the same output that I get... X-Git-Url: http://plrg.eecs.uci.edu/git/?p=IRC.git;a=commitdiff_plain;h=49f02b081d717c559f3739344164214fef287fb0 mp3decoder compiled by our research compiler produces the same output that I get from the mp3decoder compiled by OpenJDK. But SS checking was turned off, so still need to have more annotations/code changes to get desired properties, linear-type and ss. --- diff --git a/Robust/src/ClassLibrary/SSJava/BufferedInputStream.java b/Robust/src/ClassLibrary/SSJava/BufferedInputStream.java index e1144a3f..81f5066c 100644 --- a/Robust/src/ClassLibrary/SSJava/BufferedInputStream.java +++ b/Robust/src/ClassLibrary/SSJava/BufferedInputStream.java @@ -262,7 +262,8 @@ public class BufferedInputStream extends FilterInputStream { */ public synchronized int read(byte[] b, int off, int len) throws IOException { if (off < 0 || len < 0 || b.length - off < len) - throw new IndexOutOfBoundsException(); +// throw new IndexOutOfBoundsException(); + return -1; if (len == 0) return 0; diff --git a/Robust/src/ClassLibrary/SSJava/PushbackInputStream.java b/Robust/src/ClassLibrary/SSJava/PushbackInputStream.java index 904ab203..70ad6550 100644 --- a/Robust/src/ClassLibrary/SSJava/PushbackInputStream.java +++ b/Robust/src/ClassLibrary/SSJava/PushbackInputStream.java @@ -212,11 +212,9 @@ public class PushbackInputStream extends FilterInputStream { public synchronized int read(@LOC("OUT") byte[] b, @LOC("THIS,PushbackInputStream.POS") int off, @LOC("THIS,PushbackInputStream.POS") int len) throws IOException { @LOC("THIS,PushbackInputStream.POS") int numBytes = Math.min(buf.length - pos, len); -System.out.println("numBytes="+numBytes+" buf.length="+buf.length+" pos="+pos); + if (numBytes > 0) { - System.out.println("buf[pos]="+buf[pos]); - System.arraycopy(buf, pos, b, off, numBytes); pos += numBytes; len -= numBytes; @@ -224,7 +222,6 @@ System.out.println("numBytes="+numBytes+" buf.length="+buf.length+" pos="+pos); } if (len > 0) { - System.out.println("len>0"); len = super.read(b, off, len); if (len == -1) // EOF return numBytes > 0 ? numBytes : -1; diff --git a/Robust/src/Tests/ssJava/mp3decoder/Bitstream.java b/Robust/src/Tests/ssJava/mp3decoder/Bitstream.java index b7430c8b..2af59207 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/Bitstream.java +++ b/Robust/src/Tests/ssJava/mp3decoder/Bitstream.java @@ -266,30 +266,31 @@ public final class Bitstream implements BitstreamErrors { * of the stream has been reached. */ public Header readFrame() throws BitstreamException { - - System.out.println("ST"); - + Header result = null; try { - System.out.println("HERE?"); result = readNextFrame(); - System.out.println("HERE?2"); + 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 { System.out.println("ET"); - + try { closeFrame(); result = readNextFrame(); } catch (BitstreamException e) { @@ -303,7 +304,6 @@ public final class Bitstream implements BitstreamErrors { throw newBitstreamException(ex.getErrorCode(), ex); } } - System.out.println("EN"); return result; } @@ -315,9 +315,10 @@ public final class Bitstream implements BitstreamErrors { * @throws BitstreamException */ private Header readNextFrame() throws BitstreamException { - System.out.println("framesize="+framesize); if (framesize == -1) { - nextFrame(); + if (nextFrame() == -1) { + return null; + } } return header; } @@ -327,10 +328,10 @@ public final class Bitstream implements BitstreamErrors { * * @throws BitstreamException */ - private void nextFrame() throws BitstreamException { + private int nextFrame() throws BitstreamException { // entire frame is read by the header class. - System.out.println("nextFrame()"); - header.read_header(this, crc); + // header.read_header(this, crc); + return header.read_header(this, crc); } /** @@ -468,8 +469,11 @@ public final class Bitstream implements BitstreamErrors { do { headerstring <<= 8; - if (readBytes(syncbuf, 3, 1) != 1) + if (readBytes(syncbuf, 3, 1) != 1) { + // System.out.println("THROW NEW BITSTREAM EXCEPTION"); + return -1; throw newBitstreamException(STREAM_EOF, null); + } headerstring |= (syncbuf[3] & 0x000000FF); @@ -686,7 +690,6 @@ public final class Bitstream implements BitstreamErrors { // first, store main_data_begin from the side inforamtion main_data_begin = peek_bits(9); - System.out.println("main_data_begin=" + main_data_begin); int max; if (channelType == 1) { // mono @@ -728,7 +731,6 @@ public final class Bitstream implements BitstreamErrors { frame_start += nSlots; if (bytes_to_discard < 0) { - System.out.println("HERE?"); return null; } diff --git a/Robust/src/Tests/ssJava/mp3decoder/Decoder.java b/Robust/src/Tests/ssJava/mp3decoder/Decoder.java index 87f1b7f3..e7ca3fd2 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/Decoder.java +++ b/Robust/src/Tests/ssJava/mp3decoder/Decoder.java @@ -146,7 +146,7 @@ public class Decoder implements DecoderErrors { @LOC("TH") int layer = header.layer(); output.clear_buffer(); -System.out.println("HERE?="+layer); + @LOC("DE,Decoder.DE") FrameDecoder decoder = retrieveDecoder(header, stream, layer); // return // ceil=DELTA(TH) decoder.decodeFrame(); diff --git a/Robust/src/Tests/ssJava/mp3decoder/Header.java b/Robust/src/Tests/ssJava/mp3decoder/Header.java index 6da0e4dd..10c7d343 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/Header.java +++ b/Robust/src/Tests/ssJava/mp3decoder/Header.java @@ -142,14 +142,15 @@ public final class Header { /** * Read a 32-bit header from the bitstream. */ - void read_header(Bitstream stream, Crc16[] crcp) throws BitstreamException { - System.out.print("READ_HEADER_ST"); + int read_header(Bitstream stream, Crc16[] crcp) throws BitstreamException { int headerstring; int channel_bitrate; boolean sync = false; do { - System.out.println("DO!"); headerstring = stream.syncHeader(syncmode); + if(headerstring==-1){ + return -1; + } _headerstring = headerstring; // E.B if (syncmode == Bitstream.INITIAL_SYNC) { h_version = ((headerstring >>> 19) & 1); @@ -218,7 +219,6 @@ public final class Header { } else { stream.unreadFrame(); } - System.out.println("do"); } while (!sync); stream.parse_frame(); if (h_protection_bit == 0) { @@ -239,7 +239,7 @@ public final class Header { * offset[cf-1] + h_padding_bit; } else { offset[0] = h_padding_bit; } */ } - System.out.print("READ_HEADER_ED"); + return 0; } /** diff --git a/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java b/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java index 31b71e2b..b7fde809 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java +++ b/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java @@ -108,7 +108,6 @@ final class LayerIIIDecoder implements FrameDecoder { private int part2_start; - /** * Constructor. */ @@ -318,9 +317,7 @@ final class LayerIIIDecoder implements FrameDecoder { // 'ch', 'channels' should be higher than all locs in the below body for (ch = 0; ch < channels; ch++) { - @LOC("THIS,LayerIIIDecoder.BR,BitReserve.BIT") int part2_start = br.hsstell(); // part2_start - // < - // br + part2_start = br.hsstell(); // grab scale factors from the main data. // following the scale factors is the actual compressed data @@ -333,7 +330,7 @@ final class LayerIIIDecoder implements FrameDecoder { // here, decoding the compressed audio data huffman_decode(ch, gr); // no need to care from this side - // System.out.println("CheckSum HuffMan = " + CheckSumHuff); +// System.out.println("CheckSum HuffMan = " + CheckSumHuff); dequantize_sample(/* ro[ch], */ch, gr); // no need to care from this // side } @@ -354,14 +351,20 @@ final class LayerIIIDecoder implements FrameDecoder { reorder(/* lr[ch], */ch, gr); antialias(ch, gr); - // for (int hb = 0;hb<576;hb++) CheckSumOut1d = CheckSumOut1d + - // out_1d[hb]; - // System.out.println("CheckSumOut1d = "+CheckSumOut1d); + +// float CheckSumOut1d=0; +// for (int hb = 0;hb<576;hb++) { +// CheckSumOut1d = CheckSumOut1d + out_1d[hb]; +// } +// System.out.println("CheckSumOut1d = "+CheckSumOut1d); + hybrid(ch, gr); - // for (int hb = 0;hb<576;hb++) CheckSumOut1d = CheckSumOut1d + - // out_1d[hb]; + // float CheckSumOut1d=0; + // for (int hb = 0;hb<576;hb++) { + // CheckSumOut1d = CheckSumOut1d + out_1d[hb]; + // } // System.out.println("CheckSumOut1d = "+CheckSumOut1d); for (sb18 = 18; sb18 < 576; sb18 += 36) { @@ -892,7 +895,7 @@ final class LayerIIIDecoder implements FrameDecoder { is_1d[index++] = y[0]; CheckSumHuff = CheckSumHuff + x[0] + y[0]; - // System.out.println("x = "+x[0]+" y = "+y[0]); +// System.out.println("x = " + x[0] + " y = " + y[0]); } // Read count1 area diff --git a/Robust/src/Tests/ssJava/mp3decoder/Player.java b/Robust/src/Tests/ssJava/mp3decoder/Player.java index 14db695e..3d59e83c 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/Player.java +++ b/Robust/src/Tests/ssJava/mp3decoder/Player.java @@ -1,3 +1,4 @@ +import FileOutputStream; /* * 11/19/04 1.0 moved to LGPL. @@ -19,249 +20,215 @@ *---------------------------------------------------------------------- */ - - /** - * The Player class implements a simple player for playback - * of an MPEG audio stream. + * The Player class implements a simple player for playback of an + * MPEG audio stream. * - * @author Mat McGowan - * @since 0.0.8 + * @author Mat McGowan + * @since 0.0.8 */ // REVIEW: the audio device should not be opened until the -// first MPEG audio frame has been decoded. +// first MPEG audio frame has been decoded. @LATTICE("BPlayer instance. - */ - public Player(InputStream stream) throws JavaLayerException - { - this(stream, null); - } - - - public Player(InputStream stream, 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("IN 0 && ret) - { - System.out.println("DECODE"); - ret = decodeFrame(); - } - /* - if (!ret) - { - // last frame, ensure all data flushed to the audio device. - AudioDevice out = audio; - if (out!=null) - { - out.flush(); - synchronized (this) - { - complete = (!closed); - close(); - } - } - } - */ - return ret; - } - - /** - * Cloases this player. Any audio currently playing is stopped - * immediately. - */ - - public synchronized void close() - { -/* - AudioDevice out = audio; - if (out!=null) - { - closed = true; - audio = null; - // this may fail, so ensure object state is set up before - // calling this method. - out.close(); - lastPosition = out.getPosition(); - try - { - bitstream.close(); - } - catch (BitstreamException ex) - { - } - } -*/ - } - - - /** - * Returns the completed status of this player. - * - * @return true if all available MPEG audio frames have been - * decoded, or false otherwise. - */ - public synchronized boolean isComplete() - { - return complete; - } - - /** - * Retrieves the position in milliseconds of the current audio - * sample being played. This method delegates to the - * 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("OPlayer instance. + */ + public Player(InputStream stream) throws JavaLayerException { + this(stream, null); + } + + public Player(InputStream stream, 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("IN 0 && ret) { + ret = decodeFrame(); + } + + // fos.flush(); + // fos.close(); + /* + * if (!ret) { // last frame, ensure all data flushed to the audio device. + * AudioDevice out = audio; if (out!=null) { out.flush(); synchronized + * (this) { complete = (!closed); close(); } } } + */ + return ret; + } + + /** + * Cloases this player. Any audio currently playing is stopped immediately. + */ + + public synchronized void close() { + /* + * AudioDevice out = audio; if (out!=null) { closed = true; audio = null; // + * this may fail, so ensure object state is set up before // calling this + * method. out.close(); lastPosition = out.getPosition(); try { + * bitstream.close(); } catch (BitstreamException ex) { } } + */ + } + + /** + * Returns the completed status of this player. + * + * @return true if all available MPEG audio frames have been decoded, or false + * otherwise. + */ + public synchronized boolean isComplete() { + return complete; + } + + /** + * Retrieves the position in milliseconds of the current audio sample being + * played. This method delegates to the + * 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("OSampleBuffer class implements an output buffer - * that provides storage for a fixed size block of samples. + * 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 + 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 + // anyway, LOC(bufferp[i])=[D,SampleBuffer.BUFP] is lower than all + // locations that have in-flows } } - public int getChannelCount() - { - return this.channels; + public int getChannelCount() { + return this.channels; } - public int getSampleFrequency() - { + public int getSampleFrequency() { return this.frequency; } - public short[] getBuffer() - { - return this.buffer; + public short[] getBuffer() { + return this.buffer; } - public int getBufferLength() - { + 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; + 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] - + + 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; + + 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; + // 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)); - */ + * 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 + 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 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; + 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) - { + public void write_buffer(@LOC("IN") int val) { - //for (int i = 0; i < channels; ++i) - // bufferp[i] = (short)i; + // for (int i = 0; i < channels; ++i) + // bufferp[i] = (short)i; } - public void close() - {} + public void close() { + } /** * */ - public void clear_buffer() - { - for (idx = 0; idx < channels; ++idx) - bufferp[idx] = (short)idx; + public void clear_buffer() { + for (idx = 0; idx < channels; ++idx) + bufferp[idx] = (short) idx; } /** * */ - public void set_stop_flag() - {} + public void set_stop_flag() { + } } diff --git a/Robust/src/Tests/ssJava/mp3decoder/SynthesisFilter.java b/Robust/src/Tests/ssJava/mp3decoder/SynthesisFilter.java index aae9bc46..f9b7a4a2 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/SynthesisFilter.java +++ b/Robust/src/Tests/ssJava/mp3decoder/SynthesisFilter.java @@ -29,30 +29,19 @@ *---------------------------------------------------------------------- */ -//import java.io.IOException; //Compiler does not support imports - /** * A class for the synthesis filter bank. This class does a fast downsampling * from 32, 44.1 or 48 kHz to 8 kHz, if ULAW is defined. Frequencies above 4 kHz * are removed by ignoring higher subbands. */ -@LATTICE("TMP= 0; i--) { + public void input_samples(float[] s) { + for (int i = 31; i >= 0; i--) { samples[i] = s[i] * eq[i]; } } @@ -167,121 +155,118 @@ final class SynthesisFilter { * for (int i=31; i>=0; i--) { new_v[i] = 0.0f; } */ - @LOC("IN,SynthesisFilter.L4") float new_v0 = 0.0f; - @LOC("IN,SynthesisFilter.L2") float new_v1 = 0.0f; - @LOC("IN,SynthesisFilter.L4") float new_v2 = 0.0f; - @LOC("IN,SynthesisFilter.L2") float new_v3 = 0.0f; - @LOC("IN,SynthesisFilter.L3") float new_v4 = 0.0f; - @LOC("IN,SynthesisFilter.L4") float new_v5 = 0.0f; - @LOC("IN,SynthesisFilter.L2") float new_v6 = 0.0f; - @LOC("IN,SynthesisFilter.L3") float new_v7 = 0.0f; - @LOC("IN,SynthesisFilter.L4") float new_v8 = 0.0f; - @LOC("IN,SynthesisFilter.L4") float new_v9 = 0.0f; - @LOC("IN,SynthesisFilter.L3") float new_v10 = 0.0f; - @LOC("IN,SynthesisFilter.L2") float new_v11 = 0.0f; - @LOC("IN,SynthesisFilter.L4") float new_v12 = 0.0f; - @LOC("IN,SynthesisFilter.L3") float new_v13 = 0.0f; - @LOC("IN,SynthesisFilter.L4") float new_v14 = 0.0f; - @LOC("IN,SynthesisFilter.L4") float new_v15 = 0.0f; - @LOC("IN,SynthesisFilter.L1") float new_v16 = 0.0f; - @LOC("IN,SynthesisFilter.L3") float new_v17 = 0.0f; - @LOC("IN,SynthesisFilter.L1") float new_v18 = 0.0f; - @LOC("IN,SynthesisFilter.L2") float new_v19 = 0.0f; - @LOC("IN,SynthesisFilter.L2") float new_v20 = 0.0f; - @LOC("IN,SynthesisFilter.L2") float new_v21 = 0.0f; - @LOC("IN,SynthesisFilter.L2") float new_v22 = 0.0f; - @LOC("IN,SynthesisFilter.L3") float new_v23 = 0.0f; - @LOC("IN,SynthesisFilter.L2") float new_v24 = 0.0f; - @LOC("IN,SynthesisFilter.L2") float new_v25 = 0.0f; - @LOC("IN,SynthesisFilter.L2") float new_v26 = 0.0f; - @LOC("IN,SynthesisFilter.L4") float new_v27 = 0.0f; - @LOC("IN,SynthesisFilter.L2") float new_v28 = 0.0f; - @LOC("IN,SynthesisFilter.L4") float new_v29 = 0.0f; - @LOC("IN,SynthesisFilter.L2") float new_v30 = 0.0f; - @LOC("IN,SynthesisFilter.L4") float new_v31 = 0.0f; - - // new_v0 = new_v1 = new_v2 = new_v3 = new_v4 = new_v5 = new_v6 = new_v7 = - // new_v8 = new_v9 = - // new_v10 = new_v11 = new_v12 = new_v13 = new_v14 = new_v15 = new_v16 = - // new_v17 = new_v18 = new_v19 = - // new_v20 = new_v21 = new_v22 = new_v23 = new_v24 = new_v25 = new_v26 = - // new_v27 = new_v28 = new_v29 = - // new_v30 = new_v31 = 0.0f; + float new_v0, new_v1, new_v2, new_v3, new_v4, new_v5, new_v6, new_v7, new_v8, new_v9; + float new_v10, new_v11, new_v12, new_v13, new_v14, new_v15, new_v16, new_v17, new_v18, new_v19; + float new_v20, new_v21, new_v22, new_v23, new_v24, new_v25, new_v26, new_v27, new_v28, new_v29; + float new_v30, new_v31; + + new_v0 = + new_v1 = + new_v2 = + new_v3 = + new_v4 = + new_v5 = + new_v6 = + new_v7 = + new_v8 = + new_v9 = + new_v10 = + new_v11 = + new_v12 = + new_v13 = + new_v14 = + new_v15 = + new_v16 = + new_v17 = + new_v18 = + new_v19 = + new_v20 = + new_v21 = + new_v22 = + new_v23 = + new_v24 = + new_v25 = + new_v26 = + new_v27 = + new_v28 = + new_v29 = + new_v30 = + 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; // subbed in samples directly below to reduce - // uneccesary areas - - @LOC("IN,SynthesisFilter.S") float s0 = samples[0]; - @LOC("IN,SynthesisFilter.S") float s1 = samples[1]; - @LOC("IN,SynthesisFilter.S") float s2 = samples[2]; - @LOC("IN,SynthesisFilter.S") float s3 = samples[3]; - @LOC("IN,SynthesisFilter.S") float s4 = samples[4]; - @LOC("IN,SynthesisFilter.S") float s5 = samples[5]; - @LOC("IN,SynthesisFilter.S") float s6 = samples[6]; - @LOC("IN,SynthesisFilter.S") float s7 = samples[7]; - @LOC("IN,SynthesisFilter.S") float s8 = samples[8]; - @LOC("IN,SynthesisFilter.S") float s9 = samples[9]; - @LOC("IN,SynthesisFilter.S") float s10 = samples[10]; - @LOC("IN,SynthesisFilter.S") float s11 = samples[11]; - @LOC("IN,SynthesisFilter.S") float s12 = samples[12]; - @LOC("IN,SynthesisFilter.S") float s13 = samples[13]; - @LOC("IN,SynthesisFilter.S") float s14 = samples[14]; - @LOC("IN,SynthesisFilter.S") float s15 = samples[15]; - @LOC("IN,SynthesisFilter.S") float s16 = samples[16]; - @LOC("IN,SynthesisFilter.S") float s17 = samples[17]; - @LOC("IN,SynthesisFilter.S") float s18 = samples[18]; - @LOC("IN,SynthesisFilter.S") float s19 = samples[19]; - @LOC("IN,SynthesisFilter.S") float s20 = samples[20]; - @LOC("IN,SynthesisFilter.S") float s21 = samples[21]; - @LOC("IN,SynthesisFilter.S") float s22 = samples[22]; - @LOC("IN,SynthesisFilter.S") float s23 = samples[23]; - @LOC("IN,SynthesisFilter.S") float s24 = samples[24]; - @LOC("IN,SynthesisFilter.S") float s25 = samples[25]; - @LOC("IN,SynthesisFilter.S") float s26 = samples[26]; - @LOC("IN,SynthesisFilter.S") float s27 = samples[27]; - @LOC("IN,SynthesisFilter.S") float s28 = samples[28]; - @LOC("IN,SynthesisFilter.S") float s29 = samples[29]; - @LOC("IN,SynthesisFilter.S") float s30 = samples[30]; - @LOC("IN,SynthesisFilter.S") float s31 = samples[31]; - - @LOC("IN,SynthesisFilter.LSH") float p0 = s0 + s31; - @LOC("IN,SynthesisFilter.LSH") float p1 = s1 + s30; - @LOC("IN,SynthesisFilter.LSH") float p2 = s2 + s29; - @LOC("IN,SynthesisFilter.LSH") float p3 = s3 + s28; - @LOC("IN,SynthesisFilter.LSH") float p4 = s4 + s27; - @LOC("IN,SynthesisFilter.LSH") float p5 = s5 + s26; - @LOC("IN,SynthesisFilter.LSH") float p6 = s6 + s25; - @LOC("IN,SynthesisFilter.LSH") float p7 = s7 + s24; - @LOC("IN,SynthesisFilter.LSH") float p8 = s8 + s23; - @LOC("IN,SynthesisFilter.LSH") float p9 = s9 + s22; - @LOC("IN,SynthesisFilter.LSH") float p10 = s10 + s21; - @LOC("IN,SynthesisFilter.LSH") float p11 = s11 + s20; - @LOC("IN,SynthesisFilter.LSH") float p12 = s12 + s19; - @LOC("IN,SynthesisFilter.LSH") float p13 = s13 + s18; - @LOC("IN,SynthesisFilter.LSH") float p14 = s14 + s17; - @LOC("IN,SynthesisFilter.LSH") float p15 = s15 + s16; - - @LOC("IN,SynthesisFilter.LSH") float pp0 = p0 + p15; - @LOC("IN,SynthesisFilter.LSH") float pp1 = p1 + p14; - @LOC("IN,SynthesisFilter.LSH") float pp2 = p2 + p13; - @LOC("IN,SynthesisFilter.LSH") float pp3 = p3 + p12; - @LOC("IN,SynthesisFilter.LSH") float pp4 = p4 + p11; - @LOC("IN,SynthesisFilter.LSH") float pp5 = p5 + p10; - @LOC("IN,SynthesisFilter.LSH") float pp6 = p6 + p9; - @LOC("IN,SynthesisFilter.LSH") float pp7 = p7 + p8; - @LOC("IN,SynthesisFilter.LSH") float pp8 = (p0 - p15) * cos1_32; - @LOC("IN,SynthesisFilter.LSH") float pp9 = (p1 - p14) * cos3_32; - @LOC("IN,SynthesisFilter.LSH") float pp10 = (p2 - p13) * cos5_32; - @LOC("IN,SynthesisFilter.LSH") float pp11 = (p3 - p12) * cos7_32; - @LOC("IN,SynthesisFilter.LSH") float pp12 = (p4 - p11) * cos9_32; - @LOC("IN,SynthesisFilter.LSH") float pp13 = (p5 - p10) * cos11_32; - @LOC("IN,SynthesisFilter.LSH") float pp14 = (p6 - p9) * cos13_32; - @LOC("IN,SynthesisFilter.LSH") float pp15 = (p7 - p8) * cos15_32; + float[] s = samples; + + float s0 = s[0]; + float s1 = s[1]; + float s2 = s[2]; + float s3 = s[3]; + float s4 = s[4]; + float s5 = s[5]; + float s6 = s[6]; + float s7 = s[7]; + float s8 = s[8]; + float s9 = s[9]; + float s10 = s[10]; + float s11 = s[11]; + float s12 = s[12]; + float s13 = s[13]; + float s14 = s[14]; + float s15 = s[15]; + float s16 = s[16]; + float s17 = s[17]; + float s18 = s[18]; + float s19 = s[19]; + float s20 = s[20]; + float s21 = s[21]; + float s22 = s[22]; + float s23 = s[23]; + float s24 = s[24]; + float s25 = s[25]; + float s26 = s[26]; + float s27 = s[27]; + float s28 = s[28]; + float s29 = s[29]; + float s30 = s[30]; + float s31 = s[31]; + + float p0 = s0 + s31; + float p1 = s1 + s30; + float p2 = s2 + s29; + float p3 = s3 + s28; + float p4 = s4 + s27; + float p5 = s5 + s26; + float p6 = s6 + s25; + float p7 = s7 + s24; + float p8 = s8 + s23; + float p9 = s9 + s22; + float p10 = s10 + s21; + float p11 = s11 + s20; + float p12 = s12 + s19; + float p13 = s13 + s18; + float p14 = s14 + s17; + float p15 = s15 + s16; + + float pp0 = p0 + p15; + float pp1 = p1 + p14; + float pp2 = p2 + p13; + float pp3 = p3 + p12; + float pp4 = p4 + p11; + float pp5 = p5 + p10; + float pp6 = p6 + p9; + float pp7 = p7 + p8; + float pp8 = (p0 - p15) * cos1_32; + float pp9 = (p1 - p14) * cos3_32; + float pp10 = (p2 - p13) * cos5_32; + float pp11 = (p3 - p12) * cos7_32; + float pp12 = (p4 - p11) * cos9_32; + float pp13 = (p5 - p10) * cos11_32; + float pp14 = (p6 - p9) * cos13_32; + float pp15 = (p7 - p8) * cos15_32; p0 = pp0 + pp7; p1 = pp1 + pp6; @@ -327,7 +312,6 @@ 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; @@ -336,7 +320,7 @@ final class SynthesisFilter { p15 = (pp14 - pp15) * cos1_4; // this is pretty insane coding - @LOC("IN,SynthesisFilter.L3") float tmp1; + 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; @@ -435,18 +419,9 @@ final class SynthesisFilter { // manually doing something that a compiler should handle sucks // coding like this is hard to read - @LOC("IN,SynthesisFilter.L4") float tmp2; - // new_v5 = (new_v11 = (new_v13 = (new_v15 = p15) + p7) + p11) - // + p5 + p13; - new_v15 = p15; - new_v13 = p15 + p7; - new_v11 = p15 + p7 + p11; - new_v5 = p15 + p7 + p11 + p5 + p13; - - // new_v7 = (new_v9 = p15 + p11 + p3) + p13; - new_v9 = p15 + p11 + p3; - new_v7 = new_v9 + p13; - + 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; @@ -459,536 +434,781 @@ final class SynthesisFilter { // insert V[0-15] (== new_v[0-15]) into actual v: // float[] x2 = actual_v + actual_write_pos; - // float dest[] = actual_v; //actual_v subbed in so as not to create a new - // area - - // int pos = actual_write_pos; //substituted to simplify location relations - - v1[0 + actual_write_pos] = new_v0; - v1[16 + actual_write_pos] = new_v1; - v1[32 + actual_write_pos] = new_v2; - v1[48 + actual_write_pos] = new_v3; - v1[64 + actual_write_pos] = new_v4; - v1[80 + actual_write_pos] = new_v5; - v1[96 + actual_write_pos] = new_v6; - v1[112 + actual_write_pos] = new_v7; - v1[128 + actual_write_pos] = new_v8; - v1[144 + actual_write_pos] = new_v9; - v1[160 + actual_write_pos] = new_v10; - v1[176 + actual_write_pos] = new_v11; - v1[192 + actual_write_pos] = new_v12; - v1[208 + actual_write_pos] = new_v13; - v1[224 + actual_write_pos] = new_v14; - v1[240 + actual_write_pos] = new_v15; + float dest[] = actual_v; + + int pos = actual_write_pos; + + dest[0 + pos] = new_v0; + dest[16 + pos] = new_v1; + dest[32 + pos] = new_v2; + dest[48 + pos] = new_v3; + dest[64 + pos] = new_v4; + dest[80 + pos] = new_v5; + dest[96 + pos] = new_v6; + dest[112 + pos] = new_v7; + dest[128 + pos] = new_v8; + dest[144 + pos] = new_v9; + dest[160 + pos] = new_v10; + dest[176 + pos] = new_v11; + dest[192 + pos] = new_v12; + dest[208 + pos] = new_v13; + dest[224 + pos] = new_v14; + dest[240 + pos] = new_v15; // V[16] is always 0.0: - v1[256 + actual_write_pos] = 0.0f; + dest[256 + pos] = 0.0f; // insert V[17-31] (== -new_v[15-1]) into actual v: - v1[272 + actual_write_pos] = -new_v15; - v1[288 + actual_write_pos] = -new_v14; - v1[304 + actual_write_pos] = -new_v13; - v1[320 + actual_write_pos] = -new_v12; - v1[336 + actual_write_pos] = -new_v11; - v1[352 + actual_write_pos] = -new_v10; - v1[368 + actual_write_pos] = -new_v9; - v1[384 + actual_write_pos] = -new_v8; - v1[400 + actual_write_pos] = -new_v7; - v1[416 + actual_write_pos] = -new_v6; - v1[432 + actual_write_pos] = -new_v5; - v1[448 + actual_write_pos] = -new_v4; - v1[464 + actual_write_pos] = -new_v3; - v1[480 + actual_write_pos] = -new_v2; - v1[496 + actual_write_pos] = -new_v1; + dest[272 + pos] = -new_v15; + dest[288 + pos] = -new_v14; + dest[304 + pos] = -new_v13; + dest[320 + pos] = -new_v12; + dest[336 + pos] = -new_v11; + dest[352 + pos] = -new_v10; + dest[368 + pos] = -new_v9; + dest[384 + pos] = -new_v8; + dest[400 + pos] = -new_v7; + dest[416 + pos] = -new_v6; + dest[432 + pos] = -new_v5; + dest[448 + pos] = -new_v4; + dest[464 + pos] = -new_v3; + dest[480 + pos] = -new_v2; + dest[496 + pos] = -new_v1; // insert V[32] (== -new_v[0]) into other v: - // dest = (actual_v==v1) ? v2 : v1; //assignment replaced with if statement - // so that new areas are not created + dest = (actual_v == v1) ? v2 : v1; - v2[0 + actual_write_pos] = -new_v0; + dest[0 + pos] = -new_v0; // insert V[33-48] (== new_v[16-31]) into other v: - v2[16 + actual_write_pos] = new_v16; - v2[32 + actual_write_pos] = new_v17; - v2[48 + actual_write_pos] = new_v18; - v2[64 + actual_write_pos] = new_v19; - v2[80 + actual_write_pos] = new_v20; - v2[96 + actual_write_pos] = new_v21; - v2[112 + actual_write_pos] = new_v22; - v2[128 + actual_write_pos] = new_v23; - v2[144 + actual_write_pos] = new_v24; - v2[160 + actual_write_pos] = new_v25; - v2[176 + actual_write_pos] = new_v26; - v2[192 + actual_write_pos] = new_v27; - v2[208 + actual_write_pos] = new_v28; - v2[224 + actual_write_pos] = new_v29; - v2[240 + actual_write_pos] = new_v30; - v2[256 + actual_write_pos] = new_v31; + dest[16 + pos] = new_v16; + dest[32 + pos] = new_v17; + dest[48 + pos] = new_v18; + dest[64 + pos] = new_v19; + dest[80 + pos] = new_v20; + dest[96 + pos] = new_v21; + dest[112 + pos] = new_v22; + dest[128 + pos] = new_v23; + dest[144 + pos] = new_v24; + dest[160 + pos] = new_v25; + dest[176 + pos] = new_v26; + dest[192 + pos] = new_v27; + dest[208 + pos] = new_v28; + dest[224 + pos] = new_v29; + dest[240 + pos] = new_v30; + dest[256 + pos] = new_v31; // insert V[49-63] (== new_v[30-16]) into other v: - v2[272 + actual_write_pos] = new_v30; - v2[288 + actual_write_pos] = new_v29; - v2[304 + actual_write_pos] = new_v28; - v2[320 + actual_write_pos] = new_v27; - v2[336 + actual_write_pos] = new_v26; - v2[352 + actual_write_pos] = new_v25; - v2[368 + actual_write_pos] = new_v24; - v2[384 + actual_write_pos] = new_v23; - v2[400 + actual_write_pos] = new_v22; - v2[416 + actual_write_pos] = new_v21; - v2[432 + actual_write_pos] = new_v20; - v2[448 + actual_write_pos] = new_v19; - v2[464 + actual_write_pos] = new_v18; - v2[480 + actual_write_pos] = new_v17; - v2[496 + actual_write_pos] = new_v16; + dest[272 + pos] = new_v30; + dest[288 + pos] = new_v29; + dest[304 + pos] = new_v28; + dest[320 + pos] = new_v27; + dest[336 + pos] = new_v26; + dest[352 + pos] = new_v25; + dest[368 + pos] = new_v24; + dest[384 + pos] = new_v23; + dest[400 + pos] = new_v22; + dest[416 + pos] = new_v21; + dest[432 + pos] = new_v20; + dest[448 + pos] = new_v19; + dest[464 + pos] = new_v18; + dest[480 + pos] = new_v17; + dest[496 + pos] = new_v16; + /* + * } else { v1[0 + actual_write_pos] = -new_v0; // insert V[33-48] (== + * new_v[16-31]) into other v: v1[16 + actual_write_pos] = new_v16; v1[32 + + * actual_write_pos] = new_v17; v1[48 + actual_write_pos] = new_v18; v1[64 + + * actual_write_pos] = new_v19; v1[80 + actual_write_pos] = new_v20; v1[96 + + * actual_write_pos] = new_v21; v1[112 + actual_write_pos] = new_v22; v1[128 + * + actual_write_pos] = new_v23; v1[144 + actual_write_pos] = new_v24; + * v1[160 + actual_write_pos] = new_v25; v1[176 + actual_write_pos] = + * new_v26; v1[192 + actual_write_pos] = new_v27; v1[208 + actual_write_pos] + * = new_v28; v1[224 + actual_write_pos] = new_v29; v1[240 + + * actual_write_pos] = new_v30; v1[256 + actual_write_pos] = new_v31; + * + * // insert V[49-63] (== new_v[30-16]) into other v: v1[272 + + * actual_write_pos] = new_v30; v1[288 + actual_write_pos] = new_v29; v1[304 + * + actual_write_pos] = new_v28; v1[320 + actual_write_pos] = new_v27; + * v1[336 + actual_write_pos] = new_v26; v1[352 + actual_write_pos] = + * new_v25; v1[368 + actual_write_pos] = new_v24; v1[384 + actual_write_pos] + * = new_v23; v1[400 + actual_write_pos] = new_v22; v1[416 + + * actual_write_pos] = new_v21; v1[432 + actual_write_pos] = new_v20; v1[448 + * + actual_write_pos] = new_v19; v1[464 + actual_write_pos] = new_v18; + * v1[480 + actual_write_pos] = new_v17; v1[496 + actual_write_pos] = + * new_v16; } + */ + } + + /** + * Compute new values via a fast cosine transform. + */ + private void compute_new_v_old() { + // p is fully initialized from x1 + // float[] p = _p; + // pp is fully initialized from p + // float[] pp = _pp; + + // float[] new_v = _new_v; + + 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]; + + for (int i = 31; i >= 0; i--) { + new_v[i] = 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[] x1 = samples; + + p[0] = x1[0] + x1[31]; + p[1] = x1[1] + x1[30]; + p[2] = x1[2] + x1[29]; + p[3] = x1[3] + x1[28]; + p[4] = x1[4] + x1[27]; + p[5] = x1[5] + x1[26]; + p[6] = x1[6] + x1[25]; + p[7] = x1[7] + x1[24]; + p[8] = x1[8] + x1[23]; + p[9] = x1[9] + x1[22]; + p[10] = x1[10] + x1[21]; + p[11] = x1[11] + x1[20]; + p[12] = x1[12] + x1[19]; + p[13] = x1[13] + x1[18]; + p[14] = x1[14] + x1[17]; + p[15] = x1[15] + x1[16]; + + pp[0] = p[0] + p[15]; + pp[1] = p[1] + p[14]; + pp[2] = p[2] + p[13]; + pp[3] = p[3] + p[12]; + pp[4] = p[4] + p[11]; + pp[5] = p[5] + p[10]; + pp[6] = p[6] + p[9]; + pp[7] = p[7] + p[8]; + pp[8] = (p[0] - p[15]) * cos1_32; + pp[9] = (p[1] - p[14]) * cos3_32; + pp[10] = (p[2] - p[13]) * cos5_32; + pp[11] = (p[3] - p[12]) * cos7_32; + pp[12] = (p[4] - p[11]) * cos9_32; + pp[13] = (p[5] - p[10]) * cos11_32; + pp[14] = (p[6] - p[9]) * cos13_32; + pp[15] = (p[7] - p[8]) * cos15_32; + + p[0] = pp[0] + pp[7]; + p[1] = pp[1] + pp[6]; + p[2] = pp[2] + pp[5]; + p[3] = pp[3] + pp[4]; + p[4] = (pp[0] - pp[7]) * cos1_16; + p[5] = (pp[1] - pp[6]) * cos3_16; + p[6] = (pp[2] - pp[5]) * cos5_16; + p[7] = (pp[3] - pp[4]) * cos7_16; + p[8] = pp[8] + pp[15]; + p[9] = pp[9] + pp[14]; + p[10] = pp[10] + pp[13]; + p[11] = pp[11] + pp[12]; + p[12] = (pp[8] - pp[15]) * cos1_16; + p[13] = (pp[9] - pp[14]) * cos3_16; + p[14] = (pp[10] - pp[13]) * cos5_16; + p[15] = (pp[11] - pp[12]) * cos7_16; + + pp[0] = p[0] + p[3]; + pp[1] = p[1] + p[2]; + pp[2] = (p[0] - p[3]) * cos1_8; + pp[3] = (p[1] - p[2]) * cos3_8; + pp[4] = p[4] + p[7]; + pp[5] = p[5] + p[6]; + pp[6] = (p[4] - p[7]) * cos1_8; + pp[7] = (p[5] - p[6]) * cos3_8; + pp[8] = p[8] + p[11]; + pp[9] = p[9] + p[10]; + pp[10] = (p[8] - p[11]) * cos1_8; + pp[11] = (p[9] - p[10]) * cos3_8; + pp[12] = p[12] + p[15]; + pp[13] = p[13] + p[14]; + pp[14] = (p[12] - p[15]) * cos1_8; + pp[15] = (p[13] - p[14]) * cos3_8; + + p[0] = pp[0] + pp[1]; + p[1] = (pp[0] - pp[1]) * cos1_4; + p[2] = pp[2] + pp[3]; + p[3] = (pp[2] - pp[3]) * cos1_4; + p[4] = pp[4] + pp[5]; + p[5] = (pp[4] - pp[5]) * cos1_4; + p[6] = pp[6] + pp[7]; + p[7] = (pp[6] - pp[7]) * cos1_4; + p[8] = pp[8] + pp[9]; + p[9] = (pp[8] - pp[9]) * cos1_4; + p[10] = pp[10] + pp[11]; + p[11] = (pp[10] - pp[11]) * cos1_4; + p[12] = pp[12] + pp[13]; + p[13] = (pp[12] - pp[13]) * cos1_4; + p[14] = pp[14] + pp[15]; + p[15] = (pp[14] - pp[15]) * cos1_4; + + // this is pretty insane coding + float tmp1; + new_v[36 - 17] = -(new_v[4] = (new_v[12] = p[7]) + p[5]) - p[6]; + new_v[44 - 17] = -p[6] - p[7] - p[4]; + new_v[6] = (new_v[10] = (new_v[14] = p[15]) + p[11]) + p[13]; + new_v[34 - 17] = -(new_v[2] = p[15] + p[13] + p[9]) - p[14]; + new_v[38 - 17] = (tmp1 = -p[14] - p[15] - p[10] - p[11]) - p[13]; + new_v[46 - 17] = -p[14] - p[15] - p[12] - p[8]; + new_v[42 - 17] = tmp1 - p[12]; + new_v[48 - 17] = -p[0]; + new_v[0] = p[1]; + new_v[40 - 17] = -(new_v[8] = p[3]) - p[2]; + + p[0] = (x1[0] - x1[31]) * cos1_64; + p[1] = (x1[1] - x1[30]) * cos3_64; + p[2] = (x1[2] - x1[29]) * cos5_64; + p[3] = (x1[3] - x1[28]) * cos7_64; + p[4] = (x1[4] - x1[27]) * cos9_64; + p[5] = (x1[5] - x1[26]) * cos11_64; + p[6] = (x1[6] - x1[25]) * cos13_64; + p[7] = (x1[7] - x1[24]) * cos15_64; + p[8] = (x1[8] - x1[23]) * cos17_64; + p[9] = (x1[9] - x1[22]) * cos19_64; + p[10] = (x1[10] - x1[21]) * cos21_64; + p[11] = (x1[11] - x1[20]) * cos23_64; + p[12] = (x1[12] - x1[19]) * cos25_64; + p[13] = (x1[13] - x1[18]) * cos27_64; + p[14] = (x1[14] - x1[17]) * cos29_64; + p[15] = (x1[15] - x1[16]) * cos31_64; + + pp[0] = p[0] + p[15]; + pp[1] = p[1] + p[14]; + pp[2] = p[2] + p[13]; + pp[3] = p[3] + p[12]; + pp[4] = p[4] + p[11]; + pp[5] = p[5] + p[10]; + pp[6] = p[6] + p[9]; + pp[7] = p[7] + p[8]; + pp[8] = (p[0] - p[15]) * cos1_32; + pp[9] = (p[1] - p[14]) * cos3_32; + pp[10] = (p[2] - p[13]) * cos5_32; + pp[11] = (p[3] - p[12]) * cos7_32; + pp[12] = (p[4] - p[11]) * cos9_32; + pp[13] = (p[5] - p[10]) * cos11_32; + pp[14] = (p[6] - p[9]) * cos13_32; + pp[15] = (p[7] - p[8]) * cos15_32; + + p[0] = pp[0] + pp[7]; + p[1] = pp[1] + pp[6]; + p[2] = pp[2] + pp[5]; + p[3] = pp[3] + pp[4]; + p[4] = (pp[0] - pp[7]) * cos1_16; + p[5] = (pp[1] - pp[6]) * cos3_16; + p[6] = (pp[2] - pp[5]) * cos5_16; + p[7] = (pp[3] - pp[4]) * cos7_16; + p[8] = pp[8] + pp[15]; + p[9] = pp[9] + pp[14]; + p[10] = pp[10] + pp[13]; + p[11] = pp[11] + pp[12]; + p[12] = (pp[8] - pp[15]) * cos1_16; + p[13] = (pp[9] - pp[14]) * cos3_16; + p[14] = (pp[10] - pp[13]) * cos5_16; + p[15] = (pp[11] - pp[12]) * cos7_16; + + pp[0] = p[0] + p[3]; + pp[1] = p[1] + p[2]; + pp[2] = (p[0] - p[3]) * cos1_8; + pp[3] = (p[1] - p[2]) * cos3_8; + pp[4] = p[4] + p[7]; + pp[5] = p[5] + p[6]; + pp[6] = (p[4] - p[7]) * cos1_8; + pp[7] = (p[5] - p[6]) * cos3_8; + pp[8] = p[8] + p[11]; + pp[9] = p[9] + p[10]; + pp[10] = (p[8] - p[11]) * cos1_8; + pp[11] = (p[9] - p[10]) * cos3_8; + pp[12] = p[12] + p[15]; + pp[13] = p[13] + p[14]; + pp[14] = (p[12] - p[15]) * cos1_8; + pp[15] = (p[13] - p[14]) * cos3_8; + + p[0] = pp[0] + pp[1]; + p[1] = (pp[0] - pp[1]) * cos1_4; + p[2] = pp[2] + pp[3]; + p[3] = (pp[2] - pp[3]) * cos1_4; + p[4] = pp[4] + pp[5]; + p[5] = (pp[4] - pp[5]) * cos1_4; + p[6] = pp[6] + pp[7]; + p[7] = (pp[6] - pp[7]) * cos1_4; + p[8] = pp[8] + pp[9]; + p[9] = (pp[8] - pp[9]) * cos1_4; + p[10] = pp[10] + pp[11]; + p[11] = (pp[10] - pp[11]) * cos1_4; + p[12] = pp[12] + pp[13]; + p[13] = (pp[12] - pp[13]) * cos1_4; + p[14] = pp[14] + pp[15]; + p[15] = (pp[14] - pp[15]) * cos1_4; + + // manually doing something that a compiler should handle sucks + // coding like this is hard to read + float tmp2; + new_v[5] = (new_v[11] = (new_v[13] = (new_v[15] = p[15]) + p[7]) + p[11]) + p[5] + p[13]; + new_v[7] = (new_v[9] = p[15] + p[11] + p[3]) + p[13]; + new_v[33 - 17] = -(new_v[1] = (tmp1 = p[13] + p[15] + p[9]) + p[1]) - p[14]; + new_v[35 - 17] = -(new_v[3] = tmp1 + p[5] + p[7]) - p[6] - p[14]; + + new_v[39 - 17] = (tmp1 = -p[10] - p[11] - p[14] - p[15]) - p[13] - p[2] - p[3]; + new_v[37 - 17] = tmp1 - p[13] - p[5] - p[6] - p[7]; + new_v[41 - 17] = tmp1 - p[12] - p[2] - p[3]; + new_v[43 - 17] = tmp1 - p[12] - (tmp2 = p[4] + p[6] + p[7]); + new_v[47 - 17] = (tmp1 = -p[8] - p[12] - p[14] - p[15]) - p[0]; + new_v[45 - 17] = tmp1 - tmp2; + + // insert V[0-15] (== new_v[0-15]) into actual v: + x1 = new_v; + // float[] x2 = actual_v + actual_write_pos; + float[] dest = actual_v; + + dest[0 + actual_write_pos] = x1[0]; + dest[16 + actual_write_pos] = x1[1]; + dest[32 + actual_write_pos] = x1[2]; + dest[48 + actual_write_pos] = x1[3]; + dest[64 + actual_write_pos] = x1[4]; + dest[80 + actual_write_pos] = x1[5]; + dest[96 + actual_write_pos] = x1[6]; + dest[112 + actual_write_pos] = x1[7]; + dest[128 + actual_write_pos] = x1[8]; + dest[144 + actual_write_pos] = x1[9]; + dest[160 + actual_write_pos] = x1[10]; + dest[176 + actual_write_pos] = x1[11]; + dest[192 + actual_write_pos] = x1[12]; + dest[208 + actual_write_pos] = x1[13]; + dest[224 + actual_write_pos] = x1[14]; + dest[240 + actual_write_pos] = x1[15]; + + // V[16] is always 0.0: + dest[256 + actual_write_pos] = 0.0f; + + // insert V[17-31] (== -new_v[15-1]) into actual v: + dest[272 + actual_write_pos] = -x1[15]; + dest[288 + actual_write_pos] = -x1[14]; + dest[304 + actual_write_pos] = -x1[13]; + dest[320 + actual_write_pos] = -x1[12]; + dest[336 + actual_write_pos] = -x1[11]; + dest[352 + actual_write_pos] = -x1[10]; + dest[368 + actual_write_pos] = -x1[9]; + dest[384 + actual_write_pos] = -x1[8]; + dest[400 + actual_write_pos] = -x1[7]; + dest[416 + actual_write_pos] = -x1[6]; + dest[432 + actual_write_pos] = -x1[5]; + dest[448 + actual_write_pos] = -x1[4]; + dest[464 + actual_write_pos] = -x1[3]; + dest[480 + actual_write_pos] = -x1[2]; + dest[496 + actual_write_pos] = -x1[1]; + + // insert V[32] (== -new_v[0]) into other v: + } /** * Compute PCM Samples. */ - @LOC("TMP") private float[] _tmpOut = new float[32]; - @LATTICE("IN,THIS samples; ) @@ -1078,86 +1297,51 @@ final class SynthesisFilter { // MDM: this may not be necessary. The Layer III decoder always // outputs 32 subband samples, but I haven't checked layer I & II. - for (@LOC("SH") int p = 0; p < 32; p++) + for (int p = 0; p < 32; p++) samples[p] = 0.0f; } - @LOC("EQ") private static final double MY_PI = 3.14159265358979323846; - @LOC("SA") private static final float cos1_64 = (float) (1.0 / (2.0 * Math.cos(MY_PI / 64.0))); - @LOC("SA") private static final float cos3_64 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 3.0 / 64.0))); - @LOC("SA") private static final float cos5_64 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 5.0 / 64.0))); - @LOC("SA") private static final float cos7_64 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 7.0 / 64.0))); - @LOC("SA") private static final float cos9_64 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 9.0 / 64.0))); - @LOC("SA") private static final float cos11_64 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 11.0 / 64.0))); - @LOC("SA") private static final float cos13_64 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 13.0 / 64.0))); - @LOC("SA") private static final float cos15_64 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 15.0 / 64.0))); - @LOC("SA") private static final float cos17_64 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 17.0 / 64.0))); - @LOC("SA") private static final float cos19_64 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 19.0 / 64.0))); - @LOC("SA") private static final float cos21_64 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 21.0 / 64.0))); - @LOC("SA") private static final float cos23_64 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 23.0 / 64.0))); - @LOC("SA") private static final float cos25_64 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 25.0 / 64.0))); - @LOC("SA") private static final float cos27_64 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 27.0 / 64.0))); - @LOC("SA") private static final float cos29_64 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 29.0 / 64.0))); - @LOC("SA") private static final float cos31_64 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 31.0 / 64.0))); - @LOC("SA") private static final float cos1_32 = (float) (1.0 / (2.0 * Math.cos(MY_PI / 32.0))); - @LOC("SA") private static final float cos3_32 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 3.0 / 32.0))); - @LOC("SA") private static final float cos5_32 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 5.0 / 32.0))); - @LOC("SA") private static final float cos7_32 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 7.0 / 32.0))); - @LOC("SA") private static final float cos9_32 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 9.0 / 32.0))); - @LOC("SA") private static final float cos11_32 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 11.0 / 32.0))); - @LOC("SA") private static final float cos13_32 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 13.0 / 32.0))); - @LOC("SA") private static final float cos15_32 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 15.0 / 32.0))); - @LOC("SA") private static final float cos1_16 = (float) (1.0 / (2.0 * Math.cos(MY_PI / 16.0))); - @LOC("SA") private static final float cos3_16 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 3.0 / 16.0))); - @LOC("SA") private static final float cos5_16 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 5.0 / 16.0))); - @LOC("SA") private static final float cos7_16 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 7.0 / 16.0))); - @LOC("SA") private static final float cos1_8 = (float) (1.0 / (2.0 * Math.cos(MY_PI / 8.0))); - @LOC("SA") private static final float cos3_8 = (float) (1.0 / (2.0 * Math.cos(MY_PI * 3.0 / 8.0))); - @LOC("SA") private static final float cos1_4 = (float) (1.0 / (2.0 * Math.cos(MY_PI / 4.0))); // Note: These values are not in the same order // as in Annex 3-B.3 of the ISO/IEC DIS 11172-3 // private float d[] = {0.000000000, -4.000442505}; - // @LOC("V2") private static float d[] = null; - /** * d[] split into subarrays of length 16. This provides for more faster access * by allowing a block of 16 to be addressed with constant offset. **/ - @LOC("V2") private static float d16[][] = null; /** diff --git a/Robust/src/Tests/ssJava/mp3decoder/makefile b/Robust/src/Tests/ssJava/mp3decoder/makefile index 7fb1e383..aea76aa8 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/makefile +++ b/Robust/src/Tests/ssJava/mp3decoder/makefile @@ -3,12 +3,12 @@ BUILDSCRIPT=../../../buildscript PROGRAM=MP3Player SOURCE_FILES=MP3Player.java -BSFLAGS= -32bit -ssjava -ssjavadebug -printlinenum -mainclass $(PROGRAM) -heapsize-mb 1000 -garbagestats -joptimize -noloop -optimize -debug +BSFLAGS= -32bit -ssjava -ssjavadebug -mainclass $(PROGRAM) -heapsize-mb 1000 -nooptimize -debug -garbagestats #-printlinenum #-joptimize default: $(PROGRAM)s.bin $(PROGRAM)s.bin: $(SOURCE_FILES) makefile - $(BUILDSCRIPT) $(BSFLAGS) -o $(PROGRAM)s -builddir sing $(SOURCE_FILES) + $(BUILDSCRIPT) $(BSFLAGS) -o $(PROGRAM) -builddir sing $(SOURCE_FILES) clean: rm -f $(PROGRAM).bin diff --git a/Robust/src/Tests/ssJava/mp3decoder/run b/Robust/src/Tests/ssJava/mp3decoder/run new file mode 100755 index 00000000..4642b81b --- /dev/null +++ b/Robust/src/Tests/ssJava/mp3decoder/run @@ -0,0 +1 @@ +./MP3Player.bin focus.mp3 \ No newline at end of file