having new variable 'inter' in-between "reorder/antialias" and "hybrid" in order...
[IRC.git] / Robust / src / Tests / ssJava / mp3decoder / LayerIIIDecoder.java
index 5ebedb1bee3b2e24c5532c204482751753ed31ae..8714428bb07d9728353fddea7c47c1e4c08cc26b 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*,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*")
 @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);
@@ -65,6 +65,8 @@ final class LayerIIIDecoder implements FrameDecoder {
   @LOC("LR")
   private float[][][] lr;
   @LOC("OUT")
+  private float[] inter; // 576 samples
+  @LOC("OUT")
   private float[] out_1d; // 576 samples
   @LOC("OUT")
   private float[][] prevblck;
@@ -87,7 +89,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 +98,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")
@@ -122,6 +124,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];
@@ -198,12 +201,6 @@ final class LayerIIIDecoder implements FrameDecoder {
         reorder_table[i] = reorder(sfBandIndex[i].s);
     }
 
-    // Sftable
-    @LOC("VAR") int[] ll0 = { 0, 6, 11, 16, 21 };
-    @LOC("VAR") int[] ss0 = { 0, 6, 12 };
-    sftable = new Sftable(ll0, ss0);
-    // END OF Sftable
-
     // scalefac_buffer
     scalefac_buffer = new int[54];
     // END OF scalefac_buffer
@@ -249,7 +246,6 @@ final class LayerIIIDecoder implements FrameDecoder {
 
     nonzero[0] = nonzero[1] = 576;
 
-    br = new BitReserve();
     si = new III_side_info_t();
 
     initialized = true;
@@ -464,6 +460,13 @@ final class LayerIIIDecoder implements FrameDecoder {
       init(header);
     }
 
+    // overwrites once per a loop
+    samples1 = new float[32];
+    samples2 = new float[32];
+    // prevblck = new float[2][SBLIMIT * SSLIMIT];
+    si = new III_side_info_t();
+    //
+
     @LOC("THIS,LayerIIIDecoder.HD1") int nSlots = header.slots();
 
     @LOC("THIS,LayerIIIDecoder.CH0") int gr;
@@ -535,6 +538,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;
@@ -954,7 +961,8 @@ final class LayerIIIDecoder implements FrameDecoder {
 
     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++;
 
@@ -1025,22 +1033,23 @@ final class LayerIIIDecoder implements FrameDecoder {
   // int[] v = { 0 };
   // @LOC("SI1")
   // int[] w = { 0 };
-  @LOC("SI1")
-  int x[] = { 0 };
-  @LOC("SI1")
-  int y[] = { 0 };
-  @LOC("SI1")
-  int v[] = { 0 };
-  @LOC("SI1")
-  int w[] = { 0 };
+  // @LOC("SI1")
+  // int x[] = { 0 };
+  // @LOC("SI1")
+  // int y[] = { 0 };
+  // @LOC("SI1")
+  // int v[] = { 0 };
+  // @LOC("SI1")
+  // int w[] = { 0 };
 
-  @LATTICE("OUT<GLOBAL,GLOBAL<THIS,THISLOC=THIS,GLOBALLOC=GLOBAL,RETURNLOC=OUT")
+  @LATTICE("VAR<OUT,OUT<THIS,THIS<RE,THISLOC=THIS,GLOBALLOC=OUT,RETURNLOC=OUT")
   private void huffman_decode(@LOC("THIS,LayerIIIDecoder.BR,BitReserve.BIT") int part2_start_local,
       @LOC("THIS,LayerIIIDecoder.CH0") int ch, @LOC("THIS,LayerIIIDecoder.CH0") int gr) {
-    x[0] = 0;
-    y[0] = 0;
-    v[0] = 0;
-    w[0] = 0;
+
+    @LOC("RE") int x[] = new int[1];
+    @LOC("RE") int y[] = new int[1];
+    @LOC("RE") int v[] = new int[1];
+    @LOC("RE") int w[] = new int[1];
 
     @LOC("THIS,LayerIIIDecoder.BR,BitReserve.BIT") int part2_3_end =
         part2_start_local + si.ch[ch].gr[gr].part2_3_length;
@@ -1076,7 +1085,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;
@@ -1108,7 +1117,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);
 
@@ -1371,7 +1380,7 @@ 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;
+        inter[index] = 0.0f;
       }
 
       if (si.ch[ch].gr[gr].mixed_block_flag != 0) {
@@ -1380,7 +1389,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
         /*
@@ -1404,21 +1413,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];
           }
         }
 
@@ -1427,7 +1436,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
@@ -1435,7 +1444,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];
       }
     }
   }
@@ -1502,12 +1511,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.
@@ -1533,7 +1541,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)
@@ -1551,8 +1559,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) {
@@ -1568,7 +1575,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;
@@ -1587,7 +1594,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)
@@ -1602,12 +1609,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.
@@ -1626,7 +1632,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)
@@ -1644,8 +1650,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) {
@@ -1662,7 +1667,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;
@@ -1682,7 +1687,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)
@@ -1693,7 +1698,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) {
@@ -1771,10 +1776,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.OUT") float bu = inter[src_idx1];
+        @LOC("THIS,LayerIIIDecoder.OUT") float bd = inter[src_idx2];
+        inter[src_idx1] = (bu * cs[ss]) - (bd * ca[ss]);
+        inter[src_idx2] = (bd * cs[ss]) + (bu * ca[ss]);
       }
     }
   }
@@ -1820,8 +1825,6 @@ final class LayerIIIDecoder implements FrameDecoder {
       // 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];
@@ -2860,27 +2863,6 @@ final class LayerIIIDecoder implements FrameDecoder {
   /***************************************************************/
   /* END OF INV_MDCT */
   /***************************************************************/
-  @LATTICE("N<VAR")
-  class Sftable {
-    @LOC("VAR")
-    public int[] l;
-    @LOC("VAR")
-    public int[] s;
-
-    public Sftable() {
-      l = new int[5];
-      s = new int[3];
-    }
-
-    @LATTICE("THIS<IN,THISLOC=THIS")
-    public Sftable(@DELEGATE @LOC("IN") int[] thel, @DELEGATE @LOC("IN") int[] thes) {
-      l = thel;
-      s = thes;
-    }
-  }
-
-  @LOC("F")
-  public Sftable sftable;
 
   public static final int nr_of_sfb_block[][][] = {
       { { 6, 5, 5, 5 }, { 9, 9, 9, 9 }, { 6, 9, 9, 9 } },