Ejemplo n.º 1
0
 public void save(DataOutputStream out) throws IOException {
   literalLengthModel.save(out);
   offsetNibble0Model.save(out);
   offsetNibble1Model.save(out);
   offsetNibble2Model.save(out);
   offsetNibble3Model.save(out);
 }
Ejemplo n.º 2
0
 public Codeword encode(int symbol) {
   switch (state) {
     case LiteralLengthState:
       if (symbol > 255) {
         state = State.OffsetNibble0State;
       }
       return literalLengthModel.encode(symbol);
     case OffsetNibble0State:
       state = State.OffsetNibble1State;
       return offsetNibble0Model.encode(symbol);
     case OffsetNibble1State:
       state = State.OffsetNibble2State;
       return offsetNibble1Model.encode(symbol);
     case OffsetNibble2State:
       state = State.OffsetNibble3State;
       return offsetNibble2Model.encode(symbol);
     case OffsetNibble3State:
       state = State.LiteralLengthState;
       return offsetNibble3Model.encode(symbol);
     default:
       throw new RuntimeException();
   }
 }
Ejemplo n.º 3
0
 public Codeword decode(int bits) {
   switch (state) {
     case LiteralLengthState:
       Codeword codeword = literalLengthModel.decode(bits);
       if (codeword.getSymbol() > 255) {
         state = State.OffsetNibble0State;
       }
       return codeword;
     case OffsetNibble0State:
       state = State.OffsetNibble1State;
       return offsetNibble0Model.decode(bits);
     case OffsetNibble1State:
       state = State.OffsetNibble2State;
       return offsetNibble1Model.decode(bits);
     case OffsetNibble2State:
       state = State.OffsetNibble3State;
       return offsetNibble2Model.decode(bits);
     case OffsetNibble3State:
       state = State.LiteralLengthState;
       return offsetNibble3Model.decode(bits);
     default:
       throw new RuntimeException();
   }
 }
Ejemplo n.º 4
0
 public Codeword getCodewordForEOF() {
   return literalLengthModel.getCodewordForEOF();
 }