add a new test case for inference
[IRC.git] / Robust / src / Tests / ssJava / mp3decoder / LayerIIIDecoder.java
index cd0d38e6021b7af49bf8c92242afe1a7d8db3cbe..0beebb6e5700348bf15ccc0144c58b10c7cb43bf 100644 (file)
@@ -47,7 +47,7 @@
 // 10th added for get_scale_factors
 // llth added for decode
 // @LATTICE("IS1D*,RO<IS1D,IS1D<SI2,SI2<SI1,SI<P2S,SF1<CH0,SF0*,SFB_SH<NS,NS<SI,SFB_SH*,SFB<SFB_SH,C,C*,SI1<SF2,SF2<SFB,SF1<BR,LR*,OUT<LR,LR<RO,NZ*,SI<SF1,SI1<NZ,NZ<SI,SI1<SBI,SBI<SI,BUF<FT,SF1<SF0,SF0<HD1,BR<ST,ST,FT<SP,SP<OUT,OUT<SI1,SI1<SI,P2S<CH0,CH0<MAX0,MAX0<BR1,FS<BR1,BR1<BR,BR<HD1,HD1<HD,OUT*,BR1*,SI1*,MAX0*,CH0*,RAW,TS,F,C,K,LY,VAR,IR,IP,CSH,GLSFD3,GLSFD4,GLSFD5,GLSFF4,GLSFF2,GLSFF3,GLSFF1,GSF4,GSF5,GSF1,GSF2,GSF3,HD2,HD3,BT,GR,RO6,RO5,RO9,RO8,RO7,RO4,RO1,RO3,RO2,SH,ME,TMP2,S,LSF,J")
-@LATTICE("SI0*,INIT*,ISR*,ISP*,HD<CH0,LR<ISR,ISR<ISP,SI1<SF2,NS*,CH0<ST,ST<INIT,IS1D*,RO1<RO,RO1*,RO<IS1D,IS1D<SI2,SI2<SI1,BR<NS,NS<SI,SFB_SH*,SFB<SFB_SH,C,C*,SF2<SFB,LR*,OUT<LR,ISP<RO1,NZ*,SI<SI0,SI0<SF15,SF15<SF1,BR1<NZ,NZ<BR,SI1<RT,RT<SBI,SBI<SI,BUF<FT,SF1<HD1,SF1<HD1,FT<SP,SP<OUT,OUT<SI1,SI1<SI,SFB_SH<BR1,BR1<BR,HD1<HD,OUT*,BR1*,SI1*,CH0*")
+@LATTICE("SI0*,INIT*,ISR*,ISP*,HD<CH0,LR<ISR,ISR<ISP,SI1<SF2,NS*,CH0<ST,ST<INIT,IS1D*,RO1<RO,RO1*,RO<IS1D,IS1D<SI2,SI2<SI1,BR<NS,NS<SI,SFB_SH*,SFB<SFB_SH,C,C*,SF2<SFB,LR*,TSOUT*,OUT1<PREV,PREV<RAWFULL,RAWFULL<RAWOUT,RAWOUT<TSOUT,TSOUT<OUT0,OUT0<LR,ISP<RO1,NZ*,SI<SI0,SI0<SF15,SF15<SF1,BR1<NZ,NZ<BR,SI1<RT,RT<SBI,SBI<SI,BUF<FT,SF1<HD1,SF1<HD1,FT<SP,SP<OUT1,SI1<SI,SFB_SH<BR1,BR1<BR,HD1<HD,OUT0*,OUT1*,BR1*,SI1*,CH0*")
 @METHODDEFAULT("OUT<V,V<THIS,THIS<SH,SH<IN,SH*,THISLOC=THIS,GLOBALLOC=IN,RETURNLOC=OUT")
 final class LayerIIIDecoder implements FrameDecoder {
   static final double d43 = (4.0 / 3.0);
@@ -64,10 +64,13 @@ final class LayerIIIDecoder implements FrameDecoder {
   private float[][][] ro;
   @LOC("LR")
   private float[][][] lr;
-  @LOC("OUT")
+  @LOC("OUT0")
+  private float[] inter; // 576 samples
+  @LOC("OUT1")
   private float[] out_1d; // 576 samples
-  @LOC("OUT")
+  @LOC("PREV")
   private float[][] prevblck;
+
   @LOC("LR")
   private float[][] k;
   @LOC("NZ")
@@ -87,7 +90,7 @@ final class LayerIIIDecoder implements FrameDecoder {
 
   // @LOC("SBT") private temporaire2[] III_scalefac_t;
   @LOC("SF2")
-  private temporaire2[] scalefac;
+  private final temporaire2[] scalefac;
   // private III_scalefac_t scalefac;
 
   @LOC("CH0")
@@ -96,7 +99,7 @@ final class LayerIIIDecoder implements FrameDecoder {
   private int frame_start;
   // @LOC("SI1") private int part2_start;
   @LOC("CH0")
-  private int channels;
+  private final int channels;
   @LOC("CH0")
   private int first_channel;
   @LOC("CH0")
@@ -110,10 +113,16 @@ final class LayerIIIDecoder implements FrameDecoder {
   @LOC("INIT")
   private boolean initialized = false;
 
+  @LOC("RAWFULL")
+  float[][] raw_full; // 18 left shfited since it will be copied into prevblck!
+
   // constructor for the linear type system
-  public LayerIIIDecoder(@DELEGATE @LOC("VAR") SynthesisFilter filtera,
+  public LayerIIIDecoder(Header h, @DELEGATE @LOC("VAR") SynthesisFilter filtera,
       @DELEGATE @LOC("VAR") SynthesisFilter filterb, @LOC("VAR") int which_ch0) {
 
+    filter_pos = 11;
+    raw_full = new float[2][SBLIMIT * SSLIMIT];
+
     filter1 = filtera;
     filter2 = filterb;
 
@@ -122,6 +131,7 @@ final class LayerIIIDecoder implements FrameDecoder {
     ro = new float[2][SBLIMIT][SSLIMIT];
     lr = new float[2][SBLIMIT][SSLIMIT];
     out_1d = new float[SBLIMIT * SSLIMIT];
+    inter = new float[SBLIMIT * SSLIMIT];
     prevblck = new float[2][SBLIMIT * SSLIMIT];
     k = new float[2][SBLIMIT * SSLIMIT];
     nonzero = new int[2];
@@ -202,6 +212,7 @@ final class LayerIIIDecoder implements FrameDecoder {
     scalefac_buffer = new int[54];
     // END OF scalefac_buffer
 
+    init(h);
   }
 
   @LATTICE("THIS<C,THIS<IN,C*,THISLOC=THIS")
@@ -243,7 +254,6 @@ final class LayerIIIDecoder implements FrameDecoder {
 
     nonzero[0] = nonzero[1] = 576;
 
-    br = new BitReserve();
     si = new III_side_info_t();
 
     initialized = true;
@@ -442,6 +452,8 @@ final class LayerIIIDecoder implements FrameDecoder {
   private float[] samples1 = new float[32];
   @LOC("SP")
   private float[] samples2 = new float[32];
+  @LOC("SI1")
+  private int filter_pos;
 
   /*
    * location hierarchy of decode() {header} {stream} {si} {br, flush_main,
@@ -454,9 +466,31 @@ final class LayerIIIDecoder implements FrameDecoder {
   @LATTICE("HEADER<VAR,VAR<THIS,C<THIS,THIS<IN,THISLOC=THIS,C*,VAR*")
   public void decode(@LOC("THIS,LayerIIIDecoder.HD") Header header) {
 
-    if (!initialized) {
-      init(header);
-    }
+    // if (!initialized) {
+    // init(header);
+    // }
+
+    // overwrites once per a loop
+    SSJAVA.arrayinit(samples1, 0);
+    SSJAVA.arrayinit(samples2, 0);
+    SSJAVA.arrayinit(ro, 2, SBLIMIT, SSLIMIT, 0);
+    SSJAVA.arrayinit(lr, 2, SBLIMIT, SSLIMIT, 0);
+    SSJAVA.arrayinit(is_pos, 7);
+    SSJAVA.arrayinit(is_ratio, 0);
+    SSJAVA.arrayinit(out_1d, 0);
+    SSJAVA.arrayinit(inter, 0);
+    SSJAVA.arrayinit(k, 2, SBLIMIT * SSLIMIT, 0);
+    SSJAVA.arrayinit(is_1d, 0);
+    SSJAVA.arrayinit(tsOutCopy, 0);
+    SSJAVA.arrayinit(scalefac_buffer, 0);
+    SSJAVA.arrayinit(nonzero, 576);
+    SSJAVA.arrayinit(new_slen, 0);
+    SSJAVA.arrayinit(rawout,0);
+    
+    CheckSumHuff = 0;
+    // prevblck = new float[2][SBLIMIT * SSLIMIT];
+    si = new III_side_info_t();
+    //
 
     @LOC("THIS,LayerIIIDecoder.HD1") int nSlots = header.slots();
 
@@ -479,6 +513,17 @@ final class LayerIIIDecoder implements FrameDecoder {
 
     @LOC("THIS,LayerIIIDecoder.HD1") int version = header.version();
 
+    // additional codes for the definitely written property
+    filter_pos = (filter_pos + 4) & 0xf;
+    filter1.vidx = 1;
+    filter2.vidx = 1;
+    filter1.actual_write_pos = filter_pos;
+    filter2.actual_write_pos = filter_pos;
+    //
+
+    // System.out.println("filter1="+filter1.vidx+" "+filter1.actual_write_pos);
+    // System.out.println("filter1="+filter2.vidx+" "+filter2.actual_write_pos);
+
     // here 'gr' and 'max_gr' should be higher than 'ch','channels', and more
     for (gr = 0; gr < max_gr; gr++) { // two granules per channel
       // in the loop body, access set={part2_start}
@@ -516,10 +561,6 @@ final class LayerIIIDecoder implements FrameDecoder {
                                                            // 'first_channel' >
                                                            // the body
 
-        // in the body
-        // read set= lr,ch,gr,out_1d, sb18, ss, SSLIMIT, out_1d
-        // write set= out_1d
-
         reorder(/* lr[ch], */ch, gr);
         antialias(ch, gr);
 
@@ -529,6 +570,10 @@ final class LayerIIIDecoder implements FrameDecoder {
         // }
         // System.out.println("CheckSumOut1d = "+CheckSumOut1d);
 
+        for (@LOC("THIS,LayerIIIDecoder.SI1") int index = 0; index < 576; index++) {
+          out_1d[index] = inter[index];
+        }
+
         hybrid(ch, gr);
 
         // float CheckSumOut1d=0;
@@ -558,6 +603,8 @@ final class LayerIIIDecoder implements FrameDecoder {
               sb++; // sb should be loc*
             }
             filter1.input_samples(samples1);
+            // System.out.println("filter1 writepos=" + filter1.actual_write_pos
+            // + " vidx=" + filter1.vidx);
             filter1.calculate_pcm_samples();
           }
         } else {
@@ -571,11 +618,31 @@ final class LayerIIIDecoder implements FrameDecoder {
             filter2.input_samples(samples2);
             filter2.calculate_pcm_samples();
           }
-
         }
+        // System.out.println("#END CH=" + ch + " actual_write_pos=" +
+        // filter1.actual_write_pos);
       } // channels
+
+      // TODO
+      // init prev
+      SSJAVA.arrayinit(prevblck, 2, SBLIMIT * SSLIMIT, 0);
+      // copy from raw_full to prev
+      SSJAVA.arraycopy(prevblck, raw_full, 2, SBLIMIT * SSLIMIT);
+      // for (int chidx = 0; chidx < 2; chidx++) {
+      // for (int sidx = 0; sidx < SBLIMIT * SSLIMIT; sidx++) {
+      // prevblck[chidx][sidx] = raw_full[chidx][sidx];
+      // }
+      // }
+      // System.out.println("#END GR=" + gr + " actual_write_pos=" +
+      // filter1.actual_write_pos);
     } // granule
 
+    // System.out.println("#END FRAME actual_write_pos=" +
+    // filter1.actual_write_pos);
+
+    filter1.clear();
+    filter2.clear();
+
     // System.out.println("Counter = ................................."+counter);
     // if (counter < 609)
     // {
@@ -852,7 +919,7 @@ final class LayerIIIDecoder implements FrameDecoder {
   // MDM: new_slen is fully initialized before use, no need
   // to reallocate array.
   @LOC("NS")
-  private final int[] new_slen = new int[4];
+  private int[] new_slen = new int[4];
 
   // ssjava
   @LATTICE("M<THIS,THIS<IN,THIS<C,C*,M*,THISLOC=THIS,GLOBALLOC=THIS")
@@ -942,13 +1009,14 @@ final class LayerIIIDecoder implements FrameDecoder {
       }
     }
 
-    for (@LOC("THIS,LayerIIIDecoder.NS") int x = 0; x < 45; x++)
-      // why 45, not 54?
-      scalefac_buffer[x] = 0;
+    // 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++) {
-      for (@LOC("THIS,LayerIIIDecoder.NS") int j = 0; j < nr_of_sfb_block[blocknumber][blocktypenumber][i]; j++) {
+      @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++;
 
@@ -1071,7 +1139,7 @@ final class LayerIIIDecoder implements FrameDecoder {
 
     index = 0;
     // Read bigvalues area
-    for (@LOC("THIS,LayerIIIDecoder.BR,BitReserve.BIT") int i = 0; i < (si.ch[ch].gr[gr].big_values << 1); i +=
+    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;
@@ -1103,7 +1171,7 @@ final class LayerIIIDecoder implements FrameDecoder {
     // h = huffcodetab.ht[si.ch[ch].gr[gr].count1table_select + 32];
     num_bits = br.hsstell();
 
-    while ((num_bits < part2_3_end) && (index < 576)) {
+    TERMINATE: while ((num_bits < part2_3_end) && (index < 576)) {
 
       huffcodetab.huffman_decoder(htIdx, x, y, v, w, br);
 
@@ -1365,9 +1433,9 @@ final class LayerIIIDecoder implements FrameDecoder {
 
     if ((si.ch[ch].gr[gr].window_switching_flag != 0) && (si.ch[ch].gr[gr].block_type == 2)) {
 
-      for (index = 0; index < 576; index++) {
-        out_1d[index] = 0.0f;
-      }
+      // for (index = 0; index < 576; index++) {
+      // inter[index] = 0.0f;
+      // }
 
       if (si.ch[ch].gr[gr].mixed_block_flag != 0) {
         // NO REORDER FOR LOW 2 SUBBANDS
@@ -1375,7 +1443,7 @@ final class LayerIIIDecoder implements FrameDecoder {
           // Modif E.B 02/22/99
           @LOC("THIS,LayerIIIDecoder.SI1") int reste = index % SSLIMIT;
           @LOC("THIS,LayerIIIDecoder.SI1") int quotien = (int) ((index - reste) / SSLIMIT);
-          out_1d[index] = lr[ch][quotien][reste];
+          inter[index] = lr[ch][quotien][reste];
         }
         // REORDERING FOR REST SWITCHED SHORT
         /*
@@ -1399,21 +1467,21 @@ final class LayerIIIDecoder implements FrameDecoder {
             @LOC("THIS,LayerIIIDecoder.SI1") int reste = src_line % SSLIMIT;
             @LOC("THIS,LayerIIIDecoder.SI1") int quotien = (int) ((src_line - reste) / SSLIMIT);
 
-            out_1d[des_line] = lr[ch][quotien][reste];
+            inter[des_line] = lr[ch][quotien][reste];
             src_line += sfb_lines;
             des_line++;
 
             reste = src_line % SSLIMIT;
             quotien = (int) ((src_line - reste) / SSLIMIT);
 
-            out_1d[des_line] = lr[ch][quotien][reste];
+            inter[des_line] = lr[ch][quotien][reste];
             src_line += sfb_lines;
             des_line++;
 
             reste = src_line % SSLIMIT;
             quotien = (int) ((src_line - reste) / SSLIMIT);
 
-            out_1d[des_line] = lr[ch][quotien][reste];
+            inter[des_line] = lr[ch][quotien][reste];
           }
         }
 
@@ -1422,7 +1490,7 @@ final class LayerIIIDecoder implements FrameDecoder {
           @LOC("THIS,LayerIIIDecoder.SI1") int j = reorder_table[sfreq][index];
           @LOC("THIS,LayerIIIDecoder.SI1") int reste = j % SSLIMIT;
           @LOC("THIS,LayerIIIDecoder.SI1") int quotien = (int) ((j - reste) / SSLIMIT);
-          out_1d[index] = lr[ch][quotien][reste];
+          inter[index] = lr[ch][quotien][reste];
         }
       }
     } else { // long blocks
@@ -1430,7 +1498,7 @@ final class LayerIIIDecoder implements FrameDecoder {
         // Modif E.B 02/22/99
         @LOC("THIS,LayerIIIDecoder.SI1") int reste = index % SSLIMIT;
         @LOC("THIS,LayerIIIDecoder.SI1") int quotien = (int) ((index - reste) / SSLIMIT);
-        out_1d[index] = lr[ch][quotien][reste];
+        inter[index] = lr[ch][quotien][reste];
       }
     }
   }
@@ -1481,12 +1549,10 @@ final class LayerIIIDecoder implements FrameDecoder {
       @LOC("THIS,LayerIIIDecoder.LR") int io_type = (si.ch[0].gr[gr].scalefac_compress & 1);
 
       // initialization
-
-      for (i = 0; i < 576; i++) {
-        is_pos[i] = 7;
-
-        is_ratio[i] = 0.0f;
-      }
+      // for (i = 0; i < 576; i++) {
+      // is_pos[i] = 7;
+      // is_ratio[i] = 0.0f;
+      // }
 
       if (i_stereo) {
         if ((si.ch[0].gr[gr].window_switching_flag != 0) && (si.ch[0].gr[gr].block_type == 2)) {
@@ -1497,12 +1563,11 @@ final class LayerIIIDecoder implements FrameDecoder {
             for (@LOC("THIS,LayerIIIDecoder.RO1") int j = 0; j < 3; j++) {
               @LOC("THIS,LayerIIIDecoder.RO1") int sfbcnt;
               sfbcnt = 2;
-              for (sfb = 12; sfb >= 3; sfb--) {
+              TERMINATE: for (sfb = 12; sfb >= 3; sfb--) {
                 i = sfBandIndex[sfreq].s[sfb];
                 lines = sfBandIndex[sfreq].s[sfb + 1] - i;
                 i = (i << 2) - i + (j + 1) * lines - 1;
-
-                while (lines > 0) {
+                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.
@@ -1528,7 +1593,7 @@ final class LayerIIIDecoder implements FrameDecoder {
                 sb = sfBandIndex[sfreq].s[sfb + 1] - temp;
                 i = (temp << 2) - temp + j * sb;
 
-                for (; sb > 0; sb--) {
+                TERMINATE: for (; sb > 0; sb--) {
                   is_pos[i] = scalefac[1].s[j][sfb];
                   if (is_pos[i] != 7)
                     if (lsf)
@@ -1546,8 +1611,7 @@ final class LayerIIIDecoder implements FrameDecoder {
               temp = sfBandIndex[sfreq].s[11];
               sb = sfBandIndex[sfreq].s[12] - temp;
               i = (temp << 2) - temp + j * sb;
-
-              for (; sb > 0; sb--) {
+              TERMINATE: for (; sb > 0; sb--) {
                 is_pos[i] = is_pos[sfb];
 
                 if (lsf) {
@@ -1563,7 +1627,7 @@ final class LayerIIIDecoder implements FrameDecoder {
               i = 2;
               ss = 17;
               sb = -1;
-              while (i >= 0) {
+              TERMINATE: while (i >= 0) {
                 if (ro[1][i][ss] != 0.0f) {
                   sb = (i << 4) + (i << 1) + ss;
                   i = -1;
@@ -1582,7 +1646,7 @@ final class LayerIIIDecoder implements FrameDecoder {
               i = sfBandIndex[sfreq].l[i];
               for (; sfb < 8; sfb++) {
                 sb = sfBandIndex[sfreq].l[sfb + 1] - sfBandIndex[sfreq].l[sfb];
-                for (; sb > 0; sb--) {
+                TERMINATE: for (; sb > 0; sb--) {
                   is_pos[i] = scalefac[1].l[sfb];
                   if (is_pos[i] != 7)
                     if (lsf)
@@ -1597,12 +1661,11 @@ final class LayerIIIDecoder implements FrameDecoder {
             for (@LOC("THIS,LayerIIIDecoder.RO1") int j = 0; j < 3; j++) {
               @LOC("THIS,LayerIIIDecoder.RO1") int sfbcnt;
               sfbcnt = -1;
-              for (sfb = 12; sfb >= 0; sfb--) {
+              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;
-
-                while (lines > 0) {
+                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.
@@ -1621,7 +1684,7 @@ final class LayerIIIDecoder implements FrameDecoder {
                 temp = sfBandIndex[sfreq].s[sfb];
                 sb = sfBandIndex[sfreq].s[sfb + 1] - temp;
                 i = (temp << 2) - temp + j * sb;
-                for (; sb > 0; sb--) {
+                TERMINATE: for (; sb > 0; sb--) {
                   is_pos[i] = scalefac[1].s[j][sfb];
                   if (is_pos[i] != 7)
                     if (lsf)
@@ -1639,8 +1702,7 @@ final class LayerIIIDecoder implements FrameDecoder {
               sfb = (temp << 2) - temp + j * sb;
               sb = sfBandIndex[sfreq].s[12] - temp2;
               i = (temp2 << 2) - temp2 + j * sb;
-
-              for (; sb > 0; sb--) {
+              TERMINATE: for (; sb > 0; sb--) {
                 is_pos[i] = is_pos[sfb];
 
                 if (lsf) {
@@ -1657,7 +1719,7 @@ final class LayerIIIDecoder implements FrameDecoder {
           i = 31;
           ss = 17;
           sb = 0;
-          while (i >= 0) {
+          TERMINATE: while (i >= 0) {
             if (ro[1][i][ss] != 0.0f) {
               sb = (i << 4) + (i << 1) + ss;
               i = -1;
@@ -1677,7 +1739,7 @@ final class LayerIIIDecoder implements FrameDecoder {
           i = sfBandIndex[sfreq].l[i];
           for (; sfb < 21; sfb++) {
             sb = sfBandIndex[sfreq].l[sfb + 1] - sfBandIndex[sfreq].l[sfb];
-            for (; sb > 0; sb--) {
+            TERMINATE: for (; sb > 0; sb--) {
               is_pos[i] = scalefac[1].l[sfb];
               if (is_pos[i] != 7)
                 if (lsf)
@@ -1688,7 +1750,7 @@ final class LayerIIIDecoder implements FrameDecoder {
             }
           }
           sfb = sfBandIndex[sfreq].l[20];
-          for (sb = 576 - sfBandIndex[sfreq].l[21]; (sb > 0) && (i < 576); sb--) {
+          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) {
@@ -1766,10 +1828,10 @@ final class LayerIIIDecoder implements FrameDecoder {
       for (ss = 0; ss < 8; ss++) {
         @LOC("THIS,LayerIIIDecoder.SI1") int src_idx1 = sb18 + 17 - ss;
         @LOC("THIS,LayerIIIDecoder.SI1") int src_idx2 = sb18 + 18 + ss;
-        @LOC("THIS,LayerIIIDecoder.OUT") float bu = out_1d[src_idx1];
-        @LOC("THIS,LayerIIIDecoder.OUT") float bd = out_1d[src_idx2];
-        out_1d[src_idx1] = (bu * cs[ss]) - (bd * ca[ss]);
-        out_1d[src_idx2] = (bd * cs[ss]) + (bu * ca[ss]);
+        @LOC("THIS,LayerIIIDecoder.OUT0") float bu = inter[src_idx1];
+        @LOC("THIS,LayerIIIDecoder.OUT0") float bd = inter[src_idx2];
+        inter[src_idx1] = (bu * cs[ss]) - (bd * ca[ss]);
+        inter[src_idx2] = (bd * cs[ss]) + (bu * ca[ss]);
       }
     }
   }
@@ -1780,9 +1842,9 @@ final class LayerIIIDecoder implements FrameDecoder {
 
   // MDM: tsOutCopy and rawout do not need initializing, so the arrays
   // can be reused.
-  @LOC("OUT")
+  @LOC("TSOUT")
   float[] tsOutCopy = new float[18];
-  @LOC("OUT")
+  @LOC("RAWOUT")
   float[] rawout = new float[36];
 
   @LATTICE("THIS<SB,SB*,THISLOC=THIS")
@@ -1805,54 +1867,95 @@ final class LayerIIIDecoder implements FrameDecoder {
 
       // tsOut = out_1d;
       // Modif E.B 02/22/99
-      for (@LOC("THIS,LayerIIIDecoder.SI1") int cc = 0; cc < 18; cc++)
-        tsOutCopy[cc] = out_1d[cc + sb18];
+      for (@LOC("THIS,LayerIIIDecoder.SI1") int cc = 0; cc < 18; cc++) {
+        // tsOutCopy[cc] = out_1d[cc + sb18];
+        tsOutCopy[cc] = inter[cc + sb18];
+      }
 
       inv_mdct(bt);
 
-      for (@LOC("THIS,LayerIIIDecoder.SI1") int cc = 0; cc < 18; cc++)
+      for (@LOC("THIS,LayerIIIDecoder.SI1") int cc = 0; cc < 18; cc++) {
         out_1d[cc + sb18] = tsOutCopy[cc];
+      }
+
       // Fin Modif
 
       // overlap addition
-      // prvblk = prevblck; //eliminated unnecessary areas
-
       out_1d[0 + sb18] = rawout[0] + prevblck[ch][sb18 + 0];
-      prevblck[ch][sb18 + 0] = rawout[18];
       out_1d[1 + sb18] = rawout[1] + prevblck[ch][sb18 + 1];
-      prevblck[ch][sb18 + 1] = rawout[19];
       out_1d[2 + sb18] = rawout[2] + prevblck[ch][sb18 + 2];
-      prevblck[ch][sb18 + 2] = rawout[20];
       out_1d[3 + sb18] = rawout[3] + prevblck[ch][sb18 + 3];
-      prevblck[ch][sb18 + 3] = rawout[21];
       out_1d[4 + sb18] = rawout[4] + prevblck[ch][sb18 + 4];
-      prevblck[ch][sb18 + 4] = rawout[22];
       out_1d[5 + sb18] = rawout[5] + prevblck[ch][sb18 + 5];
-      prevblck[ch][sb18 + 5] = rawout[23];
       out_1d[6 + sb18] = rawout[6] + prevblck[ch][sb18 + 6];
-      prevblck[ch][sb18 + 6] = rawout[24];
       out_1d[7 + sb18] = rawout[7] + prevblck[ch][sb18 + 7];
-      prevblck[ch][sb18 + 7] = rawout[25];
       out_1d[8 + sb18] = rawout[8] + prevblck[ch][sb18 + 8];
-      prevblck[ch][sb18 + 8] = rawout[26];
       out_1d[9 + sb18] = rawout[9] + prevblck[ch][sb18 + 9];
-      prevblck[ch][sb18 + 9] = rawout[27];
       out_1d[10 + sb18] = rawout[10] + prevblck[ch][sb18 + 10];
-      prevblck[ch][sb18 + 10] = rawout[28];
       out_1d[11 + sb18] = rawout[11] + prevblck[ch][sb18 + 11];
-      prevblck[ch][sb18 + 11] = rawout[29];
       out_1d[12 + sb18] = rawout[12] + prevblck[ch][sb18 + 12];
-      prevblck[ch][sb18 + 12] = rawout[30];
       out_1d[13 + sb18] = rawout[13] + prevblck[ch][sb18 + 13];
-      prevblck[ch][sb18 + 13] = rawout[31];
       out_1d[14 + sb18] = rawout[14] + prevblck[ch][sb18 + 14];
-      prevblck[ch][sb18 + 14] = rawout[32];
       out_1d[15 + sb18] = rawout[15] + prevblck[ch][sb18 + 15];
-      prevblck[ch][sb18 + 15] = rawout[33];
       out_1d[16 + sb18] = rawout[16] + prevblck[ch][sb18 + 16];
-      prevblck[ch][sb18 + 16] = rawout[34];
       out_1d[17 + sb18] = rawout[17] + prevblck[ch][sb18 + 17];
-      prevblck[ch][sb18 + 17] = rawout[35];
+      raw_full[ch][sb18 + 0] = rawout[18];
+      raw_full[ch][sb18 + 1] = rawout[19];
+      raw_full[ch][sb18 + 2] = rawout[20];
+      raw_full[ch][sb18 + 3] = rawout[21];
+      raw_full[ch][sb18 + 4] = rawout[22];
+      raw_full[ch][sb18 + 5] = rawout[23];
+      raw_full[ch][sb18 + 6] = rawout[24];
+      raw_full[ch][sb18 + 7] = rawout[25];
+      raw_full[ch][sb18 + 8] = rawout[26];
+      raw_full[ch][sb18 + 9] = rawout[27];
+      raw_full[ch][sb18 + 10] = rawout[28];
+      raw_full[ch][sb18 + 11] = rawout[29];
+      raw_full[ch][sb18 + 12] = rawout[30];
+      raw_full[ch][sb18 + 13] = rawout[31];
+      raw_full[ch][sb18 + 14] = rawout[32];
+      raw_full[ch][sb18 + 15] = rawout[33];
+      raw_full[ch][sb18 + 16] = rawout[34];
+      raw_full[ch][sb18 + 17] = rawout[35];
+
+      // original implementation:
+      // out_1d[0 + sb18] = rawout[0] + prevblck[ch][sb18 + 0];
+      // prevblck[ch][sb18 + 0] = rawout[18];
+      // out_1d[1 + sb18] = rawout[1] + prevblck[ch][sb18 + 1];
+      // prevblck[ch][sb18 + 1] = rawout[19];
+      // out_1d[2 + sb18] = rawout[2] + prevblck[ch][sb18 + 2];
+      // prevblck[ch][sb18 + 2] = rawout[20];
+      // out_1d[3 + sb18] = rawout[3] + prevblck[ch][sb18 + 3];
+      // prevblck[ch][sb18 + 3] = rawout[21];
+      // out_1d[4 + sb18] = rawout[4] + prevblck[ch][sb18 + 4];
+      // prevblck[ch][sb18 + 4] = rawout[22];
+      // out_1d[5 + sb18] = rawout[5] + prevblck[ch][sb18 + 5];
+      // prevblck[ch][sb18 + 5] = rawout[23];
+      // out_1d[6 + sb18] = rawout[6] + prevblck[ch][sb18 + 6];
+      // prevblck[ch][sb18 + 6] = rawout[24];
+      // out_1d[7 + sb18] = rawout[7] + prevblck[ch][sb18 + 7];
+      // prevblck[ch][sb18 + 7] = rawout[25];
+      // out_1d[8 + sb18] = rawout[8] + prevblck[ch][sb18 + 8];
+      // prevblck[ch][sb18 + 8] = rawout[26];
+      // out_1d[9 + sb18] = rawout[9] + prevblck[ch][sb18 + 9];
+      // prevblck[ch][sb18 + 9] = rawout[27];
+      // out_1d[10 + sb18] = rawout[10] + prevblck[ch][sb18 + 10];
+      // prevblck[ch][sb18 + 10] = rawout[28];
+      // out_1d[11 + sb18] = rawout[11] + prevblck[ch][sb18 + 11];
+      // prevblck[ch][sb18 + 11] = rawout[29];
+      // out_1d[12 + sb18] = rawout[12] + prevblck[ch][sb18 + 12];
+      // prevblck[ch][sb18 + 12] = rawout[30];
+      // out_1d[13 + sb18] = rawout[13] + prevblck[ch][sb18 + 13];
+      // prevblck[ch][sb18 + 13] = rawout[31];
+      // out_1d[14 + sb18] = rawout[14] + prevblck[ch][sb18 + 14];
+      // prevblck[ch][sb18 + 14] = rawout[32];
+      // out_1d[15 + sb18] = rawout[15] + prevblck[ch][sb18 + 15];
+      // prevblck[ch][sb18 + 15] = rawout[33];
+      // out_1d[16 + sb18] = rawout[16] + prevblck[ch][sb18 + 16];
+      // prevblck[ch][sb18 + 16] = rawout[34];
+      // out_1d[17 + sb18] = rawout[17] + prevblck[ch][sb18 + 17];
+      // prevblck[ch][sb18 + 17] = rawout[35];
+
     }
   }
 
@@ -1877,28 +1980,28 @@ final class LayerIIIDecoder implements FrameDecoder {
   // @LOC("IN") int block_type) {//remove alias
   // ssjava
   @LATTICE("THIS,THISLOC=THIS")
-  public void inv_mdct(@LOC("THIS,LayerIIIDecoder.OUT") int block_type) {
+  public void inv_mdct(@LOC("THIS,LayerIIIDecoder.TSOUT") int block_type) {
     // float[] win_bt;
-    @LOC("THIS,LayerIIIDecoder.OUT") int i;
-
-    @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_0;
-    @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_1;
-    @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_2;
-    @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_3;
-    @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_4;
-    @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_5;
-    @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_6;
-    @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_7;
-    @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_8;
-    @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_9;
-    @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_10;
-    @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_11;
-    @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_12;
-    @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_13;
-    @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_14;
-    @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_15;
-    @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_16;
-    @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_17;
+    @LOC("THIS,LayerIIIDecoder.TSOUT") int i;
+
+    @LOC("THIS,LayerIIIDecoder.TSOUT") float tmpf_0;
+    @LOC("THIS,LayerIIIDecoder.TSOUT") float tmpf_1;
+    @LOC("THIS,LayerIIIDecoder.TSOUT") float tmpf_2;
+    @LOC("THIS,LayerIIIDecoder.TSOUT") float tmpf_3;
+    @LOC("THIS,LayerIIIDecoder.TSOUT") float tmpf_4;
+    @LOC("THIS,LayerIIIDecoder.TSOUT") float tmpf_5;
+    @LOC("THIS,LayerIIIDecoder.TSOUT") float tmpf_6;
+    @LOC("THIS,LayerIIIDecoder.TSOUT") float tmpf_7;
+    @LOC("THIS,LayerIIIDecoder.TSOUT") float tmpf_8;
+    @LOC("THIS,LayerIIIDecoder.TSOUT") float tmpf_9;
+    @LOC("THIS,LayerIIIDecoder.TSOUT") float tmpf_10;
+    @LOC("THIS,LayerIIIDecoder.TSOUT") float tmpf_11;
+    @LOC("THIS,LayerIIIDecoder.TSOUT") float tmpf_12;
+    @LOC("THIS,LayerIIIDecoder.TSOUT") float tmpf_13;
+    @LOC("THIS,LayerIIIDecoder.TSOUT") float tmpf_14;
+    @LOC("THIS,LayerIIIDecoder.TSOUT") float tmpf_15;
+    @LOC("THIS,LayerIIIDecoder.TSOUT") float tmpf_16;
+    @LOC("THIS,LayerIIIDecoder.TSOUT") float tmpf_17;
 
     tmpf_0 =
         tmpf_1 =
@@ -1963,7 +2066,7 @@ final class LayerIIIDecoder implements FrameDecoder {
       rawout[34] = 0.0f;
       rawout[35] = 0.0f;
 
-      @LOC("THIS,LayerIIIDecoder.OUT") int six_i = 0;
+      @LOC("THIS,LayerIIIDecoder.TSOUT") int six_i = 0;
 
       for (i = 0; i < 3; i++) {
         // 12 point IMDCT
@@ -1980,9 +2083,9 @@ final class LayerIIIDecoder implements FrameDecoder {
         tsOutCopy[9 + i] += tsOutCopy[3 + i];
 
         // 3 point IDCT on even indices
-        @LOC("THIS,LayerIIIDecoder.OUT") float pp1;
-        @LOC("THIS,LayerIIIDecoder.OUT") float pp2;
-        @LOC("THIS,LayerIIIDecoder.OUT") float sum;
+        @LOC("THIS,LayerIIIDecoder.TSOUT") float pp1;
+        @LOC("THIS,LayerIIIDecoder.TSOUT") float pp2;
+        @LOC("THIS,LayerIIIDecoder.TSOUT") float sum;
         pp2 = tsOutCopy[12 + i] * 0.500000000f;
         pp1 = tsOutCopy[6 + i] * 0.866025403f;
         sum = tsOutCopy[0 + i] + pp2;
@@ -2006,7 +2109,7 @@ final class LayerIIIDecoder implements FrameDecoder {
         tmpf_5 *= 0.517638090f;
 
         // Output butterflies on 2 3 point IDCT's (for 6 point IDCT)
-        @LOC("THIS,LayerIIIDecoder.OUT") float save = tmpf_0;
+        @LOC("THIS,LayerIIIDecoder.TSOUT") float save = tmpf_0;
         tmpf_0 += tmpf_5;
         tmpf_5 = save - tmpf_5;
         save = tmpf_1;
@@ -2093,24 +2196,24 @@ final class LayerIIIDecoder implements FrameDecoder {
       tsOutCopy[5] += tsOutCopy[3];
       tsOutCopy[3] += tsOutCopy[1];
 
-      @LOC("THIS,LayerIIIDecoder.OUT") float tmp0;
-      @LOC("THIS,LayerIIIDecoder.OUT") float tmp1;
-      @LOC("THIS,LayerIIIDecoder.OUT") float tmp2;
-      @LOC("THIS,LayerIIIDecoder.OUT") float tmp3;
-      @LOC("THIS,LayerIIIDecoder.OUT") float tmp4;
-      @LOC("THIS,LayerIIIDecoder.OUT") float tmp0_;
-      @LOC("THIS,LayerIIIDecoder.OUT") float tmp1_;
-      @LOC("THIS,LayerIIIDecoder.OUT") float tmp2_;
-      @LOC("THIS,LayerIIIDecoder.OUT") float tmp3_;
-      @LOC("THIS,LayerIIIDecoder.OUT") float tmp0o;
-      @LOC("THIS,LayerIIIDecoder.OUT") float tmp1o;
-      @LOC("THIS,LayerIIIDecoder.OUT") float tmp2o;
-      @LOC("THIS,LayerIIIDecoder.OUT") float tmp3o;
-      @LOC("THIS,LayerIIIDecoder.OUT") float tmp4o;
-      @LOC("THIS,LayerIIIDecoder.OUT") float tmp0_o;
-      @LOC("THIS,LayerIIIDecoder.OUT") float tmp1_o;
-      @LOC("THIS,LayerIIIDecoder.OUT") float tmp2_o;
-      @LOC("THIS,LayerIIIDecoder.OUT") float tmp3_o;
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float tmp0;
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float tmp1;
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float tmp2;
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float tmp3;
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float tmp4;
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float tmp0_;
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float tmp1_;
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float tmp2_;
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float tmp3_;
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float tmp0o;
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float tmp1o;
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float tmp2o;
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float tmp3o;
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float tmp4o;
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float tmp0_o;
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float tmp1_o;
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float tmp2_o;
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float tmp3_o;
 
       // Fast 9 Point Inverse Discrete Cosine Transform
       //
@@ -2127,8 +2230,8 @@ final class LayerIIIDecoder implements FrameDecoder {
       // 9 point IDCT on even indices
 
       // 5 points on odd indices (not realy an IDCT)
-      @LOC("THIS,LayerIIIDecoder.OUT") float i00 = tsOutCopy[0] + tsOutCopy[0];
-      @LOC("THIS,LayerIIIDecoder.OUT") float iip12 = i00 + tsOutCopy[12];
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float i00 = tsOutCopy[0] + tsOutCopy[0];
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float iip12 = i00 + tsOutCopy[12];
 
       tmp0 =
           iip12 + tsOutCopy[4] * 1.8793852415718f + tsOutCopy[8] * 1.532088886238f + tsOutCopy[16]
@@ -2143,7 +2246,7 @@ final class LayerIIIDecoder implements FrameDecoder {
       tmp4 = tsOutCopy[0] - tsOutCopy[4] + tsOutCopy[8] - tsOutCopy[12] + tsOutCopy[16];
 
       // 4 points on even indices
-      @LOC("THIS,LayerIIIDecoder.OUT") float i66_ = tsOutCopy[6] * 1.732050808f; // Sqrt[3]
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float i66_ = tsOutCopy[6] * 1.732050808f; // Sqrt[3]
 
       tmp0_ =
           tsOutCopy[2] * 1.9696155060244f + i66_ + tsOutCopy[10] * 1.2855752193731f + tsOutCopy[14]
@@ -2158,8 +2261,8 @@ final class LayerIIIDecoder implements FrameDecoder {
 
       // 9 point IDCT on odd indices
       // 5 points on odd indices (not realy an IDCT)
-      @LOC("THIS,LayerIIIDecoder.OUT") float i0 = tsOutCopy[0 + 1] + tsOutCopy[0 + 1];
-      @LOC("THIS,LayerIIIDecoder.OUT") float i0p12 = i0 + tsOutCopy[12 + 1];
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float i0 = tsOutCopy[0 + 1] + tsOutCopy[0 + 1];
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float i0p12 = i0 + tsOutCopy[12 + 1];
 
       tmp0o =
           i0p12 + tsOutCopy[4 + 1] * 1.8793852415718f + tsOutCopy[8 + 1] * 1.532088886238f
@@ -2177,7 +2280,7 @@ final class LayerIIIDecoder implements FrameDecoder {
           (tsOutCopy[0 + 1] - tsOutCopy[4 + 1] + tsOutCopy[8 + 1] - tsOutCopy[12 + 1] + tsOutCopy[16 + 1]) * 0.707106781f; // Twiddled
 
       // 4 points on even indices
-      @LOC("THIS,LayerIIIDecoder.OUT") float i6_ = tsOutCopy[6 + 1] * 1.732050808f; // Sqrt[3]
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float i6_ = tsOutCopy[6 + 1] * 1.732050808f; // Sqrt[3]
 
       tmp0_o =
           tsOutCopy[2 + 1] * 1.9696155060244f + i6_ + tsOutCopy[10 + 1] * 1.2855752193731f
@@ -2196,8 +2299,8 @@ final class LayerIIIDecoder implements FrameDecoder {
       // and
       // twiddle factors for 36 point IDCT
 
-      @LOC("THIS,LayerIIIDecoder.OUT") float e;
-      @LOC("THIS,LayerIIIDecoder.OUT") float o;
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float e;
+      @LOC("THIS,LayerIIIDecoder.TSOUT") float o;
       e = tmp0 + tmp0_;
       o = (tmp0o + tmp0_o) * 0.501909918f;
       tmpf_0 = e + o;