Skip to content

Commit

Permalink
Make the bitstream version available in the context.
Browse files Browse the repository at this point in the history
  • Loading branch information
flanglet committed May 10, 2021
1 parent 239ee3c commit 9828b05
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions java/src/main/java/kanzi/io/CompressedInputStream.java
Original file line number Diff line number Diff line change
@@ -132,13 +132,15 @@ protected void readHeader() throws IOException
throw new kanzi.io.IOException("Invalid stream type", Error.ERR_INVALID_FILE);

// Read stream version
final int version = (int) this.ibs.readBits(4);
final int bsVersion = (int) this.ibs.readBits(4);

// Sanity check
if (version != BITSTREAM_FORMAT_VERSION)
throw new kanzi.io.IOException("Invalid bitstream, cannot read this version of the stream: " + version,
if (bsVersion != BITSTREAM_FORMAT_VERSION)
throw new kanzi.io.IOException("Invalid bitstream, cannot read this version of the stream: " + bsVersion,
Error.ERR_STREAM_VERSION);

this.ctx.put("bsVersion", bsVersion);

// Read block checksum
if (this.ibs.readBit() == 1)
this.hasher = new XXHash32(BITSTREAM_TYPE);
1 change: 1 addition & 0 deletions java/src/main/java/kanzi/io/CompressedOutputStream.java
Original file line number Diff line number Diff line change
@@ -146,6 +146,7 @@ public CompressedOutputStream(OutputBitStream obs, Map<String, Object> ctx)
this.hasher = (checksum == true) ? new XXHash32(BITSTREAM_TYPE) : null;
this.jobs = tasks;
this.pool = threadPool;
ctx.put("bsVersion", BITSTREAM_FORMAT_VERSION);
this.sa = new SliceByteArray(new byte[0], 0);
this.buffers = new SliceByteArray[2*this.jobs];
this.closed = new AtomicBoolean(false);

0 comments on commit 9828b05

Please sign in to comment.