< prev index next >

src/java.base/share/classes/com/sun/java/util/jar/pack/AdaptiveCoding.java

Print this page




 187             int ADef   = (headCoding == dflt)?1:0;
 188             int BDef   = (tailCoding == dflt)?1:0;
 189             if (ADef+BDef > 1)  BDef = 0;  // arbitrary choice
 190             int ABDef  = 1*ADef + 2*BDef;
 191             assert(ABDef < 3);
 192             int KX     = getKXOf(K);
 193             int KB     = getKBOf(K);
 194             assert(decodeK(KX, KB) == K);
 195             int KBFlag = (KB != KB_DEFAULT)?1:0;
 196             bytes.write(_meta_run + KX + 4*KBFlag + 8*ABDef);
 197             if (KBFlag != 0)    bytes.write(KB);
 198             if (ADef == 0)  bytes.write(headCoding.getMetaCoding(dflt));
 199             if (tailCoding instanceof AdaptiveCoding) {
 200                 run = (AdaptiveCoding) tailCoding;
 201                 continue; // tail call, to avoid deep stack recursion
 202             }
 203             if (BDef == 0)  bytes.write(tailCoding.getMetaCoding(dflt));
 204             break;
 205         }
 206     }
 207     public static int parseMetaCoding(byte[] bytes, int pos, Coding dflt, CodingMethod res[]) {
 208         int op = bytes[pos++] & 0xFF;
 209         if (op < _meta_run || op >= _meta_pop)  return pos-1; // backup
 210         AdaptiveCoding prevc = null;
 211         for (boolean keepGoing = true; keepGoing; ) {
 212             keepGoing = false;
 213             assert(op >= _meta_run);
 214             op -= _meta_run;
 215             int KX = op % 4;
 216             int KBFlag = (op / 4) % 2;
 217             int ABDef = (op / 8);
 218             assert(ABDef < 3);
 219             int ADef = (ABDef & 1);
 220             int BDef = (ABDef & 2);
 221             CodingMethod[] ACode = {dflt}, BCode = {dflt};
 222             int KB = KB_DEFAULT;
 223             if (KBFlag != 0)
 224                 KB = bytes[pos++] & 0xFF;
 225             if (ADef == 0) {
 226                 pos = BandStructure.parseMetaCoding(bytes, pos, dflt, ACode);
 227             }




 187             int ADef   = (headCoding == dflt)?1:0;
 188             int BDef   = (tailCoding == dflt)?1:0;
 189             if (ADef+BDef > 1)  BDef = 0;  // arbitrary choice
 190             int ABDef  = 1*ADef + 2*BDef;
 191             assert(ABDef < 3);
 192             int KX     = getKXOf(K);
 193             int KB     = getKBOf(K);
 194             assert(decodeK(KX, KB) == K);
 195             int KBFlag = (KB != KB_DEFAULT)?1:0;
 196             bytes.write(_meta_run + KX + 4*KBFlag + 8*ABDef);
 197             if (KBFlag != 0)    bytes.write(KB);
 198             if (ADef == 0)  bytes.write(headCoding.getMetaCoding(dflt));
 199             if (tailCoding instanceof AdaptiveCoding) {
 200                 run = (AdaptiveCoding) tailCoding;
 201                 continue; // tail call, to avoid deep stack recursion
 202             }
 203             if (BDef == 0)  bytes.write(tailCoding.getMetaCoding(dflt));
 204             break;
 205         }
 206     }
 207     public static int parseMetaCoding(byte[] bytes, int pos, Coding dflt, CodingMethod[] res) {
 208         int op = bytes[pos++] & 0xFF;
 209         if (op < _meta_run || op >= _meta_pop)  return pos-1; // backup
 210         AdaptiveCoding prevc = null;
 211         for (boolean keepGoing = true; keepGoing; ) {
 212             keepGoing = false;
 213             assert(op >= _meta_run);
 214             op -= _meta_run;
 215             int KX = op % 4;
 216             int KBFlag = (op / 4) % 2;
 217             int ABDef = (op / 8);
 218             assert(ABDef < 3);
 219             int ADef = (ABDef & 1);
 220             int BDef = (ABDef & 2);
 221             CodingMethod[] ACode = {dflt}, BCode = {dflt};
 222             int KB = KB_DEFAULT;
 223             if (KBFlag != 0)
 224                 KB = bytes[pos++] & 0xFF;
 225             if (ADef == 0) {
 226                 pos = BandStructure.parseMetaCoding(bytes, pos, dflt, ACode);
 227             }


< prev index next >