changes.
[IRC.git] / Robust / src / Benchmarks / SSJava / MP3Decoder / LayerIIIDecoder.java
index 031113ff2d49dac990f614c39c5a5aeb8c835d95..c6766010d0d06857a79406da4712d1d859f4e09d 100644 (file)
@@ -32,8 +32,6 @@
  *----------------------------------------------------------------------
  */
 
-
-
 /**
  * Class Implementing Layer 3 Decoder.
  * 
@@ -49,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*,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*")
+@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*,RO*,RAWOUT*")
 @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);
@@ -58,7 +56,7 @@ final class LayerIIIDecoder implements FrameDecoder {
 
   // MDM: removed, as this wasn't being used.
   // private float CheckSumOut1d = 0.0f;
-  @LOC("SI1")
+  @LOC("IS1D")
   private int CheckSumHuff = 0;
   @LOC("IS1D")
   private int[] is_1d;
@@ -487,6 +485,9 @@ final class LayerIIIDecoder implements FrameDecoder {
     SSJAVA.arrayinit(scalefac_buffer, 0);
     SSJAVA.arrayinit(nonzero, 576);
     SSJAVA.arrayinit(new_slen, 0);
+
+    SSJAVA.arrayinit(raw_full, 2, SBLIMIT * SSLIMIT, 0);
+    SSJAVA.arrayinit(rawout, 0);
     CheckSumHuff = 0;
     // prevblck = new float[2][SBLIMIT * SSLIMIT];
     si = new III_side_info_t();
@@ -514,15 +515,11 @@ 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;
+    filter_pos = (header.getIdx() * 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
@@ -624,10 +621,12 @@ final class LayerIIIDecoder implements FrameDecoder {
       } // 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);
+      if (gr < max_gr - 1) {
+        // 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];
@@ -637,6 +636,12 @@ final class LayerIIIDecoder implements FrameDecoder {
       // filter1.actual_write_pos);
     } // granule
 
+    // TODO
+    // init prev
+    SSJAVA.arrayinit(prevblck, 2, SBLIMIT * SSLIMIT, 0);
+    // copy from raw_full to prev
+    SSJAVA.arraycopy(prevblck, raw_full, 2, SBLIMIT * SSLIMIT);
+
     // System.out.println("#END FRAME actual_write_pos=" +
     // filter1.actual_write_pos);
 
@@ -646,7 +651,7 @@ final class LayerIIIDecoder implements FrameDecoder {
     // System.out.println("Counter = ................................."+counter);
     // if (counter < 609)
     // {
-    counter++; // count should be loc*
+    // counter++; // count should be loc*
     // buffer.write_buffer(1); // buffer!!!
     // }
     // else if (counter == 609)
@@ -667,7 +672,7 @@ final class LayerIIIDecoder implements FrameDecoder {
   @LATTICE("OUT<THIS,THIS<C,C<IN,C*,THISLOC=THIS,RETURNLOC=OUT")
   private boolean get_side_info(@LOC("THIS,LayerIIIDecoder.HD1") Header header) {
 
-    @LOC("THIS,LayerIIIDecoder.SI,LayerIIIDecoder$III_side_info_t.TEMP") SideInfoBuffer sib =
+    @LOC("THIS,LayerIIIDecoder.SI,III_side_info_t.TEMP") SideInfoBuffer sib =
         header.getSideInfoBuffer();
     @LOC("THIS,LayerIIIDecoder.SF1") int version = header.version();
 
@@ -699,8 +704,7 @@ final class LayerIIIDecoder implements FrameDecoder {
           si.ch[ch].gr[gr].big_values = sib.get_bits(9);
           si.ch[ch].gr[gr].global_gain = sib.get_bits(8);
           si.ch[ch].gr[gr].scalefac_compress = sib.get_bits(4);
-          @LOC("THIS,LayerIIIDecoder.SI,LayerIIIDecoder$III_side_info_t.TEMP") int cond =
-              sib.get_bits(1);
+          @LOC("THIS,LayerIIIDecoder.SI,III_side_info_t.TEMP") int cond = sib.get_bits(1);
           // si.ch[ch].gr[gr].window_switching_flag = sib.get_bits(1);
           // if ((si.ch[ch].gr[gr].window_switching_flag) != 0) {
           if (cond != 0) {
@@ -758,8 +762,7 @@ final class LayerIIIDecoder implements FrameDecoder {
         si.ch[ch].gr[0].global_gain = sib.get_bits(8);
         si.ch[ch].gr[0].scalefac_compress = sib.get_bits(9);
 
-        @LOC("THIS,LayerIIIDecoder.SI,LayerIIIDecoder$III_side_info_t.TEMP") int cond =
-            sib.get_bits(1);
+        @LOC("THIS,LayerIIIDecoder.SI,III_side_info_t.TEMP") int cond = sib.get_bits(1);
         // si.ch[ch].gr[0].window_switching_flag = sib.get_bits(1);
         // if ((si.ch[ch].gr[0].window_switching_flag) != 0) {
         if (cond != 0) {
@@ -809,6 +812,7 @@ final class LayerIIIDecoder implements FrameDecoder {
         *
         */
   @LATTICE("THIS<IN,THISLOC=THIS,GLOBALLOC=IN")
+  @PCLOC("THIS,LayerIIIDecoder.SF15")
   private void get_scale_factors(@LOC("THIS,LayerIIIDecoder.SF1") Header header,
       @LOC("THIS,LayerIIIDecoder.SF1") int ch, @LOC("THIS,LayerIIIDecoder.SF1") int gr) {
 
@@ -923,6 +927,7 @@ final class LayerIIIDecoder implements FrameDecoder {
 
   // ssjava
   @LATTICE("M<THIS,THIS<IN,THIS<C,C*,M*,THISLOC=THIS,GLOBALLOC=THIS")
+  @PCLOC("THIS,LayerIIIDecoder.SI0")
   private void get_LSF_scale_data(@LOC("THIS,LayerIIIDecoder.SF15") Header header,
       @LOC("THIS,LayerIIIDecoder.SF15") int ch, @LOC("THIS,LayerIIIDecoder.SF15") int gr) {
 
@@ -930,13 +935,13 @@ final class LayerIIIDecoder implements FrameDecoder {
     // @LOC("THIS,LayerIIIDecoder.GLSFD1") gr_info_s gr_info =
     // (si.ch[ch].gr[gr]); // remove alias
 
-    @LOC("THIS,LayerIIIDecoder.SI,LayerIIIDecoder$III_side_info_t.CH,LayerIIIDecoder$temporaire.GR,LayerIIIDecoder$gr_info_s.V") int scalefac_comp =
+    @LOC("THIS,LayerIIIDecoder.SI,III_side_info_t.CH,temporaire.GR,gr_info_s.V") int scalefac_comp =
         si.ch[ch].gr[gr].scalefac_compress;
     @LOC("THIS,LayerIIIDecoder.NS") int blocktypenumber;
 
-    @LOC("THIS,LayerIIIDecoder.SI,LayerIIIDecoder$III_side_info_t.CH,LayerIIIDecoder$temporaire.GR,LayerIIIDecoder$gr_info_s.V") int int_scalefac_comp;
+    @LOC("THIS,LayerIIIDecoder.SI,III_side_info_t.CH,temporaire.GR,gr_info_s.V") int int_scalefac_comp;
     @LOC("THIS,LayerIIIDecoder.SFB_SH") int m;
-    @LOC("THIS,LayerIIIDecoder.SI,LayerIIIDecoder$III_side_info_t.CH,LayerIIIDecoder$temporaire.GR,LayerIIIDecoder$gr_info_s.V") int blocknumber =
+    @LOC("THIS,LayerIIIDecoder.SI,III_side_info_t.CH,temporaire.GR,gr_info_s.V") int blocknumber =
         0;
 
     if (si.ch[ch].gr[gr].block_type == 2) {
@@ -1028,6 +1033,7 @@ final class LayerIIIDecoder implements FrameDecoder {
         *
         */
   @LATTICE("THIS<IN,THISLOC=THIS,GLOBALLOC=IN")
+  @PCLOC("THIS,LayerIIIDecoder.SF15")
   private void get_LSF_scale_factors(@LOC("THIS,LayerIIIDecoder.SF1") Header header,
       @LOC("THIS,LayerIIIDecoder.SF1") int ch, @LOC("THIS,LayerIIIDecoder.SF1") int gr) {
 
@@ -1100,10 +1106,10 @@ final class LayerIIIDecoder implements FrameDecoder {
   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) {
 
-    @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.IS1D") int x[] = new int[1];
+    @LOC("THIS,LayerIIIDecoder.IS1D") int y[] = new int[1];
+    @LOC("THIS,LayerIIIDecoder.IS1D") int v[] = new int[1];
+    @LOC("THIS,LayerIIIDecoder.IS1D") 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;
@@ -1220,6 +1226,7 @@ final class LayerIIIDecoder implements FrameDecoder {
   /**
         *
         */
+  @PCLOC("THIS,LayerIIIDecoder.LR")
   private void i_stereo_k_values(@LOC("THIS,LayerIIIDecoder.LR") int is_pos,
       @LOC("THIS,LayerIIIDecoder.LR") int io_type, @LOC("THIS,LayerIIIDecoder.LR") int i) {
     if (is_pos == 0) {
@@ -1803,11 +1810,11 @@ final class LayerIIIDecoder implements FrameDecoder {
   private void antialias(@LOC("THIS,LayerIIIDecoder.SI") int ch,
       @LOC("THIS,LayerIIIDecoder.SI") int gr) {
 
-    @LOC("THIS,LayerIIIDecoder.SI,LayerIIIDecoder$III_side_info_t.CH,LayerIIIDecoder$temporaire.GR2") int sb18;
+    @LOC("THIS,LayerIIIDecoder.SI,III_side_info_t.CH,temporaire.GR2") int sb18;
     @LOC("THIS,LayerIIIDecoder.SI1") int ss;
-    @LOC("THIS,LayerIIIDecoder.SI,LayerIIIDecoder$III_side_info_t.CH,LayerIIIDecoder$temporaire.GR2") int sb18lim;
+    @LOC("THIS,LayerIIIDecoder.SI,III_side_info_t.CH,temporaire.GR2") int sb18lim;
 
-    // @LOC("THIS,LayerIIIDecoder.SI,LayerIIIDecoder$III_side_info_t.CH,LayerIIIDecoder$temporaire.GR1")
+    // @LOC("THIS,LayerIIIDecoder.SI,III_side_info_t.CH,temporaire.GR1")
     // gr_info_s gr_info =
     // (si.ch[ch].gr[gr]);
     // 31 alias-reduction operations between each pair of sub-bands
@@ -2390,7 +2397,6 @@ final class LayerIIIDecoder implements FrameDecoder {
   // This may be adjusted for performance without any problems.
   // public static final int POW_TABLE_LIMIT=512;
 
-
   private static final int slen[][] = { { 0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4 },
       { 0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3 } };
 
@@ -2841,134 +2847,131 @@ final class LayerIIIDecoder implements FrameDecoder {
 
 }
 
+/************************************************************/
+/* L3TABLE */
+/************************************************************/
 
+@LATTICE("N<VAR")
+class SBI {
+  @LOC("VAR")
+  public int[] l;
+  @LOC("VAR")
+  public int[] s;
 
+  public SBI() {
+    l = new int[23];
+    s = new int[14];
+  }
 
-  /************************************************************/
-  /* L3TABLE */
-  /************************************************************/
-
-  @LATTICE("N<VAR")
-   class SBI {
-    @LOC("VAR")
-    public int[] l;
-    @LOC("VAR")
-    public int[] s;
+  @LATTICE("THIS<IN,THISLOC=THIS")
+  public SBI(@DELEGATE @LOC("IN") int[] thel, @DELEGATE @LOC("IN") int[] thes) {
+    l = thel;
+    s = thes;
+  }
+}
 
-    public SBI() {
-      l = new int[23];
-      s = new int[14];
-    }
+@LATTICE("V,V*")
+class gr_info_s {
+  @LOC("V")
+  public int part2_3_length = 0;
+  @LOC("V")
+  public int big_values = 0;
+  @LOC("V")
+  public int global_gain = 0;
+  @LOC("V")
+  public int scalefac_compress = 0;
+  @LOC("V")
+  public int window_switching_flag = 0;
+  @LOC("V")
+  public int block_type = 0;
+  @LOC("V")
+  public int mixed_block_flag = 0;
+  @LOC("V")
+  public int[] table_select;
+  @LOC("V")
+  public int[] subblock_gain;
+  @LOC("V")
+  public int region0_count = 0;
+  @LOC("V")
+  public int region1_count = 0;
+  @LOC("V")
+  public int preflag = 0;
+  @LOC("V")
+  public int scalefac_scale = 0;
+  @LOC("V")
+  public int count1table_select = 0;
 
-    @LATTICE("THIS<IN,THISLOC=THIS")
-    public SBI(@DELEGATE @LOC("IN") int[] thel, @DELEGATE @LOC("IN") int[] thes) {
-      l = thel;
-      s = thes;
-    }
+  /**
+   * Dummy Constructor
+   */
+  public gr_info_s() {
+    table_select = new int[3];
+    subblock_gain = new int[3];
   }
+}
 
-  @LATTICE("V,V*")
-   class gr_info_s {
-    @LOC("V")
-    public int part2_3_length = 0;
-    @LOC("V")
-    public int big_values = 0;
-    @LOC("V")
-    public int global_gain = 0;
-    @LOC("V")
-    public int scalefac_compress = 0;
-    @LOC("V")
-    public int window_switching_flag = 0;
-    @LOC("V")
-    public int block_type = 0;
-    @LOC("V")
-    public int mixed_block_flag = 0;
-    @LOC("V")
-    public int[] table_select;
-    @LOC("V")
-    public int[] subblock_gain;
-    @LOC("V")
-    public int region0_count = 0;
-    @LOC("V")
-    public int region1_count = 0;
-    @LOC("V")
-    public int preflag = 0;
-    @LOC("V")
-    public int scalefac_scale = 0;
-    @LOC("V")
-    public int count1table_select = 0;
-
-    /**
-     * Dummy Constructor
-     */
-    public gr_info_s() {
-      table_select = new int[3];
-      subblock_gain = new int[3];
-    }
-  }
+@LATTICE("GR2<GR1,GR1<GR,GR2*")
+class temporaire {
+  @LOC("GR")
+  public int[] scfsi;
+  @LOC("GR")
+  public gr_info_s[] gr;
 
-  @LATTICE("GR2<GR1,GR1<GR,GR2*")
-   class temporaire {
-    @LOC("GR")
-    public int[] scfsi;
-    @LOC("GR")
-    public gr_info_s[] gr;
-
-    /**
-     * Dummy Constructor
-     */
-    public temporaire() {
-      scfsi = new int[4];
-      gr = new gr_info_s[2];
-      gr[0] = new gr_info_s();
-      gr[1] = new gr_info_s();
-    }
+  /**
+   * Dummy Constructor
+   */
+  public temporaire() {
+    scfsi = new int[4];
+    gr = new gr_info_s[2];
+    gr[0] = new gr_info_s();
+    gr[1] = new gr_info_s();
   }
+}
 
-  @LATTICE("CH<TEMP,TEMP*")
-   class III_side_info_t {
-
-    @LOC("CH")
-    public int main_data_begin = 0;
-    @LOC("CH")
-    public int private_bits = 0;
-    @LOC("CH")
-    public temporaire[] ch;
-
-    /**
-     * Dummy Constructor
-     */
-    public III_side_info_t() {
-      ch = new temporaire[2];
-      ch[0] = new temporaire();
-      ch[1] = new temporaire();
-    }
+@LATTICE("CH<TEMP,TEMP*")
+class III_side_info_t {
+
+  @LOC("CH")
+  public int main_data_begin = 0;
+  @LOC("CH")
+  public int private_bits = 0;
+  @LOC("CH")
+  public temporaire[] ch;
+
+  /**
+   * Dummy Constructor
+   */
+  public III_side_info_t() {
+    ch = new temporaire[2];
+    ch[0] = new temporaire();
+    ch[1] = new temporaire();
   }
+}
 
-  @LATTICE("N<VAR")
-   class temporaire2 {
-    @LOC("VAR")
-    public int[] l; /* [cb] */
-    @LOC("VAR")
-    public int[][] s; /* [window][cb] */
-
-    /**
-     * Dummy Constructor
-     */
-    public temporaire2() {
-      l = new int[23];
-      s = new int[3][13];
-    }
+@LATTICE("N<VAR")
+class temporaire2 {
+  @LOC("VAR")
+  public int[] l; /* [cb] */
+  @LOC("VAR")
+  public int[][] s; /* [window][cb] */
+
+  /**
+   * Dummy Constructor
+   */
+  public temporaire2() {
+    l = new int[23];
+    s = new int[3][13];
   }
+}
 
-  // class III_scalefac_t
-  // {
-  // public temporaire2[] tab;
-  // /**
-  // * Dummy Constructor
-  // */
-  // public III_scalefac_t()
-  // {
-  // tab = new temporaire2[2];
-  // }
-  // }
+// class III_scalefac_t
+// {
+// public temporaire2[] tab;
+// /**
+// * Dummy Constructor
+// */
+// public III_scalefac_t()
+// {
+// tab = new temporaire2[2];
+// }
+// }