From 139a7a223e7439a7aeb5bcc292e3904b274a766d Mon Sep 17 00:00:00 2001 From: david Date: Mon, 11 Jul 2011 22:57:35 +0000 Subject: [PATCH] annotated --- .../Tests/ssJava/mp3decoder/BitReserve.java | 49 +- Robust/src/Tests/ssJava/mp3decoder/Crc16.java | 13 +- .../src/Tests/ssJava/mp3decoder/Decoder.java | 18 +- .../Tests/ssJava/mp3decoder/Equalizer.java | 21 +- .../src/Tests/ssJava/mp3decoder/Header.java | 75 +- .../ssJava/mp3decoder/JavaLayerUtils.java | 5 +- .../ssJava/mp3decoder/LayerIDecoder.java | 156 ++- .../ssJava/mp3decoder/LayerIIDecoder.java | 233 +-- .../ssJava/mp3decoder/LayerIIIDecoder.java | 553 ++++---- .../src/Tests/ssJava/mp3decoder/Obuffer.java | 8 +- .../ssJava/mp3decoder/OutputChannels.java | 24 +- .../src/Tests/ssJava/mp3decoder/Player.java | 2 +- .../Tests/ssJava/mp3decoder/SampleBuffer.java | 12 +- .../ssJava/mp3decoder/SynthesisFilter.java | 1247 +++++++++-------- .../Tests/ssJava/mp3decoder/huffcodetab.java | 109 +- 15 files changed, 1383 insertions(+), 1142 deletions(-) diff --git a/Robust/src/Tests/ssJava/mp3decoder/BitReserve.java b/Robust/src/Tests/ssJava/mp3decoder/BitReserve.java index 24794c1a..bd57b6ea 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/BitReserve.java +++ b/Robust/src/Tests/ssJava/mp3decoder/BitReserve.java @@ -38,6 +38,8 @@ // REVIEW: there is no range checking, so buffer underflow or overflow // can silently occur. +@LATTICE("SH 0) @@ -133,11 +141,12 @@ final class BitReserve * Returns next bit from reserve. * @returns 0 if next bit is reset, or 1 if next bit is set. */ + @RETURNLOC("OUT") public int hget1bit() { - totbit++; - int val = buf[buf_byte_idx]; - buf_byte_idx = (buf_byte_idx+1) & BUFSIZE_MASK; + totbit++; + @LOC("OUT") int val = buf[buf_byte_idx]; + buf_byte_idx = (buf_byte_idx+1) & BUFSIZE_MASK; return val; } @@ -177,9 +186,10 @@ final class BitReserve /** * Write 8 bits into the bit stream. */ - public void hputbuf(int val) + @LATTICE("OUTEqualizer instance. @@ -178,10 +180,12 @@ public final class Equalizer * @return an array of factors that can be applied to the * subbands. */ + @RETURNLOC("OUT") float[] getBandFactors() { - float[] factors = new float[BANDS]; - for (int i=0, maxCount=BANDS; i private to public - public static final int bitrates[][][] = { + @LOC("T") 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, @@ -597,7 +604,7 @@ public final class Header } // E.B -> private to public - public static final String bitrate_str[][][] = { + @LOC("T") 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", diff --git a/Robust/src/Tests/ssJava/mp3decoder/JavaLayerUtils.java b/Robust/src/Tests/ssJava/mp3decoder/JavaLayerUtils.java index 2156e3db..9a32c5b8 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/JavaLayerUtils.java +++ b/Robust/src/Tests/ssJava/mp3decoder/JavaLayerUtils.java @@ -117,9 +117,10 @@ public class JavaLayerUtils 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"); @@ -133,7 +134,7 @@ public class JavaLayerUtils if (arrayLength!=length) throw new InvalidObjectException("array length mismatch"); } - + */ return obj; } diff --git a/Robust/src/Tests/ssJava/mp3decoder/LayerIDecoder.java b/Robust/src/Tests/ssJava/mp3decoder/LayerIDecoder.java index 97363a97..89eb5dec 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/LayerIDecoder.java +++ b/Robust/src/Tests/ssJava/mp3decoder/LayerIDecoder.java @@ -28,27 +28,30 @@ /** * Implements decoding of MPEG Audio Layer I frames. */ -class LayerIDecoder implements FrameDecoder +@LATTICE("L source.length - 3) temp = source.length - 3; - target[tmp] = source[temp]; + samples[tmp] = groupingtable[0][temp]; temp++;tmp++; - target[tmp] = source[temp]; + samples[tmp] = groupingtable[0][temp]; temp++;tmp++; - target[tmp] = source[temp]; + samples[tmp] = groupingtable[0][temp]; // memcpy (samples, groupingtable + samplecode, 3 * sizeof (real)); } @@ -718,11 +728,11 @@ class LayerIIDecoder extends LayerIDecoder implements FrameDecoder /** * */ - public boolean put_next_sample(int channels, SynthesisFilter filter1, SynthesisFilter filter2) + public boolean put_next_sample(@LOC("IN") int channels, @LOC("IN") SynthesisFilter filter1, @LOC("IN") SynthesisFilter filter2) { if ((allocation != 0) && (channels != OutputChannels.RIGHT_CHANNEL)) { - float sample = samples[samplenumber]; + @LOC("SH") float sample = samples[samplenumber]; if (groupingtable[0] == null) sample = (sample + d[0]) * c[0]; @@ -745,15 +755,19 @@ class LayerIIDecoder extends LayerIDecoder implements FrameDecoder /** * Class for layer II subbands in joint stereo mode. */ + @LATTICE("L 0) - xr_1d[quotien][reste] = g_gain * t_43[abv]; + xr[quotien][reste] = g_gain * t_43[abv]; else { if (-abv < t_43.length) - xr_1d[quotien][reste] = -g_gain * t_43[-abv]; + xr[quotien][reste] = -g_gain * t_43[-abv]; else - xr_1d[quotien][reste] = -g_gain * (float) Math.pow(-abv, d43); + xr[quotien][reste] = -g_gain * (float) Math.pow(-abv, d43); } } else { if (is_1d[j] > 0) - xr_1d[quotien][reste] = g_gain * (float) Math.pow(abv, d43); + xr[quotien][reste] = g_gain * (float) Math.pow(abv, d43); else - xr_1d[quotien][reste] = -g_gain * (float) Math.pow(-abv, d43); + xr[quotien][reste] = -g_gain * (float) Math.pow(-abv, d43); } } } @@ -947,8 +962,8 @@ final class LayerIIIDecoder implements FrameDecoder { // apply formula per block type for (j = 0; j < nonzero[ch]; j++) { // Modif E.B 02/22/99 - int reste = j % SSLIMIT; - int quotien = (int) ((j - reste) / SSLIMIT); + @LOC("REST") int reste = j % SSLIMIT; + @LOC("QUO") int quotien = (int) ((j - reste) / SSLIMIT); if (index == next_cb_boundary) { /* Adjust critical band boundary */ if ((gr_info.window_switching_flag != 0) && (gr_info.block_type == 2)) { @@ -1005,36 +1020,36 @@ final class LayerIIIDecoder implements FrameDecoder { * 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]))); */ - int idx = scalefac[ch].s[t_index][cb] << gr_info.scalefac_scale; + @LOC("IDX") int idx = scalefac[ch].s[t_index][cb] << gr_info.scalefac_scale; idx += (gr_info.subblock_gain[t_index] << 2); - xr_1d[quotien][reste] *= two_to_negative_half_pow[idx]; + xr[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])); */ - int idx = scalefac[ch].l[cb]; + @LOC("IDX") int idx = scalefac[ch].l[cb]; if (gr_info.preflag != 0) idx += pretab[cb]; idx = idx << gr_info.scalefac_scale; - xr_1d[quotien][reste] *= two_to_negative_half_pow[idx]; + xr[quotien][reste] *= two_to_negative_half_pow[idx]; } index++; } for (j = nonzero[ch]; j < 576; j++) { // Modif E.B 02/22/99 - int reste = j % SSLIMIT; - int quotien = (int) ((j - reste) / SSLIMIT); + @LOC("REST") int reste = j % SSLIMIT; + @LOC("QUO") int quotien = (int) ((j - reste) / SSLIMIT); if (reste < 0) reste = 0; if (quotien < 0) quotien = 0; - xr_1d[quotien][reste] = 0.0f; + xr[quotien][reste] = 0.0f; } return; @@ -1043,19 +1058,24 @@ final class LayerIIIDecoder implements FrameDecoder { /** * */ - private void reorder(float xr[][], int ch, int gr) { + @LATTICE("THIS= 3; sfb--) { i = sfBandIndex[sfreq].s[sfb]; @@ -1276,8 +1300,8 @@ final class LayerIIIDecoder implements FrameDecoder { } // for (; sfb<8 ... } // for (j=0 ... } else { // if (gr_info.mixed_block_flag) - for (int j = 0; j < 3; j++) { - int sfbcnt; + for (@LOC("THIS,LayerIIIDecoder.J") int j = 0; j < 3; j++) { + @LOC("THIS,LayerIIIDecoder.SH") int sfbcnt; sfbcnt = -1; for (sfb = 12; sfb >= 0; sfb--) { temp = sfBandIndex[sfreq].s[sfb]; @@ -1418,9 +1442,12 @@ final class LayerIIIDecoder implements FrameDecoder { /** * */ - private void antialias(int ch, int gr) { - int sb18, ss, sb18lim; - gr_info_s gr_info = (si.ch[ch].gr[gr]); + @LATTICE("THIS 32767.0f) ? 32767 : diff --git a/Robust/src/Tests/ssJava/mp3decoder/OutputChannels.java b/Robust/src/Tests/ssJava/mp3decoder/OutputChannels.java index 91458859..edf00278 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/OutputChannels.java +++ b/Robust/src/Tests/ssJava/mp3decoder/OutputChannels.java @@ -29,36 +29,38 @@ * @author Mat McGowan 12/12/99 * @since 0.0.7 */ +@LATTICE("BOutputChannels instance @@ -85,8 +87,8 @@ public class OutputChannels throw new IllegalArgumentException("Invalid channel code: "+code); } } - - private OutputChannels(int channels) + + private OutputChannels(@LOC("IN") int channels) { outputChannels = channels; diff --git a/Robust/src/Tests/ssJava/mp3decoder/Player.java b/Robust/src/Tests/ssJava/mp3decoder/Player.java index 406876e2..b4048110 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/Player.java +++ b/Robust/src/Tests/ssJava/mp3decoder/Player.java @@ -110,7 +110,7 @@ public class Player { boolean ret = true; - + SSJAVA: while (frames-- > 0 && ret) { ret = decodeFrame(); diff --git a/Robust/src/Tests/ssJava/mp3decoder/SampleBuffer.java b/Robust/src/Tests/ssJava/mp3decoder/SampleBuffer.java index a1e20aa1..913b8b02 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/SampleBuffer.java +++ b/Robust/src/Tests/ssJava/mp3decoder/SampleBuffer.java @@ -27,14 +27,15 @@ * The SampleBuffer class implements an output buffer * that provides storage for a fixed size block of samples. */ -@LATTICE("BUF>> 4; y[0] = h.val[point][1] & 0xf; error = 0; @@ -533,7 +542,7 @@ final class huffcodetab 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. @@ -560,7 +569,7 @@ final class huffcodetab if (ht!=null) return; - ht = new huffcodetab[HTN]; + 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); @@ -589,7 +598,7 @@ final class huffcodetab 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[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); -- 2.34.1