Skip to content

Commit 9828b05

Browse files
committed
Make the bitstream version available in the context.
1 parent 239ee3c commit 9828b05

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

java/src/main/java/kanzi/io/CompressedInputStream.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,15 @@ protected void readHeader() throws IOException
132132
throw new kanzi.io.IOException("Invalid stream type", Error.ERR_INVALID_FILE);
133133

134134
// Read stream version
135-
final int version = (int) this.ibs.readBits(4);
135+
final int bsVersion = (int) this.ibs.readBits(4);
136136

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

142+
this.ctx.put("bsVersion", bsVersion);
143+
142144
// Read block checksum
143145
if (this.ibs.readBit() == 1)
144146
this.hasher = new XXHash32(BITSTREAM_TYPE);

java/src/main/java/kanzi/io/CompressedOutputStream.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ public CompressedOutputStream(OutputBitStream obs, Map<String, Object> ctx)
146146
this.hasher = (checksum == true) ? new XXHash32(BITSTREAM_TYPE) : null;
147147
this.jobs = tasks;
148148
this.pool = threadPool;
149+
ctx.put("bsVersion", BITSTREAM_FORMAT_VERSION);
149150
this.sa = new SliceByteArray(new byte[0], 0);
150151
this.buffers = new SliceByteArray[2*this.jobs];
151152
this.closed = new AtomicBoolean(false);

0 commit comments

Comments
 (0)