boolean adef = (offset >> 3 & 1) == 1;
boolean bdef = (offset >> 4 & 1) == 1;
// If both A and B use the default encoding, what's the point of
// having a run of default values followed by default values
if (adef && bdef)
throw new Pack200Exception(
"ADef and BDef should never both be true");
int kb = (kbflag ? in.read() : 3);
int k = (kb + 1) * (int) Math.pow(16, kx);
Codec aCodec, bCodec;
if (adef) {
aCodec = defaultCodec;
} else {
aCodec = getCodec(in.read(), in, defaultCodec);
}
if (bdef) {
bCodec = defaultCodec;
} else {
bCodec = getCodec(in.read(), in, defaultCodec);
}
return new RunCodec(k, aCodec, bCodec);
} else if (value >= 141 && value <= 188) { // Population Codec
int offset = value - 141;
boolean fdef = (offset & 1) == 1;
boolean udef = (offset >> 1 & 1) == 1;
int tdefl = offset >> 2;
boolean tdef = tdefl != 0;
// From section 6.7.3 of spec
final int[] tdefToL = { 0, 4, 8, 16, 32, 64, 128, 192, 224, 240,
248, 252 };
int l = tdefToL[tdefl];
// NOTE: Do not re-factor this to bring out uCodec; the order in
// which
// they are read from the stream is important
if (tdef) {
Codec fCodec = (fdef ? defaultCodec : getCodec(in.read(), in,
defaultCodec));
Codec uCodec = (udef ? defaultCodec : getCodec(in.read(), in,
defaultCodec));
// Unfortunately, if tdef, then tCodec depends both on l and
// also on k, the
// number of items read from the fCodec. So we don't know in
// advance what
// the codec will be.
return new PopulationCodec(fCodec, l, uCodec);
} else {
Codec fCodec = (fdef ? defaultCodec : getCodec(in.read(), in,
defaultCodec));
Codec tCodec = getCodec(in.read(), in, defaultCodec);
Codec uCodec = (udef ? defaultCodec : getCodec(in.read(), in,
defaultCodec));
return new PopulationCodec(fCodec, tCodec, uCodec);
}
} else {
throw new Pack200Exception("Invalid codec encoding byte (" + value
+ ") found");
}
}