mp3decoder finally passes the flow-down rule checking.
authoryeom <yeom>
Fri, 19 Aug 2011 00:00:48 +0000 (00:00 +0000)
committeryeom <yeom>
Fri, 19 Aug 2011 00:00:48 +0000 (00:00 +0000)
Robust/src/Tests/ssJava/mp3decoder/BitReserve.java
Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java
Robust/src/Tests/ssJava/mp3decoder/huffcodetab.java

index aa47a961fb54ca12a42f84fcc0bcd5aeb5c7e700..e4167f00b0048a7c334801c46521dfba40f69068 100644 (file)
@@ -52,7 +52,7 @@ final class BitReserve {
    */\r
   private static final int BUFSIZE_MASK = BUFSIZE - 1;\r
 \r
    */\r
   private static final int BUFSIZE_MASK = BUFSIZE - 1;\r
 \r
-  @LOC("OFF")\r
+  @LOC("BIT")\r
   private int offset;\r
 \r
   @LOC("BIT")\r
   private int offset;\r
 \r
   @LOC("BIT")\r
@@ -61,7 +61,7 @@ final class BitReserve {
   @LOC("BIT")\r
   private int buf_byte_idx;\r
 \r
   @LOC("BIT")\r
   private int buf_byte_idx;\r
 \r
-  @LOC("BUF")\r
+  @LOC("BIT")\r
   private final int[] buf;\r
 \r
   BitReserve() {\r
   private final int[] buf;\r
 \r
   BitReserve() {\r
@@ -76,7 +76,7 @@ final class BitReserve {
    */\r
   @RETURNLOC("THIS,BitReserve.BIT")\r
   public int hsstell() {\r
    */\r
   @RETURNLOC("THIS,BitReserve.BIT")\r
   public int hsstell() {\r
-    return (totbit); \r
+    return (totbit);\r
   }\r
 \r
   /**\r
   }\r
 \r
   /**\r
@@ -116,9 +116,10 @@ final class BitReserve {
    * \r
    * @returns 0 if next bit is reset, or 1 if next bit is set.\r
    */\r
    * \r
    * @returns 0 if next bit is reset, or 1 if next bit is set.\r
    */\r
+  @RETURNLOC("THIS,BitReserve.BIT")\r
   public int hget1bit() {\r
     totbit++;\r
   public int hget1bit() {\r
     totbit++;\r
-    @LOC("OUT") int val = buf[buf_byte_idx];\r
+    @LOC("THIS,BitReserve.BIT") int val = buf[buf_byte_idx];\r
     buf_byte_idx = (buf_byte_idx + 1) & BUFSIZE_MASK;\r
     return val;\r
   }\r
     buf_byte_idx = (buf_byte_idx + 1) & BUFSIZE_MASK;\r
     return val;\r
   }\r
index 5ebedb1bee3b2e24c5532c204482751753ed31ae..cd0d38e6021b7af49bf8c92242afe1a7d8db3cbe 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")
 // 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,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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);
 @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);
@@ -198,12 +198,6 @@ final class LayerIIIDecoder implements FrameDecoder {
         reorder_table[i] = reorder(sfBandIndex[i].s);
     }
 
         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
     // scalefac_buffer
     scalefac_buffer = new int[54];
     // END OF scalefac_buffer
@@ -1025,22 +1019,23 @@ final class LayerIIIDecoder implements FrameDecoder {
   // int[] v = { 0 };
   // @LOC("SI1")
   // int[] w = { 0 };
   // 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) {
   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;
 
     @LOC("THIS,LayerIIIDecoder.BR,BitReserve.BIT") int part2_3_end =
         part2_start_local + si.ch[ch].gr[gr].part2_3_length;
@@ -2860,27 +2855,6 @@ final class LayerIIIDecoder implements FrameDecoder {
   /***************************************************************/
   /* END OF INV_MDCT */
   /***************************************************************/
   /***************************************************************/
   /* 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 } },
 
   public static final int nr_of_sfb_block[][][] = {
       { { 6, 5, 5, 5 }, { 9, 9, 9, 9 }, { 6, 9, 9, 9 } },
index 77be768e95ecdb0ae90fc8462820bd720bab644d..2f52c134f871a9516b45f9681414937b9ad758ca 100644 (file)
@@ -506,20 +506,21 @@ final class huffcodetab {
    * Do the huffman-decoding. note! for counta,countb -the 4 bit value is\r
    * returned in y, discard x.\r
    */\r
    * Do the huffman-decoding. note! for counta,countb -the 4 bit value is\r
    * returned in y, discard x.\r
    */\r
-  @LATTICE("OUT<THIS,THIS<V,V<IN,IN<C,C*,THISLOC=THIS,RETURNLOC=OUT,GLOBALLOC=IN")\r
+  @LATTICE("OUT<V1,THIS<V1,V1<V,V<IN,IN<C,C*,V*,THISLOC=THIS,GLOBALLOC=IN")\r
+  @RETURNLOC("OUT,BitReserve.BIT")\r
   public static int huffman_decoder(@LOC("THIS,LayerIIIDecoder.SI2") int htIdx,\r
   public static int huffman_decoder(@LOC("THIS,LayerIIIDecoder.SI2") int htIdx,\r
-      @LOC("THIS,LayerIIIDecoder.SI1") int[] x, @LOC("THIS,LayerIIIDecoder.SI1") int[] y,\r
-      @LOC("THIS,LayerIIIDecoder.SI1") int[] v, @LOC("THIS,LayerIIIDecoder.SI1") int[] w,\r
-      @LOC("THIS,LayerIIIDecoder.BR") BitReserve br) {\r
+      @LOC("OUT,BitReserve.BIT") int[] x, @LOC("OUT,BitReserve.BIT") int[] y,\r
+      @LOC("OUT,BitReserve.BIT") int[] v, @LOC("OUT,BitReserve.BIT") int[] w,\r
+      @LOC("OUT") BitReserve br) {\r
     // array of all huffcodtable headers\r
     // 0..31 Huffman code table 0..31\r
     // 32,33 count1-tables\r
 \r
     @LOC("C") int dmask = 1 << ((4 * 8) - 1);\r
     @LOC("THIS,LayerIIIDecoder.SI1") int hs = 4 * 8;\r
     // array of all huffcodtable headers\r
     // 0..31 Huffman code table 0..31\r
     // 32,33 count1-tables\r
 \r
     @LOC("C") int dmask = 1 << ((4 * 8) - 1);\r
     @LOC("THIS,LayerIIIDecoder.SI1") int hs = 4 * 8;\r
-    @LOC("THIS,LayerIIIDecoder.BR,BitReserve.BIT") int level;\r
-    @LOC("THIS,LayerIIIDecoder.BR,BitReserve.BIT") int point = 0;\r
-    @LOC("OUT") int error = 1;\r
+    @LOC("OUT,BitReserve.BIT") int level;\r
+    @LOC("OUT,BitReserve.BIT") int point = 0;\r
+    @LOC("OUT,BitReserve.BIT") int error = 1;\r
     level = dmask;\r
 \r
     if (ht[htIdx].val == null)\r
     level = dmask;\r
 \r
     if (ht[htIdx].val == null)\r
@@ -618,129 +619,6 @@ final class huffcodetab {
     return error;\r
   }\r
 \r
     return error;\r
   }\r
 \r
-  /**\r
-   * Do the huffman-decoding. note! for counta,countb -the 4 bit value is\r
-   * returned in y, discard x.\r
-   */\r
-  @LATTICE("X<Y,V<Y,W<Y,Y<VAR,VAR<IN,OUT<IN,VAR*,Y*,X*,V*,W*,THISLOC=IN,GLOBALLOC=IN")\r
-  @RETURNLOC("IN")\r
-  // public static int huffman_decoder(/* @LOC("IN") huffcodetab h, */@LOC("IN")\r
-  // int idx,\r
-  // @LOC("X") int[] x, @LOC("Y") int[] y, @LOC("V") int[] v, @LOC("W") int[] w,\r
-  // @LOC("IN") BitReserve br) {\r
-  public static HuffData huffman_decoder(@LOC("IN") int idx, @LOC("IN") HuffData data) {\r
-    // array of all huffcodtable headers\r
-    // 0..31 Huffman code table 0..31\r
-    // 32,33 count1-tables\r
-\r
-    @LOC("IN") int dmask = 1 << ((4 * 8) - 1);\r
-    @LOC("IN") int hs = 4 * 8;\r
-    @LOC("VAR") int level;\r
-    @LOC("VAR") int point = 0;\r
-    @LOC("OUT") int error = 1;\r
-    level = dmask;\r
-\r
-    if (ht[idx].val == null) {\r
-      // return 2;\r
-      return data;\r
-    }\r
-\r
-    /* table 0 needs no bits */\r
-    if (ht[idx].treelen == 0) {\r
-      data.y = 0;\r
-      data.x = 0;\r
-      // return 0;\r
-      return data;\r
-    }\r
-\r
-    /* Lookup in Huffman table. */\r
-\r
-    /*\r
-     * int bitsAvailable = 0; int bitIndex = 0;\r
-     * \r
-     * int bits[] = bitbuf;\r
-     */\r
-    do {\r
-      if (ht[idx].val[point][0] == 0) { /* end of tree */\r
-        data.x = ht[idx].val[point][1] >>> 4;\r
-        data.y = ht[idx].val[point][1] & 0xf;\r
-        error = 0;\r
-        break;\r
-      }\r
-\r
-      // hget1bit() is called thousands of times, and so needs to be\r
-      // ultra fast.\r
-      /*\r
-       * if (bitIndex==bitsAvailable) { bitsAvailable = br.readBits(bits, 32);\r
-       * bitIndex = 0; }\r
-       */\r
-      // if (bits[bitIndex++]!=0)\r
-      if (data.br.hget1bit() != 0) {\r
-        while (ht[idx].val[point][1] >= MXOFF)\r
-          point += ht[idx].val[point][1];\r
-        point += ht[idx].val[point][1];\r
-      } else {\r
-        while (ht[idx].val[point][0] >= MXOFF)\r
-          point += ht[idx].val[point][0];\r
-        point += ht[idx].val[point][0];\r
-      }\r
-      level >>>= 1;\r
-      // MDM: ht[0] is always 0;\r
-    } while ((level != 0) || (point < 0 /* ht[0].treelen */));\r
-\r
-    // put back any bits not consumed\r
-    /*\r
-     * int unread = (bitsAvailable-bitIndex); if (unread>0)\r
-     * br.rewindNbits(unread);\r
-     */\r
-    /* Process sign encodings for quadruples tables. */\r
-    // System.out.println(h.tablename);\r
-    if (ht[idx].tablename0 == '3' && (ht[idx].tablename1 == '2' || ht[idx].tablename1 == '3')) {\r
-      data.v = (data.y >> 3) & 1;\r
-      data.w = (data.y >> 2) & 1;\r
-      data.x = (data.y >> 1) & 1;\r
-      data.y = data.y & 1;\r
-\r
-      /*\r
-       * v, w, x and y are reversed in the bitstream. switch them around to make\r
-       * test bistream work.\r
-       */\r
-\r
-      if (data.v != 0)\r
-        if (data.br.hget1bit() != 0)\r
-          data.v = -data.v;\r
-      if (data.w != 0)\r
-        if (data.br.hget1bit() != 0)\r
-          data.w = -data.w;\r
-      if (data.x != 0)\r
-        if (data.br.hget1bit() != 0)\r
-          data.x = -data.x;\r
-      if (data.y != 0)\r
-        if (data.br.hget1bit() != 0)\r
-          data.y = -data.y;\r
-    } else {\r
-      // Process sign and escape encodings for dual tables.\r
-      // x and y are reversed in the test bitstream.\r
-      // Reverse x and y here to make test bitstream work.\r
-\r
-      if (ht[idx].linbits != 0)\r
-        if ((ht[idx].xlen - 1) == data.x)\r
-          data.x += data.br.hgetbits(ht[idx].linbits);\r
-      if (data.x != 0)\r
-        if (data.br.hget1bit() != 0)\r
-          data.x = -data.x;\r
-      if (ht[idx].linbits != 0)\r
-        if ((ht[idx].ylen - 1) == data.y)\r
-          data.y += data.br.hgetbits(ht[idx].linbits);\r
-      if (data.y != 0)\r
-        if (data.br.hget1bit() != 0)\r
-          data.y = -data.y;\r
-    }\r
-\r
-    return data;\r
-    // return error;\r
-  }\r
-\r
   public static void inithuff() {\r
 \r
     if (ht != null)\r
   public static void inithuff() {\r
 \r
     if (ht != null)\r