@Override
   public int decode(byte[] block, int blkptr, int len)
   {
      if ((block == null) || (blkptr + len > block.length) || (blkptr < 0) || (len < 0))
         return -1;

      if (len == 0)
         return 0;

      final int end = blkptr + len;
      final int sz = (this.chunkSize == 0) ? len : this.chunkSize;
      int startChunk = blkptr;

      while (startChunk < end)
      {
         if (this.decodeHeader(this.freqs) == 0)
            return startChunk - blkptr;

         final int endChunk = (startChunk + sz < end) ? startChunk + sz : end;
         this.decodeChunk(block, startChunk, endChunk);        
         startChunk = endChunk;
      }

      return len;
   }